@Test
public void testTabularDataToMapOfMaps() throws Exception {
CompositeType rowType = new CompositeType(
"MyRowType",
"my row descr",
new String[] {"key1", "key2"},
new String[] {"key1 descr", "key2 descr"},
new OpenType[] {SimpleType.STRING, SimpleType.STRING});
TabularType tabularType = new TabularType(
"MyTabularType",
"my table descr",
rowType,
new String[] {"key1"});
Map<String, ?> row1 = ImmutableMap.of(
"key1", "row1.val1",
"key2", "row1.val2");
Map<String, ?> row2 = ImmutableMap.of(
"key1", "row2.val1",
"key2", "row2.val2");
TabularDataSupport table = new TabularDataSupport(tabularType);
table.put(new CompositeDataSupport(rowType, row1));
table.put(new CompositeDataSupport(rowType, row2));
Map<List<?>, Map<String, Object>> result = JmxValueFunctions.tabularDataToMapOfMaps(table);
assertEquals(result, ImmutableMap.of(ImmutableList.of("row1.val1"), row1, ImmutableList.of("row2.val1"), row2));
Map<?,?> result2 = JmxValueFunctions.tabularDataToMapOfMaps().apply(table);
assertEquals(result2, ImmutableMap.of(ImmutableList.of("row1.val1"), row1, ImmutableList.of("row2.val1"), row2));
}