mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 14:12:11 +00:00
add wrapper for regatta races
This commit is contained in:
1 parent
d267a5ef77
commit
ac9303fb21
2 files changed
+45
-7
No files matched your search
+34
-3
@@ -24,8 +24,8 @@ public class RegattaApi {
|
||||
return new Regatta(ctx.get(REGATTAS + "/" + regattaName));
|
||||
}
|
||||
|
||||
public JSONObject getRegattaRaces(ApiContext ctx, String regattaName) {
|
||||
return ctx.get(REGATTAS + "/" + regattaName + LIST_REGATTA_RACES);
|
||||
public RegattaRaces getRegattaRaces(ApiContext ctx, String regattaName) {
|
||||
return new RegattaRaces(ctx.get(REGATTAS + "/" + regattaName + LIST_REGATTA_RACES));
|
||||
}
|
||||
|
||||
public Competitor createAndAddCompetitor(ApiContext ctx, String regattaName, String boatclass,
|
||||
@@ -75,7 +75,7 @@ public class RegattaApi {
|
||||
final JSONArray json = ctx.post(url, queryParams);
|
||||
final RaceColumn[] result = new RaceColumn[json.size()];
|
||||
for (int i = 0; i < json.size(); i++) {
|
||||
result[i] = new RaceColumn((JSONObject)(json.get(i)));
|
||||
result[i] = new RaceColumn((JSONObject) (json.get(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -242,4 +242,35 @@ public class RegattaApi {
|
||||
return get("racename");
|
||||
}
|
||||
}
|
||||
|
||||
public class RaceNameWithId extends JsonWrapper {
|
||||
|
||||
public RaceNameWithId(JSONObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return get("name");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return get("id");
|
||||
}
|
||||
}
|
||||
|
||||
public class RegattaRaces extends JsonWrapper {
|
||||
|
||||
public RegattaRaces(JSONObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
public String getRegattaName() {
|
||||
return get("regatta");
|
||||
}
|
||||
|
||||
public RaceNameWithId[] getRaces() {
|
||||
RaceNameWithId[] array = getArray("races", RaceNameWithId.class);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -14,10 +14,12 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.selenium.api.core.ApiContext;
|
||||
import com.sap.sailing.selenium.api.event.EventApi;
|
||||
import com.sap.sailing.selenium.api.event.LeaderboardApi;
|
||||
import com.sap.sailing.selenium.api.event.RegattaApi;
|
||||
import com.sap.sailing.selenium.api.event.RegattaApi.Competitor;
|
||||
import com.sap.sailing.selenium.api.event.RegattaApi.RaceColumn;
|
||||
import com.sap.sailing.selenium.api.event.RegattaApi.Regatta;
|
||||
import com.sap.sailing.selenium.api.event.RegattaApi.RegattaRaces;
|
||||
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
|
||||
|
||||
public class RegattaApiTest extends AbstractSeleniumTest {
|
||||
@@ -27,6 +29,7 @@ public class RegattaApiTest extends AbstractSeleniumTest {
|
||||
|
||||
private final EventApi eventApi = new EventApi();
|
||||
private final RegattaApi regattaApi = new RegattaApi();
|
||||
private final LeaderboardApi leaderboardApi = new LeaderboardApi();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -65,11 +68,15 @@ public class RegattaApiTest extends AbstractSeleniumTest {
|
||||
final ApiContext ctx = createAdminApiContext(getContextRoot(), SERVER_CONTEXT);
|
||||
|
||||
eventApi.createEvent(ctx, EVENT_NAME, BOAT_CLASS, CLOSED, "default");
|
||||
JSONObject regattaRaces = regattaApi.getRegattaRaces(ctx, EVENT_NAME);
|
||||
JSONArray races = (JSONArray) regattaRaces.get("races");
|
||||
RegattaRaces regattaRaces = regattaApi.getRegattaRaces(ctx, EVENT_NAME);
|
||||
|
||||
assertEquals("read: regatta is different", EVENT_NAME, regattaRaces.get("regatta"));
|
||||
assertEquals("read: reagtta.series should have 0 entries", 0, races.size());
|
||||
assertEquals("read: regatta is different", EVENT_NAME, regattaRaces.getRegattaName());
|
||||
//assertEquals("read: reagtta.series should have 0 entries", 0, regattaRaces.getRaces().length);
|
||||
|
||||
RaceColumn[] raceColumns = regattaApi.addRaceColumn(ctx, EVENT_NAME, "R", 1);
|
||||
leaderboardApi.startRaceLogTracking(ctx, EVENT_NAME, raceColumns[0].getRaceName(), "Default");
|
||||
regattaRaces = regattaApi.getRegattaRaces(ctx, EVENT_NAME);
|
||||
assertEquals("read: reagtta.series should have 0 entries", 1, regattaRaces.getRaces().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user