use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenStockOnHandDoesNotMatchQuantityAndNoAdjustmentsProvided.
@Test
public void shouldNotRejectWhenStockOnHandDoesNotMatchQuantityAndNoAdjustmentsProvided() {
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(newArrayList(lineItem));
StockEventDto event = createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, null);
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenEventLineItemHasNoReason.
@Test
public void shouldNotRejectWhenEventLineItemHasNoReason() throws Exception {
// given
StockEventDto event = createStockEventDto();
setContext(event);
StockEventLineItemDto invalidItem = event.getLineItems().get(0);
invalidItem.setDestinationId(randomUUID());
invalidItem.setReasonId(null);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ReasonExistenceValidatorTest method shouldThrowErrorIfEventReasonIdNotFoundInDb.
@Test
public void shouldThrowErrorIfEventReasonIdNotFoundInDb() throws Exception {
// expect
expectedEx.expect(ValidationMessageException.class);
expectedEx.expectMessage(ERROR_EVENT_REASON_NOT_EXIST);
// given
StockEventDto stockEventDto = StockEventDtoDataBuilder.createStockEventDto();
UUID reasonId = UUID.randomUUID();
stockEventDto.getLineItems().get(0).setReasonId(reasonId);
setContext(stockEventDto);
when(reasonRepository.findOne(reasonId)).thenReturn(null);
// when
reasonExistenceValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ReceiveIssueReasonValidatorTest method eventThatHasSourceAndA_reasonOfCreditShouldPass.
@Test
public void eventThatHasSourceAndA_reasonOfCreditShouldPass() throws Exception {
// given
StockEventDto stockEventDto = createStockEventDto();
stockEventDto.getLineItems().get(0).setSourceId(UUID.randomUUID());
stockEventDto.getLineItems().get(0).setDestinationId(null);
UUID reasonId = UUID.randomUUID();
stockEventDto.getLineItems().get(0).setReasonId(reasonId);
setContext(stockEventDto);
when(reasonRepository.findByIdIn(singleton(reasonId))).thenReturn(singletonList(creditAdhocReason));
creditAdhocReason.setId(reasonId);
// when
receiveIssueReasonValidator.validate(stockEventDto);
// then: no error exception
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class ReceiveIssueReasonValidatorTest method eventThatHasDestinationAndA_reasonOfCreditShouldNotPass.
@Test
public void eventThatHasDestinationAndA_reasonOfCreditShouldNotPass() throws Exception {
StockEventDto stockEventDto = createStockEventDto();
stockEventDto.getLineItems().get(0).setDestinationId(UUID.randomUUID());
stockEventDto.getLineItems().get(0).setSourceId(null);
stockEventDto.getLineItems().get(0).setReasonId(UUID.randomUUID());
testErrorCase(ERROR_EVENT_ISSUE_REASON_TYPE_INVALID, stockEventDto, creditAdhocReason);
}
Aggregations