@Test public void shouldNotGiveErrorIfDependentsAreNotMissing() throws Exception { Map<String, OpenLmisMessage> errors = new ProgramRnrTemplate(1L, asList( rnrColumn(QUANTITY_REQUESTED, false, null, "Requested Quantity"), rnrColumn(REASON_FOR_REQUESTED_QUANTITY, false, null, "Requested Quantity Reason"), rnrColumn(STOCK_OUT_DAYS, false, CALCULATED, "stockOutDays"), rnrColumn(NORMALIZED_CONSUMPTION, false, USER_INPUT, "normalizedConsumption"), rnrColumn(STOCK_IN_HAND, true, USER_INPUT, "stock in hand"), rnrColumn(QUANTITY_DISPENSED, true, USER_INPUT, "quantity dispensed"), rnrColumn(QUANTITY_RECEIVED, true, USER_INPUT, "quantity received"), rnrColumn(BEGINNING_BALANCE, true, USER_INPUT, "beginning balance"), rnrColumn(LOSSES_AND_ADJUSTMENTS, true, USER_INPUT, "losses and adjustment") )).validateToSave(); assertThat(errors.size(), is(0)); }
public Map<String, OpenLmisMessage> validateToSave() { validateColumnsTobeCheckedIfUserInput(); validateCalculatedColumnHasDependentChecked(STOCK_IN_HAND, QUANTITY_DISPENSED); validateCalculatedColumnHasDependentChecked(QUANTITY_DISPENSED, STOCK_IN_HAND); validateQuantityDispensedAndStockInHandCannotBeCalculatedAtSameTime(); validateQuantityRequested(); return errorMap; }
ProgramRnrTemplate extends Template { public Map<String, OpenLmisMessage> validateToSave() { validateColumnsTobeCheckedIfUserInput(); validateCalculatedColumnHasDependentChecked(STOCK_IN_HAND, QUANTITY_DISPENSED); validateCalculatedColumnHasDependentChecked(QUANTITY_DISPENSED, STOCK_IN_HAND); validateQuantityDispensedAndStockInHandCannotBeCalculatedAtSameTime(); validateQuantityRequested(); return errorMap; } }
ProgramRnrTemplate extends Template { public Map<String, OpenLmisMessage> validateToSave() { validateColumnsTobeCheckedIfUserInput(); validateCalculatedColumnHasDependentChecked(STOCK_IN_HAND, QUANTITY_DISPENSED); validateCalculatedColumnHasDependentChecked(QUANTITY_DISPENSED, STOCK_IN_HAND); validateQuantityDispensedAndStockInHandCannotBeCalculatedAtSameTime(); validateQuantityRequested(); return errorMap; } ProgramRnrTemplate(Long programId, List<? extends Column> rnrColumns);  ProgramRnrTemplate(List<? extends Column> programRnrColumns); }
ProgramRnrTemplate extends Template { public Map<String, OpenLmisMessage> validateToSave() { validateColumnsTobeCheckedIfUserInput(); validateCalculatedColumnHasDependentChecked(STOCK_IN_HAND, QUANTITY_DISPENSED); validateCalculatedColumnHasDependentChecked(QUANTITY_DISPENSED, STOCK_IN_HAND); validateQuantityDispensedAndStockInHandCannotBeCalculatedAtSameTime(); validateQuantityRequested(); return errorMap; } ProgramRnrTemplate(Long programId, List<? extends Column> rnrColumns);  ProgramRnrTemplate(List<? extends Column> programRnrColumns); boolean columnsVisible(String... rnrColumnNames); boolean columnsCalculated(String... rnrColumnNames); boolean columnsUserInput(String... rnrColumnNames); String getRnrColumnLabelFor(String columnName); Map<String, OpenLmisMessage> validateToSave(); List<? extends Column> getPrintableColumns(Boolean fullSupply); }
ProgramRnrTemplate extends Template { public Map<String, OpenLmisMessage> validateToSave() { validateColumnsTobeCheckedIfUserInput(); validateCalculatedColumnHasDependentChecked(STOCK_IN_HAND, QUANTITY_DISPENSED); validateCalculatedColumnHasDependentChecked(QUANTITY_DISPENSED, STOCK_IN_HAND); validateQuantityDispensedAndStockInHandCannotBeCalculatedAtSameTime(); validateQuantityRequested(); return errorMap; } ProgramRnrTemplate(Long programId, List<? extends Column> rnrColumns);  ProgramRnrTemplate(List<? extends Column> programRnrColumns); boolean columnsVisible(String... rnrColumnNames); boolean columnsCalculated(String... rnrColumnNames); boolean columnsUserInput(String... rnrColumnNames); String getRnrColumnLabelFor(String columnName); Map<String, OpenLmisMessage> validateToSave(); List<? extends Column> getPrintableColumns(Boolean fullSupply); static final String STOCK_IN_HAND; static final String REMARKS; static final String QUANTITY_DISPENSED; static final String BEGINNING_BALANCE; static final String QUANTITY_RECEIVED; static final String QUANTITY_APPROVED; static final String LOSSES_AND_ADJUSTMENTS; static final String STOCK_OUT_DAYS; static final String NORMALIZED_CONSUMPTION; static final String QUANTITY_REQUESTED; static final String REASON_FOR_REQUESTED_QUANTITY; static final String NEW_PATIENT_COUNT; static final String COST; static final String PRICE; static final String TOTAL; static final String PRODUCT; static final String DISPENSING_UNIT; static final String PRODUCT_CODE; static final String PACKS_TO_SHIP; static final String SKIPPED; static final String CALCULATED_ORDER_QUANTITY; static final String USER_NEEDS_TO_ENTER_DEPENDENT_FIELD; static final String INTERDEPENDENT_FIELDS_CAN_NOT_BE_CALCULATED; static final String COLUMN_SHOULD_BE_VISIBLE_IF_USER_INPUT; static final String USER_NEED_TO_ENTER_REQUESTED_QUANTITY_REASON; }