use of org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesV2DtoBuilderTest method shouldSortStockCardSummaries.
@Test
public void shouldSortStockCardSummaries() throws Exception {
List<StockCard> stockCards = asList(stockCard, stockCard1, stockCard2);
fulfillMap.remove(orderable1.getId());
LocalDate asOfDate = LocalDate.now();
List<StockCardSummaryV2Dto> result = builder.build(asList(orderable2, orderable3), stockCards, fulfillMap, asOfDate);
StockCardSummaryV2Dto summary2 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable2.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
StockCardSummaryV2Dto summary3 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable3.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard2, orderable3, asOfDate)));
assertEquals(2, result.size());
assertEquals(result.get(0), summary3);
assertEquals(result.get(1), summary2);
}
use of org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummariesWithDateBeforeThereWereCards.
@Test
public void shouldBuildStockCardSummariesWithDateBeforeThereWereCards() throws Exception {
List<StockCard> stockCards = asList(stockCard, stockCard1);
LocalDate asOfDate = getBaseDate().minusDays(10);
List<StockCardSummaryV2Dto> result = builder.build(Collections.singletonList(orderable1), stockCards, fulfillMap, asOfDate);
StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
assertEquals(1, result.size());
assertThat(result, hasItems(summary1));
}
use of org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class ObjectReferenceDtoTest method shouldImplementToString.
@Test
public void shouldImplementToString() {
ObjectReferenceDto objectReference = new ObjectReferenceDtoDataBuilder().build();
ToStringTestUtils.verify(ObjectReferenceDto.class, objectReference, "SEPARATOR");
}
use of org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummaries.
@Test
public void shouldBuildStockCardSummaries() throws Exception {
List<StockCard> stockCards = asList(stockCard, stockCard1);
LocalDate asOfDate = LocalDate.now();
List<StockCardSummaryV2Dto> result = builder.build(asList(orderable1, orderable2, orderable3), stockCards, fulfillMap, asOfDate);
StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
StockCardSummaryV2Dto summary2 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable2.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
StockCardSummaryV2Dto summary3 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable3.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate)));
assertEquals(3, result.size());
assertThat(result, hasItems(summary1, summary2, summary3));
}
use of org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummariesForCurrentDate.
@Test
public void shouldBuildStockCardSummariesForCurrentDate() throws Exception {
List<StockCard> stockCards = asList(stockCard, stockCard1);
LocalDate asOfDate = LocalDate.now();
List<StockCardSummaryV2Dto> result = builder.build(Collections.singletonList(orderable1), stockCards, fulfillMap, null);
StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
assertEquals(1, result.size());
assertThat(result, hasItems(summary1));
}
Aggregations