@Test public void loadChartWithBrokenValues() throws ComponentLookupException { List<MeasurementsChartConfiguration> settings = this.mocker.getComponentUnderTest().loadConfigurationsForMeasurementType("tested"); Assert.assertEquals("tested", settings.get(4).getMeasurementType()); Mockito.verify(this.mocker.getMockedLogger()).warn("Invalid chart settings for [{}]: invalid integer [{}]", "charts.tested.configurations.broken.lowerAgeLimit", "two"); Assert.assertEquals(0, settings.get(4).getLowerAgeLimit()); Mockito.verify(this.mocker.getMockedLogger()).warn("Invalid chart settings for [{}]: invalid integer [{}]", "charts.tested.configurations.broken.upperAgeLimit", "36.5"); Assert.assertEquals(240, settings.get(4).getUpperAgeLimit()); Mockito.verify(this.mocker.getMockedLogger()).warn( "Invalid chart settings for [{}]: value should be a positive integer, was [{}]", "charts.tested.configurations.broken.ageTickStep", "-1"); Assert.assertEquals(6, settings.get(4).getAgeTickStep()); Mockito.verify(this.mocker.getMockedLogger()).warn("Invalid chart settings for [{}]: invalid integer [{}]", "charts.tested.configurations.broken.ageLabelStep", ""); Assert.assertEquals(12, settings.get(4).getAgeLabelStep()); Mockito.verify(this.mocker.getMockedLogger()).warn( "Invalid chart settings for [{}]: value should be finite, was [{}]", "charts.tested.configurations.broken.lowerValueLimit", "NaN"); Assert.assertEquals(0.0, settings.get(4).getLowerValueLimit(), 1.0E-2); Assert.assertEquals(24.0, settings.get(4).getUpperValueLimit(), 1.0E-2); Assert.assertEquals(0.2, settings.get(4).getValueTickStep(), 1.0E-2); Mockito.verify(this.mocker.getMockedLogger()).warn( "Invalid chart settings for [{}]: value should be finite, was [{}]", "charts.tested.configurations.broken.valueLabelStep", "Infinity"); Assert.assertEquals(1.0, settings.get(4).getValueLabelStep(), 1.0E-2); Assert.assertEquals("\uFFFEWeight for age,b\u0123 to 2\u00000 years", settings.get(4).getChartTitle()); Assert.assertEquals("Age (years)", settings.get(4).getTopLabel()); Assert.assertEquals("Age (years)", settings.get(4).getBottomLabel()); Assert.assertEquals("Weight (kg)", settings.get(4).getLeftLabel()); Assert.assertEquals("Weight (kg)", settings.get(4).getRightLabel()); }
@Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); } String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; }
DefaultMeasurementsChartConfigurationsFactory implements MeasurementsChartConfigurationsFactory { @Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); } String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; } }
DefaultMeasurementsChartConfigurationsFactory implements MeasurementsChartConfigurationsFactory { @Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); } String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; }  }
DefaultMeasurementsChartConfigurationsFactory implements MeasurementsChartConfigurationsFactory { @Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); } String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; }  @Override List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType); }
DefaultMeasurementsChartConfigurationsFactory implements MeasurementsChartConfigurationsFactory { @Override public List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType) { ResourceBundle configuration = ResourceBundle.getBundle("measurementsChartsConfigurations"); String key = "charts." + measurementType + ".configurations"; if (!configuration.containsKey(key)) { return Collections.emptyList(); } String[] charts = configuration.getString(key).split(","); List<MeasurementsChartConfiguration> result = new ArrayList<>(charts.length); for (String chart : charts) { SimpleMeasurementsChartConfiguration chartSettings = loadChart(key + '.' + chart + '.', configuration); if (validateChart(chartSettings)) { chartSettings.measurementType = measurementType; result.add(chartSettings); } } return result; }  @Override List<MeasurementsChartConfiguration> loadConfigurationsForMeasurementType(String measurementType);  }