Search in sources :

Example 6 with Rider

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

Example 7 with Rider

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());
}
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 8 with Rider

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

Example 9 with Rider

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

Example 10 with Rider

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());
}
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)

Aggregations

Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)46 RealmList (io.realm.RealmList)17 Realm (io.realm.Realm)13 RaceGroup (ch.hsr.sa.radiotour.dataaccess.models.RaceGroup)9 Test (org.junit.Test)9 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)5 TextView (android.widget.TextView)3 Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)3 JSONException (org.json.JSONException)3 Fragment (android.support.v4.app.Fragment)2 View (android.view.View)2 JudgmentRiderConnection (ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)2 RiderRanking (ch.hsr.sa.radiotour.dataaccess.models.RiderRanking)2 Manifest (android.Manifest)1 AlertDialog (android.app.AlertDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 PackageManager (android.content.pm.PackageManager)1 Location (android.location.Location)1