Search in sources :

Example 16 with Judgement

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

the class RewardRepositoryInstrumentedTest method addReward.

@Test
public void addReward() {
    RealmList<Judgement> judgements = new RealmList<>();
    RealmResults<Judgement> realmJudgments = realm.where(Judgement.class).findAll();
    judgements.addAll(realmJudgments);
    Reward reward = new Reward();
    reward.setPoints(new RealmList<Integer>(1, 3, 5));
    reward.setMoney(new RealmList<Integer>(100, 300, 500));
    reward.setType(RewardType.POINTS);
    reward.setRewardId(93);
    reward.setRewardJudgements(judgements);
    synchronized (this) {
        rewardRepository.addReward(reward, onSaveRewardCallback);
    }
    Assert.assertEquals(93, realm.where(Reward.class).findAll().first().getRewardId().intValue());
    Assert.assertEquals(300, realm.where(Reward.class).findAll().first().getMoney().get(1).intValue());
    Assert.assertEquals(2, realm.where(Reward.class).findAll().first().getRewardJudgements().size());
    Assert.assertEquals(93, realm.where(Reward.class).findAll().first().getRewardJudgements().first().getRewardId());
}
Also used : Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) RealmList(io.realm.RealmList) Reward(ch.hsr.sa.radiotour.dataaccess.models.Reward) Test(org.junit.Test)

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