adjusted RaceRecord and added hasReplay(), using it in test case

Change-Id: Id39dafc4bae4fb36118de779e4abf55fd401fbe6
This commit is contained in:
Axel Uhl committed 2016-05-11 16:32:41 +02:00
1 parent b6f3f31fa0
commit 72129e6311
3 files changed
+10 -3

No files matched your search

@@ -95,7 +95,7 @@ public class ParseTracTracJSONServiceOutputTest {
List<RaceRecord> races = jsonService.getRaceRecords();
assertFalse(races.isEmpty());
for (RaceRecord race : races) {
if ("REPLAY".equals(race.getRaceStatus())) {
if (race.hasReplay()) {
// replay races may have an empty / null live URI
assertTrue(race.getLiveURI() == null || new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":4400").equals(race.getLiveURI()));
// and they point to stored data in the form of a binary ".mtb" file
@@ -103,7 +103,7 @@ public class ParseTracTracJSONServiceOutputTest {
assertTrue(race.getStoredURI().toString().endsWith(expectedSuffix) ||
new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":4401").equals(race.getStoredURI()));
} else {
if (!"HIDDEN".equals(race.getRaceStatus())) {
if (!"HIDDEN".equals(race.getRaceVisibility())) {
// hidden races may have a null live URI and perhaps have already been converted to an .mtb, so only assert if not a HIDDEN race
assertEquals(new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":4400"), race.getLiveURI());
assertEquals(new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":4401"), race.getStoredURI());
@@ -39,11 +39,12 @@ public class RaceRecord {
private final List<String> boatClassNames;
private final String raceStatus;
private final String raceVisibility;
private final boolean hasReplay;
private final URL jsonUrl;
public RaceRecord(URL jsonURL, String regattaName, String name, String replayURL, String paramURLAsString,
String ID, String trackingstarttime, String trackingendtime, String racestarttime,
String commaSeparatedBoatClassNames, String status, String visibility, boolean loadLiveAndStoredURI)
String commaSeparatedBoatClassNames, String status, String visibility, boolean hasReplay, boolean loadLiveAndStoredURI)
throws URISyntaxException, IOException {
super();
this.regattaName = regattaName;
@@ -51,6 +52,7 @@ public class RaceRecord {
this.replayURL = replayURL;
this.raceStatus = status;
this.raceVisibility = visibility;
this.hasReplay = hasReplay;
this.ID = ID;
this.jsonUrl = jsonURL;
this.boatClassNames = new ArrayList<String>();
@@ -141,6 +143,10 @@ public class RaceRecord {
public boolean hasLiveAndStoredURI() {
return liveURI != null;
}
public boolean hasReplay() {
return hasReplay;
}
public String getName() {
return name;
@@ -44,6 +44,7 @@ public class JSONServiceImpl implements JSONService {
(String) jsonRaceEntry.get("classes"),
(String) jsonRaceEntry.get("status"),
(String) jsonRaceEntry.get("visibility"),
Boolean.valueOf((Boolean) jsonRaceEntry.get("has_replay")),
/*loadLiveAndStoreURI*/ loadLiveAndStoredURI);
return raceRecord;
}