Search in sources :

Example 1 with CanFulfillForMeEntryDtoDataBuilder

use of org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummaryV2DtoTest method shouldCompareStockCards.

@Test
public void shouldCompareStockCards() {
    StockCardSummaryV2Dto stockCard1 = new StockCardSummaryV2DtoDataBuilder().withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().build()).build();
    StockCardSummaryV2Dto stockCard2 = new StockCardSummaryV2DtoDataBuilder().build();
    assertEquals(-1, stockCard1.compareTo(stockCard2));
    stockCard2 = new StockCardSummaryV2DtoDataBuilder().withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().build()).build();
    assertEquals(0, stockCard1.compareTo(stockCard2));
    stockCard1 = new StockCardSummaryV2DtoDataBuilder().build();
    stockCard2 = new StockCardSummaryV2DtoDataBuilder().build();
    assertEquals(0, stockCard1.compareTo(stockCard2));
    stockCard2 = new StockCardSummaryV2DtoDataBuilder().withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().build()).build();
    assertEquals(1, stockCard1.compareTo(stockCard2));
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) StockCardSummaryV2Dto(org.openlmis.stockmanagement.web.stockcardsummariesv2.StockCardSummaryV2Dto) StockCardSummaryV2DtoDataBuilder(org.openlmis.stockmanagement.testutils.StockCardSummaryV2DtoDataBuilder) Test(org.junit.Test)

Example 2 with CanFulfillForMeEntryDtoDataBuilder

use of org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummaryV2DtoTest method shouldGetStockOnHand.

@Test
public void shouldGetStockOnHand() {
    StockCardSummaryV2Dto stockCard = new StockCardSummaryV2DtoDataBuilder().withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().withStockOnHand(null).build()).withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().withStockOnHand(12).build()).build();
    assertEquals(new Integer(12), stockCard.getStockOnHand());
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) StockCardSummaryV2Dto(org.openlmis.stockmanagement.web.stockcardsummariesv2.StockCardSummaryV2Dto) StockCardSummaryV2DtoDataBuilder(org.openlmis.stockmanagement.testutils.StockCardSummaryV2DtoDataBuilder) Test(org.junit.Test)

Example 3 with CanFulfillForMeEntryDtoDataBuilder

use of org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder 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);
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) ObjectReferenceDtoDataBuilder(org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 4 with CanFulfillForMeEntryDtoDataBuilder

use of org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder 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));
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) ObjectReferenceDtoDataBuilder(org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 5 with CanFulfillForMeEntryDtoDataBuilder

use of org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummaryV2DtoTest method shouldGetNullStockOnHandIfCanFulfillDoesNotHaveStockOnHand.

@Test
public void shouldGetNullStockOnHandIfCanFulfillDoesNotHaveStockOnHand() {
    StockCardSummaryV2Dto stockCard = new StockCardSummaryV2DtoDataBuilder().withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().withStockOnHand(null).build()).withCanFulfillForMe(new CanFulfillForMeEntryDtoDataBuilder().withStockOnHand(null).build()).build();
    assertEquals(null, stockCard.getStockOnHand());
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) StockCardSummaryV2Dto(org.openlmis.stockmanagement.web.stockcardsummariesv2.StockCardSummaryV2Dto) StockCardSummaryV2DtoDataBuilder(org.openlmis.stockmanagement.testutils.StockCardSummaryV2DtoDataBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 CanFulfillForMeEntryDtoDataBuilder (org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder)9 LocalDate (java.time.LocalDate)5 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)5 ObjectReferenceDtoDataBuilder (org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder)5 StockCardSummaryV2DtoDataBuilder (org.openlmis.stockmanagement.testutils.StockCardSummaryV2DtoDataBuilder)3 StockCardSummaryV2Dto (org.openlmis.stockmanagement.web.stockcardsummariesv2.StockCardSummaryV2Dto)3 CanFulfillForMeEntryDto (org.openlmis.stockmanagement.web.stockcardsummariesv2.CanFulfillForMeEntryDto)1