Search in sources :

Example 6 with RawQuery

use of com.pushtorefresh.storio3.sqlite.queries.RawQuery in project storio by pushtorefresh.

the class DefaultStorIOSQLiteTest method shouldPassSQLWithoutArgsToExecSQL.

@Test
public void shouldPassSQLWithoutArgsToExecSQL() {
    RawQuery rawQuery = RawQuery.builder().query("DROP TABLE IF EXISTS someTable").build();
    storIOSQLite.lowLevel().executeSQL(rawQuery);
    verify(sqLiteOpenHelper).getWritableDatabase();
    verify(sqLiteDatabase).execSQL(eq(rawQuery.query()));
    verifyNoMoreInteractions(sqLiteOpenHelper, sqLiteDatabase);
}
Also used : RawQuery(com.pushtorefresh.storio3.sqlite.queries.RawQuery) Test(org.junit.Test)

Example 7 with RawQuery

use of com.pushtorefresh.storio3.sqlite.queries.RawQuery in project storio by pushtorefresh.

the class RxJavaUtilsTest method createGetFlowableOptionalCompletedAfterInitialEmissionIfNoTablesAndTags.

@Test
public void createGetFlowableOptionalCompletedAfterInitialEmissionIfNoTablesAndTags() {
    RawQuery queryWithoutTablesAnTags = RawQuery.builder().query("select * from " + UserTableMeta.TABLE + " where " + UserTableMeta.COLUMN_ID + "=?").args(1).build();
    PreparedGetObject<User> preparedGet = storIOSQLite.get().object(User.class).withQuery(queryWithoutTablesAnTags).prepare();
    TestSubscriber<Optional<User>> subscriber = new TestSubscriber<Optional<User>>();
    RxJavaUtils.createGetFlowableOptional(storIOSQLite, preparedGet, null, queryWithoutTablesAnTags, BackpressureStrategy.LATEST).subscribe(subscriber);
    subscriber.assertNoErrors();
    subscriber.assertValues(Optional.<User>empty());
    subscriber.assertComplete();
}
Also used : User(com.pushtorefresh.storio3.sqlite.integration.User) Optional(com.pushtorefresh.storio3.Optional) RawQuery(com.pushtorefresh.storio3.sqlite.queries.RawQuery) TestSubscriber(io.reactivex.subscribers.TestSubscriber) BaseTest(com.pushtorefresh.storio3.sqlite.integration.BaseTest) Test(org.junit.Test)

Example 8 with RawQuery

use of com.pushtorefresh.storio3.sqlite.queries.RawQuery in project storio by pushtorefresh.

the class RxJavaUtilsTest method createGetFlowableCompletedAfterInitialEmissionIfNoTablesAndTags.

@Test
public void createGetFlowableCompletedAfterInitialEmissionIfNoTablesAndTags() {
    RawQuery queryWithoutTablesAnTags = RawQuery.builder().query("select * from " + UserTableMeta.TABLE).build();
    PreparedGetListOfObjects<User> preparedGet = storIOSQLite.get().listOfObjects(User.class).withQuery(queryWithoutTablesAnTags).prepare();
    TestSubscriber<List<User>> subscriber = new TestSubscriber<List<User>>();
    RxJavaUtils.createGetFlowable(storIOSQLite, preparedGet, null, queryWithoutTablesAnTags, BackpressureStrategy.LATEST).subscribe(subscriber);
    subscriber.assertNoErrors();
    subscriber.assertValues(EMPTY_LIST);
    subscriber.assertComplete();
}
Also used : User(com.pushtorefresh.storio3.sqlite.integration.User) RawQuery(com.pushtorefresh.storio3.sqlite.queries.RawQuery) TestSubscriber(io.reactivex.subscribers.TestSubscriber) List(java.util.List) BaseTest(com.pushtorefresh.storio3.sqlite.integration.BaseTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 RawQuery (com.pushtorefresh.storio3.sqlite.queries.RawQuery)6 BaseTest (com.pushtorefresh.storio3.sqlite.integration.BaseTest)2 User (com.pushtorefresh.storio3.sqlite.integration.User)2 PreparedGetNumberOfResults (com.pushtorefresh.storio3.sqlite.operations.get.PreparedGetNumberOfResults)2 TestSubscriber (io.reactivex.subscribers.TestSubscriber)2 Cursor (android.database.Cursor)1 NonNull (android.support.annotation.NonNull)1 Optional (com.pushtorefresh.storio3.Optional)1 StorIOSQLite (com.pushtorefresh.storio3.sqlite.StorIOSQLite)1 PreparedExecuteSQL (com.pushtorefresh.storio3.sqlite.operations.execute.PreparedExecuteSQL)1 List (java.util.List)1