use of de.codecentric.boot.admin.notify.TestNotifier in project spring-boot-admin by codecentric.
the class FilteringNotifierTest method test_expired_removal.
@Test
public void test_expired_removal() {
FilteringNotifier notifier = new FilteringNotifier(new TestNotifier());
notifier.setCleanupInterval(0L);
String id1 = notifier.addFilter(new ApplicationNameNotificationFilter("foo", 0L));
String id2 = notifier.addFilter(new ApplicationNameNotificationFilter("bar", -1L));
assertThat(notifier.getNotificationFilters(), hasKey(id1));
assertThat(notifier.getNotificationFilters(), hasKey(id2));
notifier.notify(EVENT);
assertThat(notifier.getNotificationFilters(), not(hasKey(id1)));
assertThat(notifier.getNotificationFilters(), hasKey(id2));
notifier.removeFilter(id2);
assertThat(notifier.getNotificationFilters(), not(hasKey(id2)));
}
use of de.codecentric.boot.admin.notify.TestNotifier in project spring-boot-admin by codecentric.
the class FilteringNotifierTest method test_filter.
@Test
public void test_filter() {
TestNotifier delegate = new TestNotifier();
FilteringNotifier notifier = new FilteringNotifier(delegate);
String idTrue = notifier.addFilter(new NotificationFilter() {
@Override
public boolean filter(ClientApplicationEvent event) {
return true;
}
});
notifier.notify(EVENT);
assertThat(delegate.getEvents(), not(hasItem(EVENT)));
notifier.removeFilter(idTrue);
notifier.notify(EVENT);
assertThat(delegate.getEvents(), hasItem(EVENT));
}
Aggregations