DimensionDictionary implements Serializable { public int[] translate(List<DimensionSpec> dimensions, DimensionKey dimensionKey) { int[] translated = new int[dimensions.size()]; for (int i = 0; i < dimensions.size(); i++) { translated[i] = getValueId(dimensions.get(i).getName(), dimensionKey.getDimensionValues()[i]); } return translated; } DimensionDictionary();  DimensionDictionary(Map<String, Map<String, Integer>> dictionary); void setDictionary(Map<String, Map<String, Integer>> dictionary); Map<String, Map<String, Integer>> getDictionary(); Map<String, Map<Integer, String>> getReverseDictionary(); Map<String, Integer> getDictionary(String dimensionName); Map<Integer, String> getReverseDictionary(String dimensionName); Integer getValueId(String dimensionName, String dimensionValue); String getDimensionValue(String dimensionName, Integer valueId); int[] translate(List<DimensionSpec> dimensions, DimensionKey dimensionKey); DimensionKey translate(List<DimensionSpec> dimensions, int[] dimensionKey); @Override boolean equals(Object o);  }
@Test public void testTranslateToInt() { DimensionKey dimensionKey = new DimensionKey(new String[] { "A0", "B0", "C0"}); int[] intKey = dictionary.translate(config.getDimensions(), dimensionKey); Assert.assertEquals(intKey, new int[] { 2, 2, 2 }); }
@Test public void testTranslateToString() { int[] intKey = new int[] { 2, 2, 2 }; DimensionKey dimensionKey = dictionary.translate(config.getDimensions(), intKey); Assert.assertEquals(dimensionKey.getDimensionValues(), new String[] { "A0", "B0", "C0" }); }