Skip to content

Commit

Permalink
Added test case for custom attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
akats7 committed Jul 24, 2023
1 parent d77f5cb commit 88d30ae
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ void transformMultipleAttributes() throws Exception {
Stream.of(new String[] {"anotherNewValue"}).collect(Collectors.toList()));
}

@Test
void customAttribute() throws Exception {
String thingName = "io.opentelemetry.contrib.jmxmetrics:type=custom";
Thing thing = new Thing("");
mbeanServer.registerMBean(thing, new ObjectName(thingName));
Map<String, Closure<?>> map =
Stream.of(
new Object[][] {
{"CustomAttribute", Eval.me("{mbean -> 'customValue'}")},
})
.collect(Collectors.toMap(data -> (String) data[0], data -> (Closure<?>) data[1]));
MBeanHelper mBeanHelper = new MBeanHelper(jmxClient, thingName, true, map);
mBeanHelper.fetch();

assertThat(mBeanHelper.getAttribute("CustomAttribute"))
.hasSameElementsAs(Stream.of(new String[] {"customValue"}).collect(Collectors.toList()));
}

private static void registerThings(String thingName) throws Exception {
for (int i = 0; i < 100; i++) {
Thing thing = new Thing(Integer.toString(i));
Expand Down

0 comments on commit 88d30ae

Please sign in to comment.