mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-11 13:22:43 +00:00
Bug 5101: drive-by fix for sporadically failing RegattaApiTest
This commit is contained in:
1 parent
d724cc9fab
commit
4fb4a9af00
2 files changed
+23
-1
No files matched your search
+22
@@ -4,9 +4,11 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
|
||||
import com.sap.sailing.selenium.api.core.ApiContext;
|
||||
|
||||
@@ -29,6 +31,26 @@ public class RegattaApi {
|
||||
return new RegattaRaces(ctx.get(REGATTAS + "/" + regattaName + LIST_REGATTA_RACES));
|
||||
}
|
||||
|
||||
public RegattaRaces getRegattaRaces(ApiContext ctx, String regattaName, Predicate<RegattaRaces> predicateToCheck)
|
||||
throws TimeoutException {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
final RegattaRaces regattaRaces = getRegattaRaces(ctx, regattaName);
|
||||
if (predicateToCheck.test(regattaRaces)) {
|
||||
return regattaRaces;
|
||||
}
|
||||
if (i == 19) {
|
||||
// skip unnecessary 500ms wait
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new TimeoutException(e);
|
||||
}
|
||||
}
|
||||
throw new TimeoutException("Expected condition failed, 20 tries, waited for 10 seconds.");
|
||||
}
|
||||
|
||||
public Competitor createAndAddCompetitor(ApiContext ctx, String regattaName, String boatclass,
|
||||
String competitorEmail, String competitorName, String nationalityIOC, UUID deviceUuid) {
|
||||
return createAndAddCompetitor(ctx, regattaName, boatclass, competitorEmail, competitorName, nationalityIOC,
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class RegattaApiTest extends AbstractSeleniumTest {
|
||||
|
||||
RaceColumn[] raceColumns = regattaApi.addRaceColumn(ctx, EVENT_NAME, "R", 1);
|
||||
leaderboardApi.startRaceLogTracking(ctx, EVENT_NAME, raceColumns[0].getRaceName(), "Default");
|
||||
regattaRaces = regattaApi.getRegattaRaces(ctx, EVENT_NAME);
|
||||
regattaRaces = regattaApi.getRegattaRaces(ctx, EVENT_NAME, r -> r.getRaces().length > 0);
|
||||
assertEquals("read: reagtta.series should have 1 entries", 1, regattaRaces.getRaces().length);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user