Search in sources :

Example 11 with RealmList

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());
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) RealmList(io.realm.RealmList) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) Test(org.junit.Test)

Example 12 with RealmList

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());
}
Also used : RealmList(io.realm.RealmList) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) Test(org.junit.Test)

Example 13 with RealmList

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());
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RealmList(io.realm.RealmList) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) Test(org.junit.Test)

Example 14 with RealmList

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());
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RealmList(io.realm.RealmList) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) Test(org.junit.Test)

Example 15 with RealmList

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());
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RealmList(io.realm.RealmList) Stage(ch.hsr.sa.radiotour.dataaccess.models.Stage) Date(java.util.Date) Test(org.junit.Test)

Aggregations

RealmList (io.realm.RealmList)39 Realm (io.realm.Realm)23 Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)17 Test (org.junit.Test)8 RaceGroup (ch.hsr.sa.radiotour.dataaccess.models.RaceGroup)7 Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)6 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)6 JudgmentRiderConnection (ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)4 Scheduler (io.reactivex.Scheduler)4 DynamicRealm (io.realm.DynamicRealm)4 RealmConfiguration (io.realm.RealmConfiguration)4 DialogInterface (android.content.DialogInterface)2 View (android.view.View)2 Maillot (ch.hsr.sa.radiotour.dataaccess.models.Maillot)2 Reward (ch.hsr.sa.radiotour.dataaccess.models.Reward)2 EmailRealm (com.xabber.android.data.database.realm.EmailRealm)2 SocialBindingRealm (com.xabber.android.data.database.realm.SocialBindingRealm)2 SyncStateRealm (com.xabber.android.data.database.realm.SyncStateRealm)2 XMPPUserRealm (com.xabber.android.data.database.realm.XMPPUserRealm)2 XabberAccountRealm (com.xabber.android.data.database.realm.XabberAccountRealm)2