Search in sources :

Example 16 with StockCardDto

use of org.openlmis.stockmanagement.dto.StockCardDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummariesServiceTest method shouldReturnPageOfStockCards.

@Test
public void shouldReturnPageOfStockCards() throws Exception {
    // given
    UUID programId = randomUUID();
    UUID facilityId = randomUUID();
    PageRequest pageRequest = new PageRequest(0, 1);
    UUID orderableId = randomUUID();
    OrderableDto orderable = createOrderableDto(orderableId, "");
    StockCard card = createStockCard(orderableId, randomUUID());
    when(cardRepository.findByProgramIdAndFacilityId(programId, facilityId, pageRequest)).thenReturn(new PageImpl<>(singletonList(card), pageRequest, 10));
    when(orderableReferenceDataService.findAll()).thenReturn(singletonList(orderable));
    when(lotReferenceDataService.getAllLotsOf(any(UUID.class))).thenReturn(emptyList());
    // when
    Page<StockCardDto> stockCards = stockCardSummariesService.findStockCards(programId, facilityId, pageRequest);
    // then
    assertThat(stockCards.getContent().size(), is(1));
    assertThat(stockCards.getTotalElements(), is(10L));
    assertThat(stockCards.getContent().get(0).getExtraData().get("vvmStatus"), is("STAGE_2"));
}
Also used : OrderableDto(org.openlmis.stockmanagement.dto.referencedata.OrderableDto) PageRequest(org.springframework.data.domain.PageRequest) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) StockCardDto(org.openlmis.stockmanagement.dto.StockCardDto) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) Test(org.junit.Test)

Aggregations

StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)16 UUID (java.util.UUID)10 Test (org.junit.Test)8 UUID.randomUUID (java.util.UUID.randomUUID)7 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)5 OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)5 BaseIntegrationTest (org.openlmis.stockmanagement.BaseIntegrationTest)4 StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)4 List (java.util.List)3 UUID.fromString (java.util.UUID.fromString)3 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)3 StockCardLineItemDto (org.openlmis.stockmanagement.dto.StockCardLineItemDto)3 FacilityDto (org.openlmis.stockmanagement.dto.referencedata.FacilityDto)3 LotDto (org.openlmis.stockmanagement.dto.referencedata.LotDto)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Collections.singletonList (java.util.Collections.singletonList)2 HashMap (java.util.HashMap)2 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)2 ProgramDto (org.openlmis.stockmanagement.dto.referencedata.ProgramDto)2 StockEventDtoDataBuilder.createStockEventDto (org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto)2