use of ch.hsr.sa.radiotour.dataaccess.models.Rider 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 ch.hsr.sa.radiotour.dataaccess.models.Rider 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 ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class RiderRepositoryInstrumentedTest method getAllRidersWithoutCallback.
@Test
public void getAllRidersWithoutCallback() {
Rider rider = new Rider();
for (int i = 1; i < 4; i++) {
rider.setCountry("swiss");
rider.setName("testrider" + 1);
rider.setStartNr(i);
rider.setTeamName("Swiss");
rider.setTeamShortName("CH");
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
}
riders = riderRepository.getAllRidersReturned();
assertEquals(3, riders.size());
assertEquals(2, riders.get(1).getStartNr());
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class RiderRepositoryInstrumentedTest method getRidersTest.
@Test
public void getRidersTest() {
Rider rider = new Rider();
for (int i = 1; i < 4; i++) {
rider.setCountry("swiss");
rider.setName("testrider" + 1);
rider.setStartNr(i);
rider.setTeamName("Swiss");
rider.setTeamShortName("CH");
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
}
synchronized (this) {
riderRepository.getAllRiders(onGetAllRidersCallback);
}
assertEquals(3, riders.size());
assertEquals(2, riders.get(1).getStartNr());
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider 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());
}
Aggregations