StockMovementRepository { public List<StockMovementItem> listUnSynced() throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder().where().eq("synced", false) .and().isNotNull("stockCard_id").query()); } @Inject  StockMovementRepository(Context context); List<StockMovementItem> listUnSynced(); void batchCreateStockMovementItemAndLotItems(final StockMovementItem stockMovementItem); void batchCreateOrUpdateStockMovementsAndLotMovements(final List<StockMovementItem> stockMovementItems); StockMovementItem getFirstStockMovement(); List<String> queryStockMovementDatesByProgram(final String programCode); Date queryEarliestStockMovementDateByProgram(final String programCode); StockMovementItem queryFirstStockMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryStockMovementHistory(final long stockCardId, final long startIndex, final long maxRows); List<StockMovementItem> queryStockItemsByCreatedDate(final long stockCardId, final Date periodBeginDate, final Date periodEndDate); List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate); List<StockMovementItem> listLastFiveStockMovements(final long stockCardId); List<StockMovementItem> listLastTwoStockMovements(final long stockCardId); List<StockMovementItem> queryMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryEachStockCardNewestMovement(); void deleteStockMovementItems(final StockCard stockCard);  }
@Test public void shouldListUnSyncedStockMovementItems() throws LMISException, ParseException { StockCard stockCard = saveStockCardWithOneMovement(stockRepository, productRepository); assertThat(stockCard.getForeignStockMovementItems().size(), is(1)); assertThat(stockMovementRepository.listUnSynced().size(), is(1)); createMovementItem(RECEIVE, 100, stockCard, new Date(), DateUtil.today(), true); assertThat(stockCard.getForeignStockMovementItems().size(), is(2)); assertThat(stockMovementRepository.listUnSynced(), notNullValue()); assertThat(stockMovementRepository.listUnSynced().size(), is(1)); }