use of de.codecentric.boot.admin.server.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(), repository);
notifier.setCleanupInterval(Duration.ZERO);
ApplicationNameNotificationFilter filter1 = new ApplicationNameNotificationFilter("foo", Instant.now().minus(Duration.ofSeconds(1)));
notifier.addFilter(filter1);
ApplicationNameNotificationFilter filter2 = new ApplicationNameNotificationFilter("bar", null);
notifier.addFilter(filter2);
assertThat(notifier.getNotificationFilters()).containsKey(filter1.getId()).containsKey(filter2.getId());
StepVerifier.create(notifier.notify(event)).verifyComplete();
assertThat(notifier.getNotificationFilters()).doesNotContainKey(filter1.getId()).containsKey(filter2.getId());
notifier.removeFilter(filter2.getId());
assertThat(notifier.getNotificationFilters()).doesNotContainKey(filter2.getId());
}
use of de.codecentric.boot.admin.server.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, repository);
AbstractNotificationFilter trueFilter = new AbstractNotificationFilter() {
@Override
public boolean filter(InstanceEvent event, Instance instance) {
return true;
}
};
notifier.addFilter(trueFilter);
StepVerifier.create(notifier.notify(event)).verifyComplete();
assertThat(delegate.getEvents()).doesNotContain(event);
notifier.removeFilter(trueFilter.getId());
StepVerifier.create(notifier.notify(event)).verifyComplete();
assertThat(delegate.getEvents()).contains(event);
}
Aggregations