@Test
public void testTabularDataToMap() 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<?,?> result = JmxValueFunctions.tabularDataToMap(table);
assertEquals(result, row2);
Map<?,?> result2 = JmxValueFunctions.tabularDataToMap().apply(table);
assertEquals(result2, row2);
}
}