use of org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity in project openlmis-stockmanagement by OpenLMIS.
the class ActiveStockCardsValidator method checkAllStockCardsCovered.
private void checkAllStockCardsCovered(StockEventDto stockEventDto) {
List<OrderableLotIdentity> coveredIdentities = stockEventDto.getLineItems().stream().map(OrderableLotIdentity::identityOf).collect(toList());
boolean anyMissing = stockCardRepository.getIdentitiesBy(stockEventDto.getProgramId(), stockEventDto.getFacilityId()).stream().anyMatch(identity -> !coveredIdentities.contains(identity));
if (anyMissing) {
throw new ValidationMessageException(new Message(ERROR_PHYSICAL_INVENTORY_NOT_INCLUDE_ACTIVE_STOCK_CARD));
}
}
use of org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity in project openlmis-stockmanagement by OpenLMIS.
the class ActiveStockCardsValidatorTest method shouldThrowExceptionIfExistingCardLotNotCovered.
@Test
public void shouldThrowExceptionIfExistingCardLotNotCovered() throws Exception {
expectedEx.expectMessage(ERROR_PHYSICAL_INVENTORY_NOT_INCLUDE_ACTIVE_STOCK_CARD);
// given
StockEventDto stockEventDto = createNoSourceDestinationStockEventDto();
stockEventDto.getLineItems().get(0).setReasonId(null);
stockEventDto.getLineItems().get(0).setLotId(randomUUID());
when(stockCardRepository.getIdentitiesBy(stockEventDto.getProgramId(), stockEventDto.getFacilityId())).thenReturn(singletonList(new OrderableLotIdentity(randomUUID(), randomUUID())));
// when
activeStockCardsValidator.validate(stockEventDto);
}
Aggregations