DoubleMatrix2DConverter implements ResultConverter<DoubleMatrix2D> { @Override public Map<String, Double> convert(String valueName, DoubleMatrix2D value) { Map<String, Double> returnValue = new HashMap<String, Double>(); double[][] data = value.getData(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { returnValue.put(valueName + "[" + i + "]" + "[" + j + "]", data[i][j]); } } return returnValue; }  @Override Map<String, Double> convert(String valueName, DoubleMatrix2D value); @Override Class<?> getConvertedClass();  }
@Test public void convertEmpty() { Map<String, Double> expected = new HashMap<String, Double>(); Map<String, Double> actual = _converter.convert("Foo", new DoubleMatrix2D(new double[0][0])); assertEquals(expected, actual); }
@Test public void convertNonEmpty() { Map<String, Double> expected = new HashMap<String, Double>(); expected.put("Foo[0][0]", 5.5); expected.put("Foo[0][1]", 6.6); expected.put("Foo[1][0]", 7.7); expected.put("Foo[1][1]", 8.8); Map<String, Double> actual = _converter.convert("Foo", new DoubleMatrix2D(new double[][] { new double[] { 5.5, 6.6 }, new double[] { 7.7, 8.8 } })); assertEquals(expected, actual); }