@Test public void shouldReturnFalseWhenViewModelIsInvalid() throws Exception { viewModel.setLotSoh("100"); viewModel.setQuantity("300"); viewModel.setExpiryDate("2014-03-18"); viewModel.setLotNumber("100"); viewModel.validateLotWithPositiveQuantity(); assertTrue(viewModel.isValid()); viewModel.setLotNumber("dk-23"); viewModel.validateLotWithPositiveQuantity(); assertTrue(viewModel.isValid()); viewModel.setQuantity("333"); viewModel.validateLotWithPositiveQuantity(); assertTrue(viewModel.isValid()); viewModel.setExpiryDate("2014-03-18"); viewModel.validateLotWithPositiveQuantity(); assertTrue(viewModel.isValid()); }
public boolean validateLotWithPositiveQuantity() { valid = StringUtils.isNumeric(quantity) && !StringUtils.isBlank(lotNumber) && !StringUtils.isBlank(expiryDate) && !StringUtils.isBlank(quantity) && Long.parseLong(quantity) > 0; return valid || (getMovementType() == MovementReasonManager.MovementType.ISSUE && !isExpiredLot()); }
LotMovementViewModel implements Serializable { public boolean validateLotWithPositiveQuantity() { valid = StringUtils.isNumeric(quantity) && !StringUtils.isBlank(lotNumber) && !StringUtils.isBlank(expiryDate) && !StringUtils.isBlank(quantity) && Long.parseLong(quantity) > 0; return valid || (getMovementType() == MovementReasonManager.MovementType.ISSUE && !isExpiredLot()); } }
LotMovementViewModel implements Serializable { public boolean validateLotWithPositiveQuantity() { valid = StringUtils.isNumeric(quantity) && !StringUtils.isBlank(lotNumber) && !StringUtils.isBlank(expiryDate) && !StringUtils.isBlank(quantity) && Long.parseLong(quantity) > 0; return valid || (getMovementType() == MovementReasonManager.MovementType.ISSUE && !isExpiredLot()); } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); }
LotMovementViewModel implements Serializable { public boolean validateLotWithPositiveQuantity() { valid = StringUtils.isNumeric(quantity) && !StringUtils.isBlank(lotNumber) && !StringUtils.isBlank(expiryDate) && !StringUtils.isBlank(quantity) && Long.parseLong(quantity) > 0; return valid || (getMovementType() == MovementReasonManager.MovementType.ISSUE && !isExpiredLot()); } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); boolean validateQuantityNotGreaterThanSOH(); LotMovementItem convertViewToModel(Product product); boolean quantityGreaterThanZero(); LotMovementItem convertViewToModelAndResetSOH(Product product); boolean validateLotWithPositiveQuantity(); boolean validateLotWithNoEmptyFields(); boolean isExpiredLot(); boolean isNewAdded(); static String generateLotNumberForProductWithoutLot(String productCode, String expiryDate); long getAdjustmentQuantity(); @Override String toString(); }
LotMovementViewModel implements Serializable { public boolean validateLotWithPositiveQuantity() { valid = StringUtils.isNumeric(quantity) && !StringUtils.isBlank(lotNumber) && !StringUtils.isBlank(expiryDate) && !StringUtils.isBlank(quantity) && Long.parseLong(quantity) > 0; return valid || (getMovementType() == MovementReasonManager.MovementType.ISSUE && !isExpiredLot()); } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); boolean validateQuantityNotGreaterThanSOH(); LotMovementItem convertViewToModel(Product product); boolean quantityGreaterThanZero(); LotMovementItem convertViewToModelAndResetSOH(Product product); boolean validateLotWithPositiveQuantity(); boolean validateLotWithNoEmptyFields(); boolean isExpiredLot(); boolean isNewAdded(); static String generateLotNumberForProductWithoutLot(String productCode, String expiryDate); long getAdjustmentQuantity(); @Override String toString();  }