Search in sources :

Example 11 with Judgement

use of ch.hsr.sa.radiotour.dataaccess.models.Judgement in project app by TourLive.

the class JudgmentRepositoryInstrumentedTest method getJudgmentById.

@Test
public void getJudgmentById() {
    Judgement judgement = new Judgement();
    judgement.setDistance(100);
    judgement.setName("judgment");
    judgement.setRewardId(93);
    synchronized (this) {
        judgmentRepository.addJudgment(judgement, onSaveJudgmentCallback);
    }
    Judgement realmJudgment;
    synchronized (this) {
        realmJudgment = judgmentRepository.getJudgmentsById(93).first();
    }
    Assert.assertEquals(judgement.getDistance(), realmJudgment.getDistance());
    Assert.assertEquals(judgement.getRewardId(), realmJudgment.getRewardId());
    Assert.assertEquals(judgement.getName(), realmJudgment.getName());
}
Also used : Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Test(org.junit.Test)

Example 12 with Judgement

use of ch.hsr.sa.radiotour.dataaccess.models.Judgement in project app by TourLive.

the class JudgmentRiderConnectionInstrumentedTest method addRewardRiderConnection.

@Test
public void addRewardRiderConnection() {
    addRider();
    addJudgment();
    RealmList<Rider> riderList = new RealmList<>();
    RealmList<Judgement> judgementList = new RealmList<>();
    riderList.add(RiderPresenter.getInstance().getRiderByStartNr(15));
    judgementList.add(JudgmentPresenter.getInstance().getJudgmentsById(93).first());
    JudgmentRiderConnection judgmentRiderConnection = new JudgmentRiderConnection();
    judgmentRiderConnection.setRank(1);
    judgmentRiderConnection.setJudgements(judgementList);
    judgmentRiderConnection.setRider(riderList);
    synchronized (this) {
        judgmentRiderConnectionRepository.addJudgmentRiderConnection(judgmentRiderConnection, onSaveJudgmentRiderConnectionCallback);
    }
    Assert.assertEquals(1, realm.where(JudgmentRiderConnection.class).findAll().first().getRank());
}
Also used : RealmList(io.realm.RealmList) Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection) Test(org.junit.Test)

Example 13 with Judgement

use of ch.hsr.sa.radiotour.dataaccess.models.Judgement in project app by TourLive.

the class JudgmentRiderConnectionInstrumentedTest method addJudgment.

private void addJudgment() {
    Judgement judgement = new Judgement();
    judgement.setDistance(100);
    judgement.setName("judgment");
    judgement.setRewardId(93);
    synchronized (this) {
        judgmentRepository.addJudgment(judgement, onSaveJudgmentCallback);
    }
}
Also used : Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement)

Example 14 with Judgement

use of ch.hsr.sa.radiotour.dataaccess.models.Judgement in project app by TourLive.

the class JudgmentRiderConnectionInstrumentedTest method clearAllRewardRiderConnections.

@Test
public void clearAllRewardRiderConnections() {
    addRider();
    addJudgment();
    RealmList<Rider> riderList = new RealmList<>();
    RealmList<Judgement> judgementList = new RealmList<>();
    riderList.add(RiderPresenter.getInstance().getRiderByStartNr(15));
    judgementList.add(JudgmentPresenter.getInstance().getJudgmentsById(93).first());
    JudgmentRiderConnection judgmentRiderConnection = new JudgmentRiderConnection();
    judgmentRiderConnection.setRank(1);
    judgmentRiderConnection.setJudgements(judgementList);
    judgmentRiderConnection.setRider(riderList);
    synchronized (this) {
        judgmentRiderConnectionRepository.addJudgmentRiderConnection(judgmentRiderConnection, onSaveJudgmentRiderConnectionCallback);
    }
    synchronized (this) {
        judgmentRiderConnectionRepository.clearAllJudgmentRiderConnections();
    }
    Assert.assertEquals(0, realm.where(JudgmentRiderConnection.class).findAll().size());
}
Also used : RealmList(io.realm.RealmList) Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection) Test(org.junit.Test)

Example 15 with Judgement

use of ch.hsr.sa.radiotour.dataaccess.models.Judgement in project app by TourLive.

the class RewardRepositoryInstrumentedTest method initTestData.

@Before
public void initTestData() {
    this.judgmentRepository = new JudgmentRepository();
    this.rewardRepository = new RewardRepository();
    realm = Realm.getInstance(RadioTourApplication.getInstance());
    initCallbacks();
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.where(Judgement.class).findAll().deleteAllFromRealm();
            realm.where(Reward.class).findAll().deleteAllFromRealm();
        }
    });
    Judgement judgement = new Judgement();
    judgement.setDistance(100);
    judgement.setName("judgment");
    judgement.setRewardId(93);
    synchronized (this) {
        judgmentRepository.addJudgment(judgement, onSaveJudgmentCallback);
        judgement.setName("judgment2");
        judgmentRepository.addJudgment(judgement, onSaveJudgmentCallback);
    }
}
Also used : Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) IJudgmentRepository(ch.hsr.sa.radiotour.dataaccess.interfaces.IJudgmentRepository) JudgmentRepository(ch.hsr.sa.radiotour.dataaccess.repositories.JudgmentRepository) IRewardRepository(ch.hsr.sa.radiotour.dataaccess.interfaces.IRewardRepository) RewardRepository(ch.hsr.sa.radiotour.dataaccess.repositories.RewardRepository) Reward(ch.hsr.sa.radiotour.dataaccess.models.Reward) Realm(io.realm.Realm) Before(org.junit.Before)

Aggregations

Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)16 Test (org.junit.Test)7 RealmList (io.realm.RealmList)6 JudgmentRiderConnection (ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)4 Reward (ch.hsr.sa.radiotour.dataaccess.models.Reward)4 Realm (io.realm.Realm)4 Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)3 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)2 Toast (android.widget.Toast)1 IJudgmentRepository (ch.hsr.sa.radiotour.dataaccess.interfaces.IJudgmentRepository)1 IRewardRepository (ch.hsr.sa.radiotour.dataaccess.interfaces.IRewardRepository)1 JudgmentRepository (ch.hsr.sa.radiotour.dataaccess.repositories.JudgmentRepository)1 RewardRepository (ch.hsr.sa.radiotour.dataaccess.repositories.RewardRepository)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 Before (org.junit.Before)1