use of org.openlmis.stockmanagement.dto.referencedata.ProgramDto in project openlmis-stockmanagement by OpenLMIS.
the class StockCardBaseService method createDtos.
protected List<StockCardDto> createDtos(List<StockCard> stockCards) {
if (stockCards.isEmpty()) {
return emptyList();
}
StockCard firstCard = stockCards.get(0);
LOGGER.debug("Calling ref data to retrieve facility info for card");
FacilityDto facility = facilityRefDataService.findOne(firstCard.getFacilityId());
LOGGER.debug("Calling ref data to retrieve program info for card");
ProgramDto program = programRefDataService.findOne(firstCard.getProgramId());
return stockCards.stream().map(card -> cardToDto(facility, program, card)).collect(toList());
}
use of org.openlmis.stockmanagement.dto.referencedata.ProgramDto 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));
}
Aggregations