mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 14:20:55 +00:00
Change unit test to mockito
This commit is contained in:
1 parent
89a4f0f051
commit
ddadfc0165
1 file changed
+22
-38
+22
-38
@@ -1,16 +1,16 @@
|
||||
package com.sap.sailing.racecommittee.app.domain.impl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.SeriesBase;
|
||||
import com.sap.sailing.domain.base.impl.FleetImpl;
|
||||
import com.sap.sailing.domain.base.racegroup.RaceGroup;
|
||||
import com.sap.sailing.domain.base.racegroup.impl.RaceGroupImpl;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRaceIdentifier;
|
||||
import com.sap.sse.common.Util.Triple;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* This test verifies the algorithm used to escape and unescape SimpleRaceIdentifier components as used in
|
||||
@@ -22,18 +22,18 @@ import com.sap.sse.common.Util.Triple;
|
||||
public class SimpleRaceIdentifierEscapingTest {
|
||||
@Test
|
||||
public void testUnescapingSimpleRaceIdentifier() {
|
||||
test("Leaderboard with trailing backslash and dot\\.", "empty", "fleet", "raceColumn");
|
||||
test("Leaderboard\\.with\\.two dots", "empty", "fleet", "raceColumn");
|
||||
test("Leaderboard with double backslash\\\\", "empty", "fleet", "raceColumn");
|
||||
test("Leaderboard with double backslash and dot\\\\.", "empty", "fleet", "raceColumn");
|
||||
test("\\Leaderboard with leading backslash", "empty", "fleet", "raceColumn");
|
||||
test("\\.Leaderboard with leading backslash and dot", "empty", "fleet", "raceColumn");
|
||||
test("\\\\.Leaderboard with leading double backslash and dot", "empty", "fleet", "raceColumn");
|
||||
test("\\\\.Leaderboard with leading double backslash and two dots", "empty", "fleet", "raceColumn");
|
||||
test("Leaderboard with trailing backslash and dot\\.", "series", "fleet", "raceColumn");
|
||||
test("Leaderboard\\.with\\.two dots", "series", "fleet", "raceColumn");
|
||||
test("Leaderboard with double backslash\\\\", "series", "fleet", "raceColumn");
|
||||
test("Leaderboard with double backslash and dot\\\\.", "series", "fleet", "raceColumn");
|
||||
test("\\Leaderboard with leading backslash", "series", "fleet", "raceColumn");
|
||||
test("\\.Leaderboard with leading backslash and dot", "series", "fleet", "raceColumn");
|
||||
test("\\\\.Leaderboard with leading double backslash and dot", "series", "fleet", "raceColumn");
|
||||
test("\\\\.Leaderboard with leading double backslash and two dots", "series", "fleet", "raceColumn");
|
||||
}
|
||||
|
||||
private void test(String leaderboardName, String empty, String fleetName, String raceColumnName) {
|
||||
final String marshalled = build(leaderboardName, empty, fleetName, raceColumnName);
|
||||
private void test(String leaderboardName, String seriesName, String fleetName, String raceColumnName) {
|
||||
final String marshalled = build(leaderboardName, seriesName, fleetName, raceColumnName);
|
||||
final Triple<String, String, String> parsed = FleetIdentifierImpl.unescape(marshalled);
|
||||
assertEquals(leaderboardName, parsed.getA());
|
||||
assertEquals(raceColumnName, parsed.getB());
|
||||
@@ -41,30 +41,14 @@ public class SimpleRaceIdentifierEscapingTest {
|
||||
}
|
||||
|
||||
private String build(final String leaderboardName, final String seriesName, final String fleetName, final String raceColumnName) {
|
||||
final Fleet fleet = new FleetImpl(fleetName);
|
||||
final SeriesBase series = new SeriesBase() {
|
||||
private static final long serialVersionUID = 1139740910228343375L;
|
||||
Fleet fleet = mock(Fleet.class);
|
||||
SeriesBase series = mock(SeriesBase.class);
|
||||
RaceGroup raceGroup = mock(RaceGroupImpl.class);
|
||||
|
||||
when(fleet.getName()).thenReturn(fleetName);
|
||||
when(series.getName()).thenReturn(seriesName);
|
||||
when(raceGroup.getName()).thenReturn(leaderboardName);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return seriesName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String newName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMedal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Fleet> getFleets() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
RaceGroup raceGroup = new RaceGroupImpl(leaderboardName, /* displayName */ null, /* boatClass */ null, /* courseArea */ null, /* series */ null, /* regattaConfiguration */ null);
|
||||
ManagedRaceIdentifier identifier = new ManagedRaceIdentifierImpl(raceColumnName, fleet, series, raceGroup);
|
||||
return identifier.getId();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user