Search in sources :

Example 26 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testInsertOrReplaceInTx.

public void testInsertOrReplaceInTx() {
    TestEntity foo = insertEntity("foo");
    TestEntity bar = insertEntity("bar");
    foo.setSimpleStringNotNull("foo2");
    assertUpdatedEntities(foo, bar, rxDao.insertOrReplaceInTx(foo, bar));
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 27 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testInsertInTx.

public void testInsertInTx() {
    TestEntity foo = RxTestHelper.createEntity("foo");
    TestEntity bar = RxTestHelper.createEntity("bar");
    TestSubscriber<Object[]> testSubscriber = RxTestHelper.awaitTestSubscriber(rxDao.insertInTx(foo, bar));
    assertEquals(1, testSubscriber.getValueCount());
    Object[] array = testSubscriber.getOnNextEvents().get(0);
    assertSame(foo, array[0]);
    assertSame(bar, array[1]);
    List<TestEntity> all = dao.loadAll();
    assertEquals(2, all.size());
    assertEquals(foo.getSimpleStringNotNull(), all.get(0).getSimpleStringNotNull());
    assertEquals(bar.getSimpleStringNotNull(), all.get(1).getSimpleStringNotNull());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 28 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxDaoTest method testUpdate.

public void testUpdate() {
    TestEntity foo = insertEntity("foo");
    foo.setSimpleString("foofoo");
    TestSubscriber testSubscriber = RxTestHelper.awaitTestSubscriber(rxDao.update(foo));
    assertEquals(1, testSubscriber.getValueCount());
    assertSame(foo, testSubscriber.getOnNextEvents().get(0));
    List<TestEntity> testEntities = dao.loadAll();
    assertEquals(1, testEntities.size());
    assertNotSame(foo, testEntities.get(0));
    assertEquals("foofoo", testEntities.get(0).getSimpleString());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) TestSubscriber(rx.observers.TestSubscriber)

Example 29 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxTestHelper method createEntity.

static TestEntity createEntity(String simpleStringNotNull) {
    TestEntity entity = new TestEntity();
    entity.setSimpleStringNotNull(simpleStringNotNull);
    return entity;
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Example 30 with TestEntity

use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.

the class RxTestHelper method insertEntity.

static TestEntity insertEntity(TestEntityDao dao, String simpleStringNotNull) {
    TestEntity entity = createEntity(simpleStringNotNull);
    dao.insert(entity);
    return entity;
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity)

Aggregations

TestEntity (org.greenrobot.greendao.daotest.TestEntity)72 ArrayList (java.util.ArrayList)16 RelationEntity (org.greenrobot.greendao.daotest.RelationEntity)4 List (java.util.List)3 DaoException (org.greenrobot.greendao.DaoException)2 TestSubscriber (rx.observers.TestSubscriber)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 WhereCondition (org.greenrobot.greendao.query.WhereCondition)1 Subscription (rx.Subscription)1