use of ch.hsr.sa.radiotour.dataaccess.models.RaceGroup in project app by TourLive.
the class RaceGroupRepository method getAllRaceGroups.
@Override
public void getAllRaceGroups(OnGetAllRaceGroupsCallback callback) {
Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
RealmResults<RaceGroup> results = realm.where(RaceGroup.class).findAll();
RealmList<RaceGroup> res = new RealmList<>();
res.addAll(results);
if (callback != null) {
callback.onSuccess(res);
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.RaceGroup in project app by TourLive.
the class RaceGroupRepository method getRaceGroupById.
@Override
public RaceGroup getRaceGroupById(String raceGroupId) {
Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
realm.beginTransaction();
RaceGroup raceGroup = realm.where(RaceGroup.class).equalTo("id", raceGroupId).findFirst();
realm.commitTransaction();
return raceGroup;
}
use of ch.hsr.sa.radiotour.dataaccess.models.RaceGroup in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method updateRaceGroupGapTime.
@Test
public void updateRaceGroupGapTime() {
RaceGroup raceGroup = new RaceGroup();
raceGroup.setType(RaceGroupType.NORMAL);
raceGroup.setPosition(1);
raceGroup.setRiders(riders);
synchronized (this) {
raceGroupRepository.addRaceGroup(raceGroup, onSaveRaceGroupCallback);
}
RealmResults<RaceGroup> res = realm.where(RaceGroup.class).findAll();
assertEquals(0, res.get(0).getHistoryGapTime());
assertEquals(0, res.get(0).getActualGapTime());
synchronized (this) {
raceGroupRepository.updateRaceGroupGapTime(res.get(0), 100, onUpdateRaceGroupCallBack);
}
RealmResults<RaceGroup> endRes = realm.where(RaceGroup.class).findAll();
assertEquals(0, res.get(0).getHistoryGapTime());
assertEquals(100, res.get(0).getActualGapTime());
}
use of ch.hsr.sa.radiotour.dataaccess.models.RaceGroup in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method addInitialRaceGroup.
@Test
public void addInitialRaceGroup() {
RaceGroup raceGroup = new RaceGroup();
raceGroup.setType(RaceGroupType.NORMAL);
raceGroup.setHistoryGapTime(100);
raceGroup.setActualGapTime(10);
raceGroup.setPosition(0);
raceGroup.setRiders(riders);
synchronized (this) {
raceGroupRepository.addInitialRaceGroup(raceGroup, onSaveRaceGroupCallback);
}
RealmResults<RaceGroup> res = realm.where(RaceGroup.class).findAll();
assertEquals(1, res.size());
assertEquals(100, res.get(0).getHistoryGapTime());
assertEquals(10, res.get(0).getActualGapTime());
assertEquals(0, res.get(0).getPosition());
assertEquals(RaceGroupType.NORMAL, res.get(0).getType());
}
use of ch.hsr.sa.radiotour.dataaccess.models.RaceGroup in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method deleteRiderInRaceGroup.
@Test
public void deleteRiderInRaceGroup() {
RaceGroup raceGroup = new RaceGroup();
raceGroup.setType(RaceGroupType.NORMAL);
raceGroup.setPosition(1);
raceGroup.setRiders(riders);
synchronized (this) {
raceGroupRepository.addRaceGroup(raceGroup, onSaveRaceGroupCallback);
}
RealmResults<RaceGroup> res = realm.where(RaceGroup.class).findAll();
RealmResults<Rider> resRiders = realm.where(Rider.class).findAll();
Rider riderToDelete = resRiders.get(0);
assertEquals(3, res.get(0).getRiders().size());
synchronized (this) {
raceGroupRepository.deleteRiderInRaceGroup(res.first(), riderToDelete, onUpdateRaceGroupCallBack);
}
RealmResults<RaceGroup> endRes = realm.where(RaceGroup.class).findAll();
assertEquals(2, endRes.get(0).getRiders().size());
}
Aggregations