TripDatabaseAdapter implements DatabaseAdapter<Trip> { @Override @NonNull public Trip build(@NonNull Trip trip, int primaryKey, @NonNull UUID uuid, @NonNull DatabaseOperationMetadata databaseOperationMetadata) { return new TripBuilderFactory(trip) .setId(primaryKey) .setUuid(uuid) .setDirectory(storageManager.getFile(trip.getName())) .setSyncState(syncStateAdapter.get(trip.getSyncState(), databaseOperationMetadata)) .build(); } TripDatabaseAdapter(@NonNull StorageManager storageManager, @NonNull UserPreferenceManager preferences, @NonNull SyncStateAdapter syncStateAdapter); @Override @NonNull Trip read(@NonNull Cursor cursor); @Override @NonNull ContentValues write(@NonNull Trip trip, @NonNull DatabaseOperationMetadata databaseOperationMetadata); @Override @NonNull Trip build(@NonNull Trip trip, int primaryKey, @NonNull UUID uuid, @NonNull DatabaseOperationMetadata databaseOperationMetadata);  }
@Test public void build() throws Exception { final Trip trip = new TripBuilderFactory() .setId(ID) .setUuid(TRIP_UUID) .setDirectory(mStorageManager.getFile(NAME)) .setStartDate(START_DATE) .setEndDate(END_DATE) .setStartTimeZone(START_TIMEZONE) .setEndTimeZone(END_TIMEZONE) .setComment(COMMENT) .setCostCenter(COST_CENTER) .setDefaultCurrency(CURRENCY_CODE, mPreferences.get(UserPreference.General.DefaultCurrency)) .setSyncState(mGetSyncState) .setNameHiddenFromAutoComplete(NAME_HIDDEN_FROM_AUTO_COMPLETE) .setCommentHiddenFromAutoComplete(COMMENT_HIDDEN_FROM_AUTO_COMPLETE) .setCostCenterHiddenFromAutoComplete(COST_CENTER_HIDDEN_FROM_AUTO_COMPLETE) .build(); assertEquals(trip, mTripDatabaseAdapter.build(mTrip, ID, TRIP_UUID, mock(DatabaseOperationMetadata.class))); assertEquals(trip.getSyncState(), mTripDatabaseAdapter.build(mTrip, ID, TRIP_UUID, mock(DatabaseOperationMetadata.class)).getSyncState()); }