CategoriesTable extends AbstractSqlTable<Category> { @Override public synchronized void onCreate(@NonNull SQLiteDatabase db, @NonNull TableDefaultsCustomizer customizer) { super.onCreate(db, customizer); final String categories = "CREATE TABLE " + getTableName() + " (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_NAME + " TEXT, " + COLUMN_CODE + " TEXT, " + COLUMN_BREAKDOWN + " BOOLEAN DEFAULT 1, " + COLUMN_DRIVE_SYNC_ID + " TEXT, " + COLUMN_DRIVE_IS_SYNCED + " BOOLEAN DEFAULT 0, " + COLUMN_DRIVE_MARKED_FOR_DELETION + " BOOLEAN DEFAULT 0, " + COLUMN_LAST_LOCAL_MODIFICATION_TIME + " DATE, " + COLUMN_CUSTOM_ORDER_ID + " INTEGER DEFAULT 0, " + COLUMN_UUID + " TEXT " + ");"; Logger.debug(this, categories); db.execSQL(categories); customizer.insertCategoryDefaults(this); } CategoriesTable(@NonNull SQLiteOpenHelper sqLiteOpenHelper,
                           @NonNull OrderingPreferencesManager orderingPreferencesManager); @Override synchronized void onCreate(@NonNull SQLiteDatabase db, @NonNull TableDefaultsCustomizer customizer); @Override synchronized void onUpgrade(@NonNull SQLiteDatabase db, int oldVersion, int newVersion, @NonNull TableDefaultsCustomizer customizer); static final String TABLE_NAME; static final String COLUMN_NAME; static final String COLUMN_CODE; static final String COLUMN_BREAKDOWN; }
@Test public void onCreate() { final TableDefaultsCustomizer customizer = mock(TableDefaultsCustomizer.class); mCategoriesTable.onCreate(mSQLiteDatabase, customizer); verify(mSQLiteDatabase, atLeastOnce()).execSQL(mSqlCaptor.capture()); verify(customizer).insertCategoryDefaults(mCategoriesTable); final List<String> allValues = mSqlCaptor.getAllValues(); assertEquals(1, allValues.size()); String creatingTable = allValues.get(0); assertTrue(creatingTable.contains("CREATE TABLE categories")); assertTrue(creatingTable.contains("id INTEGER PRIMARY KEY AUTOINCREMENT")); assertTrue(creatingTable.contains("name TEXT")); assertTrue(creatingTable.contains("code TEXT")); assertTrue(creatingTable.contains("breakdown BOOLEAN")); assertTrue(creatingTable.contains("drive_sync_id TEXT")); assertTrue(creatingTable.contains("drive_is_synced BOOLEAN DEFAULT 0")); assertTrue(creatingTable.contains("drive_marked_for_deletion BOOLEAN DEFAULT 0")); assertTrue(creatingTable.contains("last_local_modification_time DATE")); assertTrue(creatingTable.contains("custom_order_id INTEGER DEFAULT 0")); assertTrue(creatingTable.contains("entity_uuid TEXT")); }