本文整理汇总了Java中com.pushtorefresh.storio.sqlite.StorIOSQLite类的典型用法代码示例。如果您正苦于以下问题:Java StorIOSQLite类的具体用法?Java StorIOSQLite怎么用?Java StorIOSQLite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StorIOSQLite类属于com.pushtorefresh.storio.sqlite包,在下文中一共展示了StorIOSQLite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: get
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
public synchronized static StorIOSQLite get(Context context) {
if (INSTANCE != null) {
return INSTANCE;
}
INSTANCE = DefaultStorIOSQLite.builder()
.sqliteOpenHelper(new StorIODbHelper(context))
.addTypeMapping(StockUpdate.class, SQLiteTypeMapping.<StockUpdate>builder()
.putResolver(new StockUpdatePutResolver())
.getResolver(new StockUpdateGetResolver())
.deleteResolver(new StockUpdateDeleteResolver())
.build())
.build();
return INSTANCE;
}
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:17,代码来源:StorIOFactory.java
示例2: get
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
public synchronized static StorIOSQLite get(Context context) {
if (INSTANCE != null) {
return INSTANCE;
}
INSTANCE = DefaultStorIOSQLite.builder()
.sqliteOpenHelper(new StorIODbHelper(context))
.addTypeMapping(StockUpdate.class, SQLiteTypeMapping.<StockUpdate>builder()
.putResolver(new StockUpdatePutResolver())
.getResolver(createGetResolver())
.deleteResolver(createDeleteResolver())
.build())
.build();
return INSTANCE;
}
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:17,代码来源:StorIOFactory.java
示例3: shouldPassSQLWithArgsToExecSQL
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void shouldPassSQLWithArgsToExecSQL() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
RawQuery rawQuery = RawQuery.builder()
.query("DROP TABLE users")
.args("arg1", "arg2")
.build();
storIOSQLite
.lowLevel()
.executeSQL(rawQuery);
verify(sqLiteOpenHelper).getWritableDatabase("password");
verify(sqLiteDatabase).execSQL(eq(rawQuery.query()), eq(new String[]{"arg1", "arg2"}));
verifyNoMoreInteractions(sqLiteOpenHelper, sqLiteDatabase);
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:20,代码来源:CipherStoreIOTest.java
示例4: shouldPassSQLWithoutArgsToExecSQL
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void shouldPassSQLWithoutArgsToExecSQL() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
RawQuery rawQuery = RawQuery.builder()
.query("DROP TABLE IF EXISTS someTable")
.build(); // No args!
storIOSQLite
.lowLevel()
.executeSQL(rawQuery);
verify(sqLiteOpenHelper).getWritableDatabase("password");
verify(sqLiteDatabase).execSQL(eq(rawQuery.query()));
verifyNoMoreInteractions(sqLiteOpenHelper, sqLiteDatabase);
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:19,代码来源:CipherStoreIOTest.java
示例5: shouldPassArgsToInsertWithOnConflict
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void shouldPassArgsToInsertWithOnConflict() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
InsertQuery insertQuery = InsertQuery.builder()
.table("test_table")
.nullColumnHack("custom_null_hack")
.build();
ContentValues contentValues = mock(ContentValues.class);
int conflictAlgorithm = SQLiteDatabase.CONFLICT_ROLLBACK;
storIOSQLite.lowLevel().insertWithOnConflict(insertQuery, contentValues, conflictAlgorithm);
verify(sqLiteDatabase).insertWithOnConflict(
eq("test_table"),
eq("custom_null_hack"),
same(contentValues),
eq(SQLiteDatabase.CONFLICT_ROLLBACK)
);
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:23,代码来源:CipherStoreIOTest.java
示例6: notifyAboutChangesShouldNotAcceptNullAsChanges
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void notifyAboutChangesShouldNotAcceptNullAsChanges() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
StorIOSQLite.LowLevel lowLevel = storIOSQLite.lowLevel();
assertThat(lowLevel).isNotNull();
try {
//noinspection ConstantConditions
lowLevel.notifyAboutChanges(null);
failBecauseExceptionWasNotThrown(NullPointerException.class);
} catch (NullPointerException expected) {
assertThat(expected).hasMessage("Changes can not be null");
}
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:17,代码来源:CipherStoreIOTest.java
示例7: observeChangesAndNotifyAboutChangesShouldWorkCorrectly
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void observeChangesAndNotifyAboutChangesShouldWorkCorrectly() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
TestSubscriber<Changes> testSubscriber = new TestSubscriber<>();
storIOSQLite
.observeChanges()
.subscribe(testSubscriber);
testSubscriber.assertNoValues();
Changes changes = Changes.newInstance("test_table");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes);
testSubscriber.assertValue(changes);
testSubscriber.assertNoErrors();
testSubscriber.unsubscribe();
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:20,代码来源:CipherStoreIOTest.java
示例8: getStorIOSQLite
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
public static StorIOSQLite getStorIOSQLite(Context context) {
if (mStorIOSQLite != null) {
return mStorIOSQLite;
}
mStorIOSQLite = DefaultStorIOSQLite.builder()
.sqliteOpenHelper(new DbOpenHelper(context))
.addTypeMapping(Post.class, SQLiteTypeMapping.<Post>builder()
// object that knows how to perform Put Operation (insert or update)
.putResolver(new PostStorIOSQLitePutResolver())
// object that knows how to perform Get Operation
.getResolver(new PostStorIOSQLiteGetResolver())
// object that knows how to perform Delete Operation
.deleteResolver(new PostStorIOSQLiteDeleteResolver())
.build())
.addTypeMapping(Comment.class, SQLiteTypeMapping.<Comment>builder()
.putResolver(new CommentStorIOSQLitePutResolver())
.getResolver(new CommentStorIOSQLiteGetResolver())
.deleteResolver(new CommentStorIOSQLiteDeleteResolver())
.build())
.build();
return mStorIOSQLite;
}
开发者ID:leavjenn,项目名称:Hews,代码行数:24,代码来源:StorIOHelper.java
示例9: getStorIO
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
public static StorIOSQLite getStorIO(Context context) {
if (mStorIOSQLite != null) {
return mStorIOSQLite;
}
mStorIOSQLite = DefaultStorIOSQLite.builder()
.sqliteOpenHelper(new OpenHelper(context))
.addTypeMapping(HistoryItem.class, SQLiteTypeMapping.<HistoryItem>builder()
.putResolver(new HistoryItemStorIOSQLitePutResolver())
.getResolver(new HistoryItemStorIOSQLiteGetResolver())
.deleteResolver(new HistoryItemStorIOSQLiteDeleteResolver())
.build())
.build();
return mStorIOSQLite;
}
开发者ID:nbsp-team,项目名称:translator-plus,代码行数:17,代码来源:History.java
示例10: provideStorIOSQLite
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Provides @PerApp StorIOSQLite provideStorIOSQLite(RxBsuirOpenHelper openHelper, Gson gson) {
return DefaultStorIOSQLite.builder()
.sqliteOpenHelper(openHelper)
.addTypeMapping(StudentGroup.class, SQLiteTypeMapping.<StudentGroup>builder().putResolver(
new StudentGroupStorIOSQLitePutResolver())
.getResolver(new StudentGroupStorIOSQLiteGetResolver())
.deleteResolver(new StudentGroupStorIOSQLiteDeleteResolver())
.build())
.addTypeMapping(Lesson.class,
SQLiteTypeMapping.<Lesson>builder().putResolver(new LessonStorIOSQLitePutResolver(gson))
.getResolver(new LessonStorIOISQLiteGetResolver(gson))
.deleteResolver(new LessonStorIOSQLiteDeleteResolver())
.build())
.addTypeMapping(Employee.class, SQLiteTypeMapping.<Employee>builder().putResolver(
new EmployeeStorIOSQLitePutResolver(gson))
.getResolver(new EmployeeStorIOISQLiteGetResolver(gson))
.deleteResolver(new EmployeeStorIOSQLiteDeleteResolver())
.build())
.build();
}
开发者ID:drymarev,项目名称:rxbsuir,代码行数:21,代码来源:DbModule.java
示例11: shouldCloseSQLiteOpenHelper
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void shouldCloseSQLiteOpenHelper() throws IOException {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
// Should not call close before explicit call to close
verify(sqLiteOpenHelper, times(0)).close();
storIOSQLite.close();
// Should call close on SQLiteOpenHelper
verify(sqLiteOpenHelper).close();
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:13,代码来源:CipherStoreIOTest.java
示例12: nestedTransactionShouldWorkNormally
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void nestedTransactionShouldWorkNormally() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(sqLiteOpenHelper, "password")
.build();
// External transaction
storIOSQLite.lowLevel().beginTransaction();
try {
try {
// Nested transaction
storIOSQLite.lowLevel().beginTransaction();
storIOSQLite
.lowLevel()
.notifyAboutChanges(Changes.newInstance("table1"));
storIOSQLite
.lowLevel()
.notifyAboutChanges(Changes.newInstance("table2"));
// Finishing nested transaction
storIOSQLite.lowLevel().setTransactionSuccessful();
} finally {
storIOSQLite.lowLevel().endTransaction();
}
// Marking external transaction as successful
storIOSQLite.lowLevel().setTransactionSuccessful();
} finally {
// Finishing external transaction
storIOSQLite.lowLevel().endTransaction();
}
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:33,代码来源:CipherStoreIOTest.java
示例13: observeChangesInTablesShouldNotAcceptNullAsTables
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void observeChangesInTablesShouldNotAcceptNullAsTables() {
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.build();
try {
//noinspection ConstantConditions
storIOSQLite.observeChangesInTables(null);
failBecauseExceptionWasNotThrown(NullPointerException.class);
} catch (NullPointerException expected) {
assertThat(expected).hasMessage("Set of tables can not be null");
}
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:14,代码来源:CipherStoreIOTest.java
示例14: observeChangesInTables
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void observeChangesInTables() {
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.build();
TestSubscriber<Changes> testSubscriber = new TestSubscriber<>();
Set<String> tables = new HashSet<>(2);
tables.add("table1");
tables.add("table2");
storIOSQLite
.observeChangesInTables(tables)
.subscribe(testSubscriber);
testSubscriber.assertNoValues();
Changes changes1 = Changes.newInstance("table1");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes1);
testSubscriber.assertValue(changes1);
Changes changes2 = Changes.newInstance("table2");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes2);
testSubscriber.assertValues(changes1, changes2);
Changes changes3 = Changes.newInstance("table3");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes3);
// changes3 or any other changes are not expected here
testSubscriber.assertValues(changes1, changes2);
testSubscriber.assertNoErrors();
testSubscriber.unsubscribe();
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:33,代码来源:CipherStoreIOTest.java
示例15: observeChangesInTableShouldNotAcceptNullAsTables
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void observeChangesInTableShouldNotAcceptNullAsTables() {
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.build();
try {
//noinspection ConstantConditions
storIOSQLite.observeChangesInTable(null);
failBecauseExceptionWasNotThrown(NullPointerException.class);
} catch (NullPointerException expected) {
assertThat(expected).hasMessage("Table can not be null or empty");
}
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:14,代码来源:CipherStoreIOTest.java
示例16: observeChangesInTable
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void observeChangesInTable() {
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.build();
TestSubscriber<Changes> testSubscriber = new TestSubscriber<>();
storIOSQLite
.observeChangesInTable("table1")
.subscribe(testSubscriber);
testSubscriber.assertNoValues();
Changes changes1 = Changes.newInstance("table2");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes1);
testSubscriber.assertNoValues();
Changes changes2 = Changes.newInstance("table1");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes2);
testSubscriber.assertValue(changes2);
Changes changes3 = Changes.newInstance("table3");
storIOSQLite
.lowLevel()
.notifyAboutChanges(changes3);
// Subscriber should not see changes of table2 and table3
testSubscriber.assertValue(changes2);
testSubscriber.assertNoErrors();
testSubscriber.unsubscribe();
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:30,代码来源:CipherStoreIOTest.java
示例17: defaultSchedulerReturnsSpecifiedScheduler
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void defaultSchedulerReturnsSpecifiedScheduler() {
Scheduler scheduler = mock(Scheduler.class);
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.defaultScheduler(scheduler)
.build();
assertThat(storIOSQLite.defaultScheduler()).isSameAs(scheduler);
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:10,代码来源:CipherStoreIOTest.java
示例18: defaultSchedulerReturnsNullIfSpecifiedSchedulerNull
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
@Test
public void defaultSchedulerReturnsNullIfSpecifiedSchedulerNull() {
StorIOSQLite storIOSQLite = CipherStoreIO.builder()
.sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
.defaultScheduler(null)
.build();
assertThat(storIOSQLite.defaultScheduler()).isNull();
}
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:9,代码来源:CipherStoreIOTest.java
示例19: getBlock1
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
/**
* Get block 1 Observable
*/
private ContentBlock1 getBlock1(StorIOSQLite storIOSQLite, Long id) {
Query q = Query.builder()
.table(ContentBlock1Table.TABLE)
.where(ContentBlock1Table.COLUMN_ID + " = ?")
.whereArgs(id)
.build();
return storIOSQLite.get()
.object(ContentBlock1.class)
.withQuery(q)
.prepare()
.executeAsBlocking();
}
开发者ID:fusion44,项目名称:galactic-tavern-android,代码行数:17,代码来源:ContentWrapperGetResolver.java
示例20: getBlock2
import com.pushtorefresh.storio.sqlite.StorIOSQLite; //导入依赖的package包/类
/**
* Get block 2 Observable
*/
private ContentBlock2 getBlock2(StorIOSQLite storIOSQLite, Long id) {
Query q = Query.builder()
.table(ContentBlock2Table.TABLE)
.where(ContentBlock2Table.COLUMN_ID + " = ?")
.whereArgs(id)
.build();
return storIOSQLite.get()
.object(ContentBlock2.class)
.withQuery(q)
.prepare()
.executeAsBlocking();
}
开发者ID:fusion44,项目名称:galactic-tavern-android,代码行数:17,代码来源:ContentWrapperGetResolver.java
注:本文中的com.pushtorefresh.storio.sqlite.StorIOSQLite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论