@Test public void shouldReturnNullLotOnHandWithNoLotInfo() { StringBuilder str = new StringBuilder(); LotOnHand lotOnHand = service.getLotOnHand(null, null, defaultProduct.getCode(), dummyCard, str); assertNull(lotOnHand); }
public LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str) { LotOnHand lotOnHand = null; if (null != lotId) { lotOnHand = lotRepository.getLotOnHandByStockCardAndLot(card.getId(), lotId); if (null == lotOnHand) { str.append("error.lot.unknown"); } } else if (null != lotObj) { if (null == lotObj.getProduct()) { lotObj.setProduct(productRepository.getByCode(productCode)); } if (!lotObj.isValid()) { str.append("error.lot.invalid"); } else { lotOnHand = getOrCreateLotOnHand(lotObj, card); } } return lotOnHand; }
StockCardService { public LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str) { LotOnHand lotOnHand = null; if (null != lotId) { lotOnHand = lotRepository.getLotOnHandByStockCardAndLot(card.getId(), lotId); if (null == lotOnHand) { str.append("error.lot.unknown"); } } else if (null != lotObj) { if (null == lotObj.getProduct()) { lotObj.setProduct(productRepository.getByCode(productCode)); } if (!lotObj.isValid()) { str.append("error.lot.invalid"); } else { lotOnHand = getOrCreateLotOnHand(lotObj, card); } } return lotOnHand; } }
StockCardService { public LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str) { LotOnHand lotOnHand = null; if (null != lotId) { lotOnHand = lotRepository.getLotOnHandByStockCardAndLot(card.getId(), lotId); if (null == lotOnHand) { str.append("error.lot.unknown"); } } else if (null != lotObj) { if (null == lotObj.getProduct()) { lotObj.setProduct(productRepository.getByCode(productCode)); } if (!lotObj.isValid()) { str.append("error.lot.invalid"); } else { lotOnHand = getOrCreateLotOnHand(lotObj, card); } } return lotOnHand; } StockCardService(FacilityService facilityService,
                   ProductRepository productRepository,
                   LotRepository lotRepository,
                   StockCardRepository repository); }
StockCardService { public LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str) { LotOnHand lotOnHand = null; if (null != lotId) { lotOnHand = lotRepository.getLotOnHandByStockCardAndLot(card.getId(), lotId); if (null == lotOnHand) { str.append("error.lot.unknown"); } } else if (null != lotObj) { if (null == lotObj.getProduct()) { lotObj.setProduct(productRepository.getByCode(productCode)); } if (!lotObj.isValid()) { str.append("error.lot.invalid"); } else { lotOnHand = getOrCreateLotOnHand(lotObj, card); } } return lotOnHand; } StockCardService(FacilityService facilityService,
                   ProductRepository productRepository,
                   LotRepository lotRepository,
                   StockCardRepository repository); @Transactional LotOnHand getOrCreateLotOnHand(Lot lot, StockCard stockCard); LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str); StockCard getOrCreateStockCard(Long facilityId, String productCode); StockCard getStockCardById(Long facilityId, Long stockCardId); List<StockCard> getStockCards(Long facilityId); @Transactional void addStockCardEntry(StockCardEntry entry); @Transactional void addStockCardEntries(List<StockCardEntry> entries); }
StockCardService { public LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str) { LotOnHand lotOnHand = null; if (null != lotId) { lotOnHand = lotRepository.getLotOnHandByStockCardAndLot(card.getId(), lotId); if (null == lotOnHand) { str.append("error.lot.unknown"); } } else if (null != lotObj) { if (null == lotObj.getProduct()) { lotObj.setProduct(productRepository.getByCode(productCode)); } if (!lotObj.isValid()) { str.append("error.lot.invalid"); } else { lotOnHand = getOrCreateLotOnHand(lotObj, card); } } return lotOnHand; } StockCardService(FacilityService facilityService,
                   ProductRepository productRepository,
                   LotRepository lotRepository,
                   StockCardRepository repository); @Transactional LotOnHand getOrCreateLotOnHand(Lot lot, StockCard stockCard); LotOnHand getLotOnHand(Long lotId, Lot lotObj, String productCode, StockCard card, StringBuilder str); StockCard getOrCreateStockCard(Long facilityId, String productCode); StockCard getStockCardById(Long facilityId, Long stockCardId); List<StockCard> getStockCards(Long facilityId); @Transactional void addStockCardEntry(StockCardEntry entry); @Transactional void addStockCardEntries(List<StockCardEntry> entries);  }