use of de.codecentric.boot.admin.model.Application 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))));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getApplications.
@Test
public void getApplications() throws Exception {
Application app = registry.register(Application.create("abc").withHealthUrl("http://localhost/health").build());
Collection<Application> applications = registry.getApplications();
assertEquals(1, applications.size());
assertTrue(applications.contains(app));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class StatusUpdateApplicationListenerTest method test_newApplication.
@Test
public void test_newApplication() throws Exception {
StatusUpdater statusUpdater = mock(StatusUpdater.class);
ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
when(scheduler.submit(any(Runnable.class))).then(new Answer<Future<?>>() {
@Override
public Future<?> answer(InvocationOnMock invocation) throws Throwable {
invocation.getArgumentAt(0, Runnable.class).run();
SettableListenableFuture<?> future = new SettableListenableFuture<Void>();
future.set(null);
return future;
}
});
StatusUpdateApplicationListener listener = new StatusUpdateApplicationListener(statusUpdater, scheduler);
Application application = Application.create("test").withHealthUrl("http://example.com").build();
listener.onClientApplicationRegistered(new ClientApplicationRegisteredEvent(application));
verify(statusUpdater).updateStatus(eq(application));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_update_statusChanged.
@Test
public void test_update_statusChanged() {
when(applicationOps.getHealth(isA(Application.class))).thenReturn(ResponseEntity.ok().body(Collections.<String, Serializable>singletonMap("status", "UP")));
when(applicationOps.getInfo(isA(Application.class))).thenReturn(ResponseEntity.ok().body(Collections.<String, Serializable>singletonMap("foo", "bar")));
updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build());
Application app = store.find("id");
assertThat(app.getStatusInfo().getStatus(), CoreMatchers.is("UP"));
assertThat((Map<String, ? extends Serializable>) app.getInfo().getValues(), hasEntry("foo", (Serializable) "bar"));
verify(publisher).publishEvent(argThat(CoreMatchers.isA(ClientApplicationStatusChangedEvent.class)));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_update_offline.
@Test
public void test_update_offline() {
when(applicationOps.getHealth(any(Application.class))).thenThrow(new ResourceAccessException("error"));
Application app = Application.create("foo").withId("id").withHealthUrl("health").withStatusInfo(StatusInfo.ofUp()).build();
updater.updateStatus(app);
StatusInfo statusInfo = store.find("id").getStatusInfo();
assertThat(statusInfo.getStatus(), CoreMatchers.is("OFFLINE"));
assertThat(statusInfo.getDetails(), hasEntry("message", (Serializable) "error"));
assertThat(statusInfo.getDetails(), hasEntry("exception", (Serializable) "org.springframework.web.client.ResourceAccessException"));
}
Aggregations