Search in sources :

Example 6 with LotDto

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

the class StockEventProcessContextBuilderTest method testBuildContext.

private void testBuildContext(StockEventDto stockEventDto) {
    // given
    UUID lotId = UUID.randomUUID();
    LotDto lot = new LotDto();
    lot.setId(lotId);
    StockEventDtoDataBuilder.createStockEventDto();
    stockEventDto.getLineItems().get(0).setLotId(lotId);
    ProgramDto programDto = new ProgramDto();
    FacilityDto facilityDto = new FacilityDto();
    ArrayList<OrderableDto> approvedProductDtos = new ArrayList<>();
    when(programService.findOne(stockEventDto.getProgramId())).thenReturn(programDto);
    when(facilityService.findOne(stockEventDto.getFacilityId())).thenReturn(facilityDto);
    when(orderableReferenceDataService.findAll()).thenReturn(approvedProductDtos);
    when(lotReferenceDataService.findOne(lotId)).thenReturn(lot);
    // when
    StockEventProcessContext context = contextBuilder.buildContext(stockEventDto);
    // then
    assertThat(context.getCurrentUserId(), is(userDto.getId()));
    assertThat(context.getProgram(), is(programDto));
    assertThat(context.getFacility(), is(facilityDto));
    assertThat(context.getAllApprovedProducts(), is(approvedProductDtos));
    assertThat(context.findLot(lotId), is(lot));
}
Also used : OrderableDto(org.openlmis.stockmanagement.dto.referencedata.OrderableDto) ProgramDto(org.openlmis.stockmanagement.dto.referencedata.ProgramDto) ArrayList(java.util.ArrayList) FacilityDto(org.openlmis.stockmanagement.dto.referencedata.FacilityDto) UUID(java.util.UUID) LotDto(org.openlmis.stockmanagement.dto.referencedata.LotDto) StockEventProcessContext(org.openlmis.stockmanagement.util.StockEventProcessContext)

Aggregations

LotDto (org.openlmis.stockmanagement.dto.referencedata.LotDto)6 UUID (java.util.UUID)5 OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)5 UUID.randomUUID (java.util.UUID.randomUUID)3 Test (org.junit.Test)3 FacilityDto (org.openlmis.stockmanagement.dto.referencedata.FacilityDto)3 ProgramDto (org.openlmis.stockmanagement.dto.referencedata.ProgramDto)3 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)2 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)2 StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)2 StockEventProcessContext (org.openlmis.stockmanagement.util.StockEventProcessContext)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID.fromString (java.util.UUID.fromString)1 BaseIntegrationTest (org.openlmis.stockmanagement.BaseIntegrationTest)1 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)1 StockCardLineItemReason (org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason)1 Node (org.openlmis.stockmanagement.domain.sourcedestination.Node)1 ValidDestinationAssignment (org.openlmis.stockmanagement.domain.sourcedestination.ValidDestinationAssignment)1 ValidSourceAssignment (org.openlmis.stockmanagement.domain.sourcedestination.ValidSourceAssignment)1