use of io.realm.RealmList in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method updateRaceGroupRiders.
@Test
public void updateRaceGroupRiders() {
RaceGroup raceGroupOne = new RaceGroup();
raceGroupOne.setType(RaceGroupType.LEAD);
raceGroupOne.setPosition(0);
raceGroupOne.setRiders(riders);
RealmList<Rider> newRiders = new RealmList<>();
for (int i = 3; i < 6; i++) {
Rider rider = new Rider();
rider.setTeamShortName("T");
rider.setTeamName("TEST");
rider.setCountry("T");
rider.setName("TEST " + i);
rider.setStartNr(i);
newRiders.add(rider);
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
}
RaceGroup raceGroupTwo = new RaceGroup();
raceGroupTwo.setType(RaceGroupType.NORMAL);
raceGroupTwo.setPosition(1);
raceGroupTwo.setRiders(newRiders);
synchronized (this) {
raceGroupRepository.addRaceGroup(raceGroupOne, onSaveRaceGroupCallback);
}
synchronized (this) {
raceGroupRepository.addRaceGroup(raceGroupTwo, onSaveRaceGroupCallback);
}
RealmResults<RaceGroup> res = realm.where(RaceGroup.class).findAll();
RealmList<Rider> riderToTransfer = new RealmList<>();
riderToTransfer.add(res.get(0).getRiders().first());
assertEquals(3, res.get(0).getRiders().size());
assertEquals(3, res.get(1).getRiders().size());
synchronized (this) {
raceGroupRepository.updateRaceGroupRiders(res.get(1), riderToTransfer, onUpdateRaceGroupCallBack);
}
RealmResults<RaceGroup> endRes = realm.where(RaceGroup.class).findAll();
assertEquals(2, res.get(0).getRiders().size());
assertEquals(4, res.get(1).getRiders().size());
}
use of io.realm.RealmList in project app by TourLive.
the class RiderRepositoryInstrumentedTest method addRider.
@Test
public void addRider() {
Rider rider = new Rider();
rider.setCountry("swiss");
rider.setName("testrider");
rider.setStartNr(15);
rider.setTeamName("Swiss");
rider.setTeamShortName("CH");
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
RealmResults<Rider> riders = realm.where(Rider.class).findAll();
RealmList<Rider> res = new RealmList<>();
for (Rider r : riders) {
if (r.getStartNr() == 15) {
res.add(r);
}
}
assertEquals(15, res.first().getStartNr());
}
use of io.realm.RealmList in project app by TourLive.
the class RiderRepositoryInstrumentedTest method updateRiderStateConnection.
@Test
public void updateRiderStateConnection() {
RiderStageConnection riderStageConnection = new RiderStageConnection();
riderStageConnection.setOfficialTime(100);
riderStageConnection.setOfficialGap(100);
riderStageConnection.setVirtualGap(100);
riderStageConnection.setBonusPoint(100);
riderStageConnection.setBonusTime(200);
riderStageConnection.setType(RiderStateType.AKTIVE);
synchronized (this) {
riderStageConnectionRepository.addRiderStageConnection(riderStageConnection, onSaveRiderStageConnectionCallbackCallback);
}
Rider rider = new Rider();
rider.setCountry("swiss");
rider.setName("testrider" + 1);
rider.setStartNr(15);
rider.setTeamName("Swiss");
rider.setTeamShortName("CH");
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
RealmList<RiderStageConnection> connections = new RealmList<>();
synchronized (this) {
connections.add(riderStageConnectionRepository.getAllRiderStateConnections().first());
riderRepository.updateRiderStageConnection(rider, connections, OnUpdateRiderStageCallback);
}
Rider realmRider = realm.where(Rider.class).equalTo("startNr", rider.getStartNr()).findFirst();
RealmList<RiderStageConnection> riderStageConnections = realmRider.getRiderStages();
assertEquals(100, riderStageConnections.get(0).getBonusPoint());
assertEquals(200, riderStageConnections.get(0).getBonusTime());
}
use of io.realm.RealmList in project app by TourLive.
the class RiderStageConnectionRepositoryInstrumentedTest method updateRiderState.
@Test
public void updateRiderState() {
RealmList<RiderStageConnection> riderStageConnections = new RealmList<>();
RiderStageConnection riderStageConnection = new RiderStageConnection();
riderStageConnection.setBonusPoint(10);
riderStageConnection.setBonusTime(20);
riderStageConnection.setOfficialGap(100);
riderStageConnection.setOfficialTime(100);
riderStageConnection.setType(RiderStateType.DNC);
riderStageConnection.setVirtualGap(100);
synchronized (this) {
riderStageConnectionRepository.addRiderStageConnection(riderStageConnection, onSaveRiderStageConnectionCallback);
}
initalRider();
Rider rider = realm.where(Rider.class).findAll().first();
RiderStageConnection stageConnection = realm.where(RiderStageConnection.class).findAll().first();
riderStageConnections.add(stageConnection);
synchronized (this) {
riderRepository.updateRiderStageConnection(rider, riderStageConnections, onUpdateRiderStageCallback);
}
synchronized (this) {
riderStageConnectionRepository.updateRiderState(RiderStateType.DROP, rider, onUpdateRiderStateCallBack);
}
RiderStageConnection res = riderStageConnectionRepository.getAllRiderStateConnections().first();
assertEquals(RiderStateType.DROP, res.getType());
}
use of io.realm.RealmList in project app by TourLive.
the class StageRepositoryInstrumentedTest method addStage.
@Test
public void addStage() {
RiderStageConnection riderStageConnection = new RiderStageConnection();
riderStageConnection.setBonusPoint(10);
riderStageConnection.setBonusTime(20);
riderStageConnection.setOfficialGap(100);
riderStageConnection.setOfficialTime(100);
riderStageConnection.setType(RiderStateType.DNC);
riderStageConnection.setVirtualGap(100);
synchronized (this) {
riderStageConnectionRepository.addRiderStageConnection(riderStageConnection, onSaveRiderStageConnectionCallback);
riderStageConnection.setBonusPoint(100);
riderStageConnectionRepository.addRiderStageConnection(riderStageConnection, onSaveRiderStageConnectionCallback);
}
RealmList<RiderStageConnection> connections = new RealmList<>();
RealmResults<RiderStageConnection> realmConnections = realm.where(RiderStageConnection.class).findAll();
connections.addAll(realmConnections);
Stage stage = new Stage();
stage.setStageId(1);
stage.setDistance(100);
stage.setStartTime(new Date());
stage.setEndTime(new Date());
stage.setFrom("bern");
stage.setTo("zuerich");
stage.setName("Etappe 1");
stage.setType(StageType.FLATSTAGE);
stage.setStageConnections(connections);
synchronized (this) {
stageRepository.addStage(stage, onSaveStageCallback);
}
Assert.assertEquals(100, realm.where(Stage.class).findAll().first().getDistance());
Assert.assertEquals("bern", realm.where(Stage.class).findAll().first().getFrom());
Assert.assertEquals("Etappe 1", realm.where(Stage.class).findAll().first().getName());
Assert.assertEquals(2, realm.where(Stage.class).findAll().first().getStageConnections().size());
Assert.assertEquals(20, realm.where(Stage.class).findAll().first().getStageConnections().first().getBonusTime());
}
Aggregations