use of ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection in project app by TourLive.
the class RiderStageConnectionRepository method getRiderStageConnections.
@Override
public void getRiderStageConnections(OnGetAllRiderStageConnectionsCallback callback) {
Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
RealmResults<RiderStageConnection> results = realm.where(RiderStageConnection.class).findAll();
RealmList<RiderStageConnection> res = new RealmList<>();
res.addAll(results);
if (callback != null) {
callback.onSuccess(res);
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection 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.RiderStageConnection in project app by TourLive.
the class RiderStageConnectionRepositoryInstrumentedTest method updateRiderStageConnectionRank.
@Test
public void updateRiderStageConnectionRank() {
Date date = new Date();
RiderRanking virtRank = new RiderRanking();
virtRank.setRank(1);
virtRank.setType(RankingType.VIRTUAL);
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 rSC = realm.where(RiderStageConnection.class).equalTo("virtualGap", riderStageConnection.getVirtualGap()).findFirst();
synchronized (this) {
riderStageConnectionRepository.updateRiderStageConnectionRanking(virtRank, rSC);
}
rSC = realm.where(RiderStageConnection.class).equalTo("id", rSC.getId()).findFirst();
assertEquals(1, rSC.getRiderRanking(RankingType.VIRTUAL).getRank());
}
use of ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection 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 ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection in project app by TourLive.
the class RiderStageConnectionRepositoryInstrumentedTest method getRiderByRank.
@Test
public void getRiderByRank() {
initalData();
RiderStageConnection rider = null;
for (RiderStageConnection riderStageConnection : riderStageConnectionRepository.getAllRiderStateConnections()) {
if (riderStageConnection.getBonusPoint() == 20) {
rider = riderStageConnection;
}
}
assertEquals(100, rider.getOfficialGap());
assertEquals(100, rider.getVirtualGap());
assertEquals(100, rider.getOfficialTime());
assertEquals(20, rider.getBonusPoint());
assertEquals(400, rider.getMountainBonusPoints());
assertEquals(300, rider.getSprintBonusPoints());
assertEquals(40, rider.getBonusTime());
assertEquals(RiderStateType.DOCTOR, rider.getType());
}
Aggregations