@Test public void shouldUpdateValuesForViewModel() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { ImplementationReportViewModel implementationReportViewModel = new ImplementationReportViewModel(); ImplementationUtils.mapForProduct(implementation, productName, implementationReportViewModel); assertThat(implementationReportViewModel.getCurrentTreatment6x1(), is((long) amount)); assertThat(implementationReportViewModel.getExistingStock6x1(), is((long) stock)); }
public static void mapForProduct(Implementation implementation, String productName, ImplementationReportViewModel report) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Treatment treatment = findTreatmentForProduct(implementation.getTreatments(), productMap().get(productName)); if (treatment == null) { return; } Method setCurrentTreatment = report.getClass().getMethod(CURRENT_TREATMENT_SETTER + productName, long.class); Method setExistingStock = report.getClass().getMethod(EXISTING_STOCK_SETTER + productName, long.class); setCurrentTreatment.invoke(report, treatment.getAmount()); setExistingStock.invoke(report, treatment.getStock()); }
ImplementationUtils { public static void mapForProduct(Implementation implementation, String productName, ImplementationReportViewModel report) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Treatment treatment = findTreatmentForProduct(implementation.getTreatments(), productMap().get(productName)); if (treatment == null) { return; } Method setCurrentTreatment = report.getClass().getMethod(CURRENT_TREATMENT_SETTER + productName, long.class); Method setExistingStock = report.getClass().getMethod(EXISTING_STOCK_SETTER + productName, long.class); setCurrentTreatment.invoke(report, treatment.getAmount()); setExistingStock.invoke(report, treatment.getStock()); } }
ImplementationUtils { public static void mapForProduct(Implementation implementation, String productName, ImplementationReportViewModel report) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Treatment treatment = findTreatmentForProduct(implementation.getTreatments(), productMap().get(productName)); if (treatment == null) { return; } Method setCurrentTreatment = report.getClass().getMethod(CURRENT_TREATMENT_SETTER + productName, long.class); Method setExistingStock = report.getClass().getMethod(EXISTING_STOCK_SETTER + productName, long.class); setCurrentTreatment.invoke(report, treatment.getAmount()); setExistingStock.invoke(report, treatment.getStock()); } private  ImplementationUtils(); }
ImplementationUtils { public static void mapForProduct(Implementation implementation, String productName, ImplementationReportViewModel report) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Treatment treatment = findTreatmentForProduct(implementation.getTreatments(), productMap().get(productName)); if (treatment == null) { return; } Method setCurrentTreatment = report.getClass().getMethod(CURRENT_TREATMENT_SETTER + productName, long.class); Method setExistingStock = report.getClass().getMethod(EXISTING_STOCK_SETTER + productName, long.class); setCurrentTreatment.invoke(report, treatment.getAmount()); setExistingStock.invoke(report, treatment.getStock()); } private  ImplementationUtils(); static void mapForProduct(Implementation implementation, String productName,
                                     ImplementationReportViewModel report); static Treatment findTreatmentForProduct(Collection<Treatment> treatments, String productCode); static Implementation findImplementationForExecutor(Collection<Implementation> implementations, String executor); }
ImplementationUtils { public static void mapForProduct(Implementation implementation, String productName, ImplementationReportViewModel report) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Treatment treatment = findTreatmentForProduct(implementation.getTreatments(), productMap().get(productName)); if (treatment == null) { return; } Method setCurrentTreatment = report.getClass().getMethod(CURRENT_TREATMENT_SETTER + productName, long.class); Method setExistingStock = report.getClass().getMethod(EXISTING_STOCK_SETTER + productName, long.class); setCurrentTreatment.invoke(report, treatment.getAmount()); setExistingStock.invoke(report, treatment.getStock()); } private  ImplementationUtils(); static void mapForProduct(Implementation implementation, String productName,
                                     ImplementationReportViewModel report); static Treatment findTreatmentForProduct(Collection<Treatment> treatments, String productCode); static Implementation findImplementationForExecutor(Collection<Implementation> implementations, String executor); static final String CURRENT_TREATMENT_SETTER; static final String EXISTING_STOCK_SETTER; }