MetricNotificationService implements NotificationService { @Override public boolean notify(Notification notification) { List<String> attributesList = new ArrayList<>(); notification.getDetails().forEach((k, v) -> { attributesList.add(k); attributesList.add(v); }); attributesList.add("notif_type"); attributesList.add(notification.getType()); metric.increment("athenz_notification", attributesList.toArray(new String[0])); return true; } MetricNotificationService(Metric metric); @Override boolean notify(Notification notification);  }
@Test public void testNotify() { Metric metric = Mockito.mock(Metric.class); MetricNotificationService metricNotificationService = new MetricNotificationService(metric); Map<String, String> details = new HashMap<>(); details.put("key1", "attribute1"); details.put("key2", "attribute2"); details.put("key3", "attribute3"); Notification notification = new Notification(); notification.setDetails(details); notification.setType("testType"); boolean notify = metricNotificationService.notify(notification); assertTrue(notify); String[] expectedAttributes = new String[] { "key1", "attribute1", "key2", "attribute2", "key3", "attribute3", "notif_type", "testType" }; Mockito.verify(metric, Mockito.times(1)) .increment("athenz_notification", expectedAttributes); }