DirtyDataManager { public List<StockCard> correctData() { return doCorrectDirtyData(stockRepository.list()); } DirtyDataManager(); List<StockCard> correctData(); List<StockCard> correctDataForStockCardOverView(List<StockCard> stockCards); List<StockCard> scanAllStockMovements();  }
@Test public void shouldScanTheNewTwoAndDeleteTheWrongMovement() throws LMISException { List<StockCard> list = Arrays.asList(stockCard1, stockCard2); List<StockMovementItem> stockMovementsForStockCard1 = Arrays.asList(stockMovementItem11, stockMovementItem12); List<StockMovementItem> stockMovementsForStockCard2 = Arrays.asList(stockMovementItem21, stockMovementItem22); when(stockRepository.list()).thenReturn(list); when(stockMovementRepository.listLastTwoStockMovements(1)).thenReturn(stockMovementsForStockCard1); when(stockMovementRepository.listLastTwoStockMovements(2)).thenReturn(stockMovementsForStockCard2); when(stockMovementRepository.queryMovementByStockCardId(2)).thenReturn(stockMovementsForStockCard2); List<StockCard> wrongStockCards = dirtyDataManager.correctData(); assertThat(wrongStockCards.size(), is(1)); assertThat(wrongStockCards.get(0).getProduct().getCode(), is("productCode2")); }