### Question:
MmdTool extends BasicTool { static TreeSet<String> getDimensionNames(List<String> targetColumnNames, ColumnRegistry columnRegistry) { final TreeSet<String> dimensionNames = new TreeSet<>(); for (final String name : targetColumnNames) { System.out.println("targetColumnNames: " + name); final Item column = columnRegistry.getColumn(name); final String dimensions = column.getDimensions(); System.out.println("dimensions: " + dimensions); if (dimensions.isEmpty()) { final String message = MessageFormat.format("Expected at least one dimension for target column ''{0}''.", name); throw new ToolException(message, ToolException.TOOL_CONFIGURATION_ERROR); } dimensionNames.addAll(Arrays.asList(dimensions.split("\\s"))); } return dimensionNames; } MmdTool(); static void main(String[] args); @Override void initialize();  }### Answer:
@Test public void testInitializeDimensionNames_emptyNameList() { final ColumnRegistry columnRegistry = new ColumnRegistry(); final List<String> nameList = new ArrayList<>(); final Set<String> dimensionNames = MmdTool.getDimensionNames(nameList, columnRegistry); assertNotNull(dimensionNames); assertEquals(0, dimensionNames.size()); }
@Test public void testInitializeDimensionNames() { final ColumnRegistry columnRegistry = new ColumnRegistry(); columnRegistry.register(new ColumnBuilder().name("Heike").dimensions("a b c").rank(3).build()); columnRegistry.register(new ColumnBuilder().name("Klaus").dimensions("left right").rank(2).build()); final List<String> nameList = new ArrayList<>(); nameList.add("Klaus"); nameList.add("Heike"); final TreeSet<String> dimensionNames = MmdTool.getDimensionNames(nameList, columnRegistry); assertNotNull(dimensionNames); assertEquals(5, dimensionNames.size()); assertThat(dimensionNames, hasItem("left")); assertThat(dimensionNames, hasItem("b")); }
@Test public void testInitializeDimensionNames_emptyDimensionTriggersException() { final ColumnRegistry columnRegistry = new ColumnRegistry(); columnRegistry.register(new ColumnBuilder().name("Heike").dimensions("").rank(0).build()); final List<String> nameList = new ArrayList<>(); nameList.add("Heike"); try { MmdTool.getDimensionNames(nameList, columnRegistry); fail("ToolException expected"); } catch (ToolException expected) { } }