ReceiptDatabaseAdapter implements SelectionBackedDatabaseAdapter<Receipt, Trip> { @NonNull @Override public Receipt read(@NonNull Cursor cursor) { final int parentIndex = cursor.getColumnIndex(ReceiptsTable.COLUMN_PARENT_TRIP_ID); final Trip trip = mTripsTable.findByPrimaryKey(cursor.getInt(parentIndex)).blockingGet(); return readForSelection(cursor, trip, true); } ReceiptDatabaseAdapter(@NonNull Table<Trip> tripsTable, @NonNull Table<PaymentMethod> paymentMethodTable,
                                  @NonNull Table<Category> categoriesTable, @NonNull StorageManager storageManager);  ReceiptDatabaseAdapter(@NonNull Table<Trip> tripsTable, @NonNull Table<PaymentMethod> paymentMethodTable,
                                  @NonNull Table<Category> categoriesTable, @NonNull StorageManager storageManager,
                                  @NonNull SyncStateAdapter syncStateAdapter); @NonNull @Override Receipt read(@NonNull Cursor cursor); @NonNull @Override Receipt readForSelection(@NonNull Cursor cursor, @NonNull Trip trip, boolean isDescending); @NonNull @Override ContentValues write(@NonNull Receipt receipt, @NonNull DatabaseOperationMetadata databaseOperationMetadata); @NonNull @Override Receipt build(@NonNull Receipt receipt, int primaryKey,
                         @NonNull UUID uuid, @NonNull DatabaseOperationMetadata databaseOperationMetadata);  }
@Test public void read() throws Exception { final Receipt receipt = new ReceiptBuilderFactory(ID) .setUuid(RECEIPT_UUID) .setTrip(mTrip) .setName(NAME) .setPrice(PRICE) .setTax(TAX) .setTax2(TAX2) .setExchangeRate(EXCHANGE_RATE) .setCategory(CATEGORY) .setFile(RECEIPT_FILE) .setDate(DATE) .setCustomOrderId(CUSTOM_ORDER_ID) .setTimeZone(TIMEZONE) .setComment(COMMENT) .setIsReimbursable(REIMBURSABLE) .setCurrency(CURRENCY_CODE) .setIsFullPage(!FULL_PAGE) .setIndex(DESCENDING_INDEX) .setPaymentMethod(PAYMENT_METHOD) .setNameHiddenFromAutoComplete(NAME_HIDDEN_FROM_AUTO_COMPLETE) .setCommentHiddenFromAutoComplete(COMMENT_HIDDEN_FROM_AUTO_COMPLETE) .setExtraEditText1(EXTRA1) .setExtraEditText2(EXTRA2) .setExtraEditText3(EXTRA3) .setSyncState(mSyncState) .build(); assertEquals(receipt, mReceiptDatabaseAdapter.read(mCursor)); }