Search in sources :

Example 1 with RewardRepository

use of ch.hsr.sa.radiotour.dataaccess.repositories.RewardRepository in project app by TourLive.

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

Example 2 with RewardRepository

use of ch.hsr.sa.radiotour.dataaccess.repositories.RewardRepository 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(realm -> {
        realm.where(Judgement.class).findAll().deleteAllFromRealm();
        realm.where(Reward.class).findAll().deleteAllFromRealm();
    });
    Judgement judgement = new Judgement();
    judgement.setId(new Random().nextLong());
    judgement.setDistance(100);
    judgement.setName("judgment");
    judgement.setRewardId(93);
    Judgement judgementTwo = new Judgement();
    judgementTwo.setId(new Random().nextLong());
    judgementTwo.setDistance(100);
    judgementTwo.setName("judgmentTwo");
    judgementTwo.setRewardId(93);
    synchronized (this) {
        judgmentRepository.addJudgment(judgement, onSaveJudgmentCallback);
        judgmentRepository.addJudgment(judgementTwo, onSaveJudgmentCallback);
    }
}
Also used : Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Random(java.util.Random) 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) Before(org.junit.Before)

Aggregations

IJudgmentRepository (ch.hsr.sa.radiotour.dataaccess.interfaces.IJudgmentRepository)2 IRewardRepository (ch.hsr.sa.radiotour.dataaccess.interfaces.IRewardRepository)2 Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)2 JudgmentRepository (ch.hsr.sa.radiotour.dataaccess.repositories.JudgmentRepository)2 RewardRepository (ch.hsr.sa.radiotour.dataaccess.repositories.RewardRepository)2 Before (org.junit.Before)2 Reward (ch.hsr.sa.radiotour.dataaccess.models.Reward)1 Realm (io.realm.Realm)1 Random (java.util.Random)1