TripsTable extends AbstractSqlTable<Trip> { @Override public synchronized void onCreate(@NonNull SQLiteDatabase db, @NonNull TableDefaultsCustomizer customizer) { super.onCreate(db, customizer); final String trips = "CREATE TABLE " + getTableName() + " (" + AbstractSqlTable.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_NAME + " TEXT UNIQUE, " + COLUMN_FROM + " DATE, " + COLUMN_TO + " DATE, " + COLUMN_FROM_TIMEZONE + " TEXT, " + COLUMN_TO_TIMEZONE + " TEXT, " + COLUMN_COMMENT + " TEXT, " + COLUMN_COST_CENTER + " TEXT, " + COLUMN_DEFAULT_CURRENCY + " TEXT, " + COLUMN_PROCESSING_STATUS + " TEXT, " + COLUMN_FILTERS + " TEXT, " + COLUMN_NAME_HIDDEN_AUTO_COMPLETE + " BOOLEAN DEFAULT 0, " + COLUMN_COMMENT_HIDDEN_AUTO_COMPLETE + " BOOLEAN DEFAULT 0, " + COLUMN_COSTCENTER_HIDDEN_AUTO_COMPLETE + " BOOLEAN DEFAULT 0, " + AbstractSqlTable.COLUMN_DRIVE_SYNC_ID + " TEXT, " + AbstractSqlTable.COLUMN_DRIVE_IS_SYNCED + " BOOLEAN DEFAULT 0, " + AbstractSqlTable.COLUMN_DRIVE_MARKED_FOR_DELETION + " BOOLEAN DEFAULT 0, " + AbstractSqlTable.COLUMN_LAST_LOCAL_MODIFICATION_TIME + " DATE, " + AbstractSqlTable.COLUMN_UUID + " TEXT " + ");"; Logger.debug(this, trips); db.execSQL(trips); } TripsTable(@NonNull SQLiteOpenHelper sqLiteOpenHelper, @NonNull StorageManager storageManager, @NonNull UserPreferenceManager preferences); @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_FROM; static final String COLUMN_TO; static final String COLUMN_FROM_TIMEZONE; static final String COLUMN_TO_TIMEZONE; static final String COLUMN_MILEAGE; static final String COLUMN_COMMENT; static final String COLUMN_COST_CENTER; static final String COLUMN_DEFAULT_CURRENCY; static final String COLUMN_FILTERS; static final String COLUMN_PROCESSING_STATUS; static final String COLUMN_NAME_HIDDEN_AUTO_COMPLETE; static final String COLUMN_COMMENT_HIDDEN_AUTO_COMPLETE; static final String COLUMN_COSTCENTER_HIDDEN_AUTO_COMPLETE; }
@Test public void onCreate() { final TableDefaultsCustomizer customizer = mock(TableDefaultsCustomizer.class); mTripsTable.onCreate(mSQLiteDatabase, customizer); verify(mSQLiteDatabase).execSQL(mSqlCaptor.capture()); verifyZeroInteractions(customizer); final String creatingTable = mSqlCaptor.getValue(); assertTrue(creatingTable.contains("CREATE TABLE trips")); assertTrue(creatingTable.contains("id INTEGER PRIMARY KEY AUTOINCREMENT")); assertTrue(creatingTable.contains("name TEXT UNIQUE")); assertTrue(creatingTable.contains("from_date DATE")); assertTrue(creatingTable.contains("to_date DATE")); assertTrue(creatingTable.contains("from_timezone TEXT")); assertTrue(creatingTable.contains("to_timezone TEXT")); assertTrue(creatingTable.contains("trips_comment TEXT")); assertTrue(creatingTable.contains("trips_cost_center TEXT")); assertTrue(creatingTable.contains("trips_default_currency TEXT")); assertTrue(creatingTable.contains("trips_filters TEXT")); assertTrue(creatingTable.contains("trip_processing_status TEXT")); 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("entity_uuid TEXT")); assertTrue(creatingTable.contains("name_hidden_auto_complete BOOLEAN DEFAULT 0")); assertTrue(creatingTable.contains("comment_hidden_auto_complete BOOLEAN DEFAULT 0")); assertTrue(creatingTable.contains("costcenter_hidden_auto_complete BOOLEAN DEFAULT 0")); }