### Question:
DimensionConfigurationInitializer { static Map<String, Integer> parseDimensionConfiguration(Collection<String> dimensionNames, Properties properties) { for (String dimName : dimensionNames) { System.out.println("dimName = " + dimName); } properties.list(System.out); final Map<String, Integer> dimensionConfiguration = new HashMap<>(50); for (final String dimensionName : dimensionNames) { if (Constants.DIMENSION_NAME_MATCHUP.equals(dimensionName)) { continue; } final String dimensionLength = properties.getProperty(dimensionName); if (StringUtils.isEmpty(dimensionLength)) { throw new ToolException( MessageFormat.format("Length of dimension ''{0}'' is not configured.", dimensionName), ToolException.TOOL_CONFIGURATION_ERROR); } try { dimensionConfiguration.put(dimensionName, Integer.parseInt(dimensionLength)); } catch (NumberFormatException e) { throw new ToolException( MessageFormat.format("Cannot parse length of dimension ''{0}''.", dimensionName), ToolException.TOOL_CONFIGURATION_ERROR); } } return dimensionConfiguration; }  static Map<String, Integer> initialize(Collection<String> dimensionNames, Configuration configuration);  }### Answer:
@Test public void testParseDimensions() { final List<String> dimensionNames = new ArrayList<>(); dimensionNames.add("upwards"); final Properties dimensionProps = new Properties(); dimensionProps.put("upwards", "72"); final Map<String, Integer> dimensionConfiguration = DimensionConfigurationInitializer.parseDimensionConfiguration(dimensionNames, dimensionProps); assertNotNull(dimensionConfiguration); final Integer upwards = dimensionConfiguration.get("upwards"); assertNotNull(upwards); assertEquals(72, upwards.intValue()); }
@Test public void testParseDimensions_matchupDimensionIsSkipped() { final List<String> dimensionNames = new ArrayList<>(); dimensionNames.add(Constants.DIMENSION_NAME_MATCHUP); dimensionNames.add("left"); final Properties dimensionProps = new Properties(); dimensionProps.put("left", "73"); dimensionProps.put(Constants.DIMENSION_NAME_MATCHUP, "unparseable_integer"); final Map<String, Integer> dimensionConfiguration = DimensionConfigurationInitializer.parseDimensionConfiguration(dimensionNames, dimensionProps); assertNotNull(dimensionConfiguration); final Integer left = dimensionConfiguration.get("left"); assertNotNull(left); assertEquals(73, left.intValue()); }
@Test public void testParseDimensions_missingDimensionInPropertiesThrows() { final List<String> dimensionNames = new ArrayList<>(); dimensionNames.add("right"); final Properties dimensionProps = new Properties(); try { DimensionConfigurationInitializer.parseDimensionConfiguration(dimensionNames, dimensionProps); fail("ToolException expected"); } catch (ToolException expected) { assertEquals("Length of dimension 'right' is not configured.", expected.getMessage()); } }
@Test public void testParseDimensions_unparseableDimensionValueThrows() { final List<String> dimensionNames = new ArrayList<>(); dimensionNames.add("down"); final Properties dimensionProps = new Properties(); dimensionProps.put("down", "weired_value"); try { DimensionConfigurationInitializer.parseDimensionConfiguration(dimensionNames, dimensionProps); fail("ToolException expected"); } catch (ToolException expected) { assertEquals("Cannot parse length of dimension 'down'.", expected.getMessage()); } }