Search in sources :

Example 1 with ClientApplicationEvent

use of de.codecentric.boot.admin.event.ClientApplicationEvent in project spring-boot-admin by codecentric.

the class ApplicationEventJournalTest method test_registration.

@Test
public void test_registration() {
    ClientApplicationEvent emittedEvent = new ClientApplicationRegisteredEvent(Application.create("foo").withId("bar").withHealthUrl("http://health").build());
    journal.onClientApplicationEvent(emittedEvent);
    Collection<ClientApplicationEvent> events = journal.getEvents();
    assertThat(events.size(), is(1));
    ClientApplicationEvent event = events.iterator().next();
    assertThat(event, sameInstance(emittedEvent));
}
Also used : ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 2 with ClientApplicationEvent

use of de.codecentric.boot.admin.event.ClientApplicationEvent in project spring-boot-admin by codecentric.

the class HazelcastJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    // Items are stored in reverse order
    List<ClientApplicationEvent> reversed = new ArrayList<>(events);
    Collections.reverse(reversed);
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) reversed));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 3 with ClientApplicationEvent

use of de.codecentric.boot.admin.event.ClientApplicationEvent in project spring-boot-admin by codecentric.

the class SimpleJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    SimpleJournaledEventStore store = new SimpleJournaledEventStore();
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) Arrays.asList(events.get(1), events.get(0))));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 4 with ClientApplicationEvent

use of de.codecentric.boot.admin.event.ClientApplicationEvent in project spring-boot-admin by codecentric.

the class SimpleJournaledEventStoreTest method test_store_capacity.

@Test
public void test_store_capacity() {
    SimpleJournaledEventStore store = new SimpleJournaledEventStore();
    store.setCapacity(2);
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) Arrays.asList(events.get(2), events.get(1))));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 5 with ClientApplicationEvent

use of de.codecentric.boot.admin.event.ClientApplicationEvent 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

ClientApplicationEvent (de.codecentric.boot.admin.event.ClientApplicationEvent)8 Test (org.junit.Test)7 ClientApplicationRegisteredEvent (de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent)5 ClientApplicationDeregisteredEvent (de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent)3 Application (de.codecentric.boot.admin.model.Application)3 Collection (java.util.Collection)3 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ClientApplicationStatusChangedEvent (de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent)1 TestNotifier (de.codecentric.boot.admin.notify.TestNotifier)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1