public void checkInvalidQualityFormItemPositionByItems()
throws ValidationException {
QualityForm qualityForm = createValidQualityForm();
qualityForm.setQualityFormType(QualityFormType.BY_ITEMS);
QualityFormItem qualityFormItem1 = createValidQualityFormItem();
qualityForm.addQualityFormItemOnTop(qualityFormItem1);
QualityFormItem qualityFormItem2 = createValidQualityFormItem();
qualityForm.addQualityFormItemOnTop(qualityFormItem2);
try {
qualityFormDAO.save(qualityForm);
} catch (ValidationException e) {
fail("It shouldn't throw an exception");
}
// Incorrect Position
qualityFormItem1.setPosition(2);
qualityFormItem2.setPosition(1);
try {
qualityFormDAO.save(qualityForm);
fail("It shouldn't throw an exception");
} catch (ValidationException e) {
// It should throw an exception
}
// Incorrect Percentage
qualityFormItem1.setPosition(0);
qualityFormItem2.setPosition(1);
qualityFormItem1.setPercentage(new BigDecimal(100));
qualityFormItem2.setPercentage(new BigDecimal(1));
try {
qualityFormDAO.save(qualityForm);
fail("It should throw an exception");
} catch (ValidationException e) {
// It should throw an exception
}
// Incorrect Percentage
qualityFormItem1.setPosition(0);
qualityFormItem2.setPosition(1);
qualityFormItem1.setPercentage(new BigDecimal(10));
qualityFormItem2.setPercentage(new BigDecimal(1));
try {
qualityFormDAO.save(qualityForm);
fail("It should throw an exception");
} catch (ValidationException e) {