use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto 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"));
}
use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto 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));
}
use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto in project openlmis-stockmanagement by OpenLMIS.
the class VvmValidatorTest method shouldNotRejectIfOrderableEnabledVvmAndLineItemHasVvmStatus.
@Test
public void shouldNotRejectIfOrderableEnabledVvmAndLineItemHasVvmStatus() {
OrderableDto orderable = generateOrderable();
orderable.setExtraData(Collections.singletonMap("useVVM", "true"));
VvmApplicable lineItem = generateVvmApplicable(orderable);
lineItem.setExtraData(Collections.singletonMap("vvmStatus", "status"));
validator.validate(Collections.singletonList(lineItem), ERROR_MESSAGE, false);
}
use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto in project openlmis-stockmanagement by OpenLMIS.
the class VvmValidatorTest method shouldRejectIfOrderableNotConfiguredVvmAndLineItemHasVvmStatus.
@Test(expected = ValidationMessageException.class)
public void shouldRejectIfOrderableNotConfiguredVvmAndLineItemHasVvmStatus() {
OrderableDto orderable = generateOrderable();
VvmApplicable lineItem = generateVvmApplicable(orderable);
lineItem.setExtraData(Collections.singletonMap("vvmStatus", "status"));
validator.validate(Collections.singletonList(lineItem), ERROR_MESSAGE, false);
}
use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto in project openlmis-stockmanagement by OpenLMIS.
the class ApprovedOrderableValidatorTest method stockEventWithOrderableIdNotInApprovedListShouldNotPassValidation.
@Test(expected = ValidationMessageException.class)
public void stockEventWithOrderableIdNotInApprovedListShouldNotPassValidation() throws Exception {
// given:
StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
OrderableDto orderableDto = new OrderableDto();
orderableDto.setId(UUID.randomUUID());
StockEventProcessContext context = new StockEventProcessContext();
context.setAllApprovedProducts(new LazyList<>(() -> singletonList(orderableDto)));
stockEventDto.setContext(context);
// when:
approvedOrderableValidator.validate(stockEventDto);
}
Aggregations