DirtyDataManager { public List<StockCard> correctDataForStockCardOverView(List<StockCard> stockCards) { return doCorrectDirtyData(stockCards); } DirtyDataManager(); List<StockCard> correctData(); List<StockCard> correctDataForStockCardOverView(List<StockCard> stockCards); List<StockCard> scanAllStockMovements();  }
@Test public void shouldScanDuplicateInventory() throws LMISException { Product product = ProductBuilder.create() .setCode("productCode1") .setProductId(1l) .setIsActive(true) .setStrength("serious1") .setPrimaryName("Primary product name1").build(); StockCard stockCard = new StockCard(); StockMovementItem stockMovementItem = new StockMovementItemBuilder() .withStockOnHand(12) .withQuantity(1) .withMovementType(MovementReasonManager.MovementType.INITIAL_INVENTORY) .build(); StockMovementItem stockMovementItem1 = new StockMovementItemBuilder() .withStockOnHand(11) .withQuantity(0) .withMovementType(MovementReasonManager.MovementType.INITIAL_INVENTORY) .build(); stockCard.setId(1l); stockCard.setProduct(product); stockCard.setStockOnHand(11); stockMovementItem.setStockCard(stockCard); stockMovementItem1.setStockCard(stockCard); List<StockCard> list = Arrays.asList(stockCard); List<StockMovementItem> duplicateMovement = Arrays.asList(stockMovementItem, stockMovementItem1); when(stockMovementRepository.listLastTwoStockMovements(1)).thenReturn(duplicateMovement); List<StockCard> wrongStockCards = dirtyDataManager.correctDataForStockCardOverView(list); assertThat(wrongStockCards.size(), is(1)); assertThat(wrongStockCards.get(0).getProduct().getCode(), is("productCode1")); }