Search in sources :

Example 1 with PutResult

use of com.pushtorefresh.storio.sqlite.operations.put.PutResult in project storio by pushtorefresh.

the class PutOperationDesignTest method putObjectBlocking.

@Test
public void putObjectBlocking() {
    User user = newUser();
    PutResult putResult = storIOSQLite().put().object(user).withPutResolver(UserTableMeta.PUT_RESOLVER).prepare().executeAsBlocking();
}
Also used : PutResult(com.pushtorefresh.storio.sqlite.operations.put.PutResult) Test(org.junit.Test)

Example 2 with PutResult

use of com.pushtorefresh.storio.sqlite.operations.put.PutResult in project storio by pushtorefresh.

the class BaseTest method putUserBlocking.

@NonNull
User putUserBlocking(@NonNull final User user) {
    final PutResult putResult = storIOSQLite.put().object(user).prepare().executeAsBlocking();
    assertThat(putResult).isNotNull();
    assertThat(putResult.wasInserted()).isTrue();
    return user;
}
Also used : PutResult(com.pushtorefresh.storio.sqlite.operations.put.PutResult) NonNull(android.support.annotation.NonNull)

Example 3 with PutResult

use of com.pushtorefresh.storio.sqlite.operations.put.PutResult in project storio by pushtorefresh.

the class UpdateTest method updateUserBlocking.

private void updateUserBlocking(@NonNull final User userForUpdate) {
    final PutResult updateResult = storIOSQLite.put().object(userForUpdate).prepare().executeAsBlocking();
    assertThat(updateResult.wasUpdated()).isTrue();
}
Also used : PutResult(com.pushtorefresh.storio.sqlite.operations.put.PutResult)

Example 4 with PutResult

use of com.pushtorefresh.storio.sqlite.operations.put.PutResult in project storio by pushtorefresh.

the class AutoParcelTest method updateObject.

@Test
public void updateObject() {
    final Book book = Book.builder().id(1).title("What a great book").author("Somebody").build();
    final PutResult putResult1 = storIOSQLite.put().object(book).prepare().executeAsBlocking();
    assertThat(putResult1.wasInserted()).isTrue();
    final Book bookWithUpdatedInfo = Book.builder().id(// Same id, should be updated
    1).title("Corrected title").author("Corrected author").build();
    final PutResult putResult2 = storIOSQLite.put().object(bookWithUpdatedInfo).prepare().executeAsBlocking();
    assertThat(putResult2.wasUpdated()).isTrue();
    final List<Book> storedBooks = storIOSQLite.get().listOfObjects(Book.class).withQuery(Query.builder().table(BookTableMeta.TABLE).build()).prepare().executeAsBlocking();
    assertThat(storedBooks).hasSize(1);
    assertThat(storedBooks.get(0)).isEqualTo(bookWithUpdatedInfo);
}
Also used : PutResult(com.pushtorefresh.storio.sqlite.operations.put.PutResult) Test(org.junit.Test)

Example 5 with PutResult

use of com.pushtorefresh.storio.sqlite.operations.put.PutResult in project storio by pushtorefresh.

the class AutoParcelTest method deleteObject.

@Test
public void deleteObject() {
    final Book book = Book.builder().id(1).title("What a great book").author("Somebody").build();
    final PutResult putResult = storIOSQLite.put().object(book).prepare().executeAsBlocking();
    assertThat(putResult.wasInserted()).isTrue();
    final DeleteResult deleteResult = storIOSQLite.delete().object(book).prepare().executeAsBlocking();
    assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);
    final List<Book> storedBooks = storIOSQLite.get().listOfObjects(Book.class).withQuery(Query.builder().table(BookTableMeta.TABLE).build()).prepare().executeAsBlocking();
    assertThat(storedBooks).hasSize(0);
}
Also used : PutResult(com.pushtorefresh.storio.sqlite.operations.put.PutResult) DeleteResult(com.pushtorefresh.storio.sqlite.operations.delete.DeleteResult) Test(org.junit.Test)

Aggregations

PutResult (com.pushtorefresh.storio.sqlite.operations.put.PutResult)6 Test (org.junit.Test)4 NonNull (android.support.annotation.NonNull)1 DeleteResult (com.pushtorefresh.storio.sqlite.operations.delete.DeleteResult)1