use of org.openlmis.stockmanagement.dto.referencedata.FacilityDto in project openlmis-stockmanagement by OpenLMIS.
the class SourceDestinationBaseServiceTest method shouldReturnSourceDtoWhenFoundExistingOne.
@Test
public void shouldReturnSourceDtoWhenFoundExistingOne() throws Exception {
UUID programId = randomUUID();
UUID facilityTypeId = randomUUID();
UUID sourceId = randomUUID();
ValidSourceAssignment assignment = createSource(programId, facilityTypeId, sourceId);
Node node = createNode(sourceId, true);
when(nodeRepository.findByReferenceId(sourceId)).thenReturn(node);
when(facilityReferenceDataService.findOne(sourceId)).thenReturn(new FacilityDto());
when(sourceRepository.findByProgramIdAndFacilityTypeIdAndNodeId(programId, facilityTypeId, node.getId())).thenReturn(createSourceAssignment(programId, facilityTypeId, node));
// when
ValidSourceDestinationDto foundDto = validSourceService.findByProgramFacilitySource(assignment);
assertThat(foundDto.getProgramId(), is(programId));
assertThat(foundDto.getFacilityTypeId(), is(facilityTypeId));
assertThat(foundDto.getNode().getReferenceId(), is(sourceId));
verify(programFacilityTypeExistenceService, times(1)).checkProgramAndFacilityTypeExist(programId, facilityTypeId);
}
use of org.openlmis.stockmanagement.dto.referencedata.FacilityDto 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