use of org.openlmis.stockmanagement.domain.event.StockEventLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockEventDto method toEvent.
/**
* Convert dto to jpa model.
*
* @return the converted jpa model object.
*/
public StockEvent toEvent() {
List<StockEventLineItem> domainLines = this.lineItems.stream().map(StockEventLineItemDto::toEventLineItem).collect(Collectors.toList());
StockEvent event = new StockEvent(facilityId, programId, context.getCurrentUserId(), // processed date generated by server side
now(), signature, documentNumber, domainLines);
domainLines.forEach(lineItem -> {
lineItem.setStockAdjustments(lineItem.stockAdjustments());
lineItem.setStockEvent(event);
});
return event;
}
use of org.openlmis.stockmanagement.domain.event.StockEventLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockEventLineItemDtoTest method shouldConvertFromDtoToJpaModel.
@Test
public void shouldConvertFromDtoToJpaModel() throws Exception {
// given
StockEventLineItemDto lineItemDto = StockEventDtoDataBuilder.createStockEventLineItem();
// when
StockEventLineItem lineItem = lineItemDto.toEventLineItem();
// then
assertThat(lineItem.getReasonFreeText(), is(lineItemDto.getReasonFreeText()));
assertThat(lineItem.getReasonId(), is(lineItemDto.getReasonId()));
assertThat(lineItem.getQuantity(), is(lineItemDto.getQuantity()));
assertThat(lineItem.getOrderableId(), is(lineItemDto.getOrderableId()));
assertThat(lineItem.getOccurredDate(), is(lineItemDto.getOccurredDate()));
assertThat(lineItem.getSourceId(), is(lineItemDto.getSourceId()));
assertThat(lineItem.getDestinationId(), is(lineItemDto.getDestinationId()));
assertThat(lineItem.getSourceFreeText(), is(lineItemDto.getSourceFreeText()));
assertThat(lineItem.getDestinationFreeText(), is(lineItemDto.getDestinationFreeText()));
}
Aggregations