ExporterUtils { static void correctScaleFactor(Map<String, VariableDescriptor> variableDescriptors, String variableName, double scaleCorrection) { final VariableDescriptor variableDescriptor = variableDescriptors.get(variableName); if (variableDescriptor != null) { final double originalScaleFactor = variableDescriptor.getScaleFactor(); variableDescriptor.setScaleFactor(originalScaleFactor * scaleCorrection); } }    }
@Test public void testCorrectScaleFactor_variableNotPresent() { Map<String, VariableDescriptor> variableDescriptors = new HashMap<>(); variableDescriptors.put("_its_here", new VariableDescriptor()); ExporterUtils.correctScaleFactor(variableDescriptors, "the_missing", 2.8); }
@Test public void testCorrectScaleFactor() { Map<String, VariableDescriptor> variableDescriptors = new HashMap<>(); variableDescriptors.put("the_one", new VariableDescriptor()); final VariableDescriptor corrected = new VariableDescriptor(); corrected.setScaleFactor(2.8); variableDescriptors.put("corrected", corrected); ExporterUtils.correctScaleFactor(variableDescriptors, "corrected", 2); assertEquals(5.6, corrected.getScaleFactor(), 1e-8); }