use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class AdjustmentReasonValidatorIntegrationTest method shouldNotThrowErrorForEventWithNoSourceDestinationAndReasonNotInDb.
@Test
public void shouldNotThrowErrorForEventWithNoSourceDestinationAndReasonNotInDb() throws Exception {
// given
StockEventDto stockEventDto = StockEventDtoDataBuilder.createNoSourceDestinationStockEventDto();
stockEventDto.getLineItems().get(0).setReasonId(UUID.randomUUID());
setContext(stockEventDto);
// when
adjustmentReasonValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class StockCardService method findOrCreateCard.
private StockCard findOrCreateCard(StockEventDto eventDto, StockEventLineItemDto eventLineItem, UUID savedEventId, List<StockCard> cardsToUpdate) {
OrderableLotIdentity identity = identityOf(eventLineItem);
StockCard card = eventDto.getContext().findCard(identity);
if (null == card) {
card = cardsToUpdate.stream().filter(elem -> identityOf(elem).equals(identity)).findFirst().orElse(null);
}
if (null == card) {
card = createStockCardFrom(eventDto, eventLineItem, savedEventId);
}
if (cardsToUpdate.stream().noneMatch(elem -> identityOf(elem).equals(identity))) {
cardsToUpdate.add(card);
}
return card;
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldRejectWhenAnyAdjustmentHasNegativeQuantity.
@Test
public void shouldRejectWhenAnyAdjustmentHasNegativeQuantity() throws Exception {
// expect
expectedException.expect(ValidationMessageException.class);
expectedException.expectMessage(ERROR_EVENT_ADJUSTMENT_QUANITITY_INVALID);
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(singletonList(lineItem));
StockEventDto event = spy(createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, singletonList(createCreditAdjustment(-2))));
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenEventHasNoDestinationOrDebitReason.
@Test
public void shouldNotRejectWhenEventHasNoDestinationOrDebitReason() throws Exception {
// given
StockEventDto stockEventDto = new StockEventDto();
// when
quantityValidator.validate(stockEventDto);
}
use of org.openlmis.stockmanagement.dto.StockEventDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenStockOnHandWithAdjustmentsDoesNotMatchQuantity.
@Test
public void shouldNotRejectWhenStockOnHandWithAdjustmentsDoesNotMatchQuantity() {
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(newArrayList(lineItem));
StockEventDto event = spy(createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, singletonList(createCreditAdjustment(5))));
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
Aggregations