Search in sources :

Example 1 with TestNotifier

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)));
}
Also used : TestNotifier(de.codecentric.boot.admin.notify.TestNotifier) Test(org.junit.Test)

Example 2 with TestNotifier

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));
}
Also used : TestNotifier(de.codecentric.boot.admin.notify.TestNotifier) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Aggregations

TestNotifier (de.codecentric.boot.admin.notify.TestNotifier)2 Test (org.junit.Test)2 ClientApplicationEvent (de.codecentric.boot.admin.event.ClientApplicationEvent)1