@Test public void shouldThrowExceptionIfQuantityReturnedIsNegative() { OrderPODLineItem orderPodLineItem = new OrderPODLineItem(1L, "P100", 10); orderPodLineItem.setQuantityReturned(-100); expectedException.expect(DataException.class); expectedException.expectMessage("error.invalid.returned.quantity"); orderPodLineItem.validate(); }
public void validate() { if (isEmpty(productCode) || quantityReceived == null) { throw new DataException("error.mandatory.fields.missing"); } if (quantityReceived < 0) { throw new DataException(new OpenLmisMessage("error.invalid.received.quantity")); } if (quantityReturned != null && quantityReturned < 0) { throw new DataException(new OpenLmisMessage("error.invalid.returned.quantity")); } }
OrderPODLineItem extends BaseModel { public void validate() { if (isEmpty(productCode) || quantityReceived == null) { throw new DataException("error.mandatory.fields.missing"); } if (quantityReceived < 0) { throw new DataException(new OpenLmisMessage("error.invalid.received.quantity")); } if (quantityReturned != null && quantityReturned < 0) { throw new DataException(new OpenLmisMessage("error.invalid.returned.quantity")); } } }
OrderPODLineItem extends BaseModel { public void validate() { if (isEmpty(productCode) || quantityReceived == null) { throw new DataException("error.mandatory.fields.missing"); } if (quantityReceived < 0) { throw new DataException(new OpenLmisMessage("error.invalid.received.quantity")); } if (quantityReturned != null && quantityReturned < 0) { throw new DataException(new OpenLmisMessage("error.invalid.returned.quantity")); } } OrderPODLineItem(Long podId, String productCode, Integer quantityReceived);  OrderPODLineItem(LineItem lineItem, Long createdBy); }
OrderPODLineItem extends BaseModel { public void validate() { if (isEmpty(productCode) || quantityReceived == null) { throw new DataException("error.mandatory.fields.missing"); } if (quantityReceived < 0) { throw new DataException(new OpenLmisMessage("error.invalid.received.quantity")); } if (quantityReturned != null && quantityReturned < 0) { throw new DataException(new OpenLmisMessage("error.invalid.returned.quantity")); } } OrderPODLineItem(Long podId, String productCode, Integer quantityReceived);  OrderPODLineItem(LineItem lineItem, Long createdBy); void validate(); void copy(OrderPODLineItem lineItem); }
OrderPODLineItem extends BaseModel { public void validate() { if (isEmpty(productCode) || quantityReceived == null) { throw new DataException("error.mandatory.fields.missing"); } if (quantityReceived < 0) { throw new DataException(new OpenLmisMessage("error.invalid.received.quantity")); } if (quantityReturned != null && quantityReturned < 0) { throw new DataException(new OpenLmisMessage("error.invalid.returned.quantity")); } } OrderPODLineItem(Long podId, String productCode, Integer quantityReceived);  OrderPODLineItem(LineItem lineItem, Long createdBy); void validate(); void copy(OrderPODLineItem lineItem);  }