use of org.openlmis.stockmanagement.testutils.OrderableFulfillDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesV2DtoBuilderTest method before.
@Before
public void before() {
ReflectionTestUtils.setField(builder, "serviceUrl", "https://openlmis/");
orderable1 = new OrderableDtoDataBuilder().build();
orderable2 = new OrderableDtoDataBuilder().build();
orderable3 = new OrderableDtoDataBuilder().build();
StockEvent event = new StockEventDataBuilder().withFacility(facilityId).withProgram(programId).build();
stockCard = new StockCardDataBuilder(event).buildWithStockOnHandAndLineItemAndOrderableId(12, new StockCardLineItemDataBuilder().buildWithStockOnHand(16), orderable1.getId());
stockCard1 = new StockCardDataBuilder(event).buildWithStockOnHandAndLineItemAndOrderableId(26, new StockCardLineItemDataBuilder().buildWithStockOnHand(30), orderable3.getId());
stockCard2 = new StockCardDataBuilder(event).withLot(UUID.randomUUID()).buildWithStockOnHandAndLineItemAndOrderableId(22, new StockCardLineItemDataBuilder().buildWithStockOnHand(10), orderable3.getId());
fulfillMap = new HashMap<>();
fulfillMap.put(orderable1.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(asList(orderable2.getId(), orderable3.getId())).build());
fulfillMap.put(orderable2.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(Collections.singletonList(orderable1.getId())).build());
}
use of org.openlmis.stockmanagement.testutils.OrderableFulfillDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class OrderableFulfillDtoTest method shouldImplementToString.
@Test
public void shouldImplementToString() {
OrderableFulfillDto orderableFulfill = new OrderableFulfillDtoDataBuilder().build();
ToStringTestUtils.verify(OrderableFulfillDto.class, orderableFulfill);
}
use of org.openlmis.stockmanagement.testutils.OrderableFulfillDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesServiceTest method shouldFindStockCards.
@Test
public void shouldFindStockCards() throws Exception {
OrderableDto orderable = new OrderableDtoDataBuilder().build();
OrderableDto orderable2 = new OrderableDtoDataBuilder().build();
OrderableDto orderable3 = new OrderableDtoDataBuilder().build();
StockCardSummariesV2SearchParams params = new StockCardSummariesV2SearchParamsDataBuilder().withOrderableIds(asList(orderable.getId(), orderable2.getId())).build();
when(approvedProductReferenceDataService.getApprovedProducts(eq(params.getFacilityId()), eq(params.getProgramId()), eq(params.getOrderableIds()))).thenReturn(new PageImpl<>(asList(orderable, orderable2, orderable3), new PageRequest(0, Integer.MAX_VALUE), 3));
Map<UUID, OrderableFulfillDto> fulfillMap = new HashMap<>();
fulfillMap.put(orderable.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(asList(orderable2.getId(), orderable3.getId())).build());
fulfillMap.put(orderable2.getId(), new OrderableFulfillDtoDataBuilder().withCanFulfillForMe(asList(orderable.getId(), orderable3.getId())).build());
when(orderableFulfillReferenceDataService.findByIds(asList(orderable.getId(), orderable2.getId(), orderable3.getId()))).thenReturn(fulfillMap);
StockEvent event = new StockEventDataBuilder().withFacility(params.getFacilityId()).withProgram(params.getProgramId()).build();
StockCard stockCard = new StockCardDataBuilder(event).withOrderable(orderable.getId()).withStockOnHand(12).build();
StockCard stockCard1 = new StockCardDataBuilder(event).withOrderable(orderable3.getId()).withStockOnHand(26).build();
List<StockCard> stockCards = asList(stockCard, stockCard1);
when(cardRepository.findByProgramIdAndFacilityId(params.getProgramId(), params.getFacilityId())).thenReturn(stockCards);
StockCardSummaries result = stockCardSummariesService.findStockCards(params);
assertEquals(3, result.getPageOfApprovedProducts().size());
}
Aggregations