Commit ad70d6cd by Johannes Edmeier Committed by Johannes Edmeier

Clean up sources

parent eb8b9709
......@@ -22,7 +22,6 @@ import org.springframework.context.annotation.Configuration;
import de.codecentric.boot.admin.config.EnableAdminServer;
// tag::application-eureka[]
@Configuration
@EnableAutoConfiguration
......
......@@ -69,27 +69,27 @@ public class SpringBootAdminApplication {
@Configuration
public static class NotifierConfig {
@Bean
@Primary
public RemindingNotifier remindingNotifier() {
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(loggerNotifier()));
notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(10));
return notifier;
}
@Bean
@Primary
public RemindingNotifier remindingNotifier() {
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(loggerNotifier()));
notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(10));
return notifier;
}
@Scheduled(fixedRate = 1_000L)
public void remind() {
remindingNotifier().sendReminders();
}
@Scheduled(fixedRate = 1_000L)
public void remind() {
remindingNotifier().sendReminders();
}
@Bean
public FilteringNotifier filteringNotifier(Notifier delegate) {
return new FilteringNotifier(delegate);
}
@Bean
public FilteringNotifier filteringNotifier(Notifier delegate) {
return new FilteringNotifier(delegate);
}
@Bean
public LoggingNotifier loggerNotifier() {
return new LoggingNotifier();
}
@Bean
public LoggingNotifier loggerNotifier() {
return new LoggingNotifier();
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -39,7 +39,6 @@ public class TurbineProperties {
*/
private boolean enabled = true;
public String[] getClusters() {
return clusters;
}
......
......@@ -27,7 +27,7 @@ import de.codecentric.boot.admin.web.AdminController;
/**
* Provides informations for the turbine view. Only available clusters until now.
*
*
* @author Johannes Edmeier
*/
@AdminController
......
......@@ -36,8 +36,8 @@ public class TurbineRouteLocator extends SimpleRouteLocator {
private final Map<String, ZuulRoute> routes;
private DiscoveryClient discovery;
public TurbineRouteLocator(ZuulRoute route, String servletPath,
ZuulProperties zuulProperties, DiscoveryClient discovery) {
public TurbineRouteLocator(ZuulRoute route, String servletPath, ZuulProperties zuulProperties,
DiscoveryClient discovery) {
super(servletPath, zuulProperties);
this.routes = singletonMap(route.getPath(), route);
this.discovery = discovery;
......@@ -68,8 +68,7 @@ public class TurbineRouteLocator extends SimpleRouteLocator {
private String resolveServiceId(String location) {
List<ServiceInstance> instances = discovery.getInstances(location);
if (instances.isEmpty()) {
throw new IllegalStateException(
"No instance found for serviceId '" + location + "'");
throw new IllegalStateException("No instance found for serviceId '" + location + "'");
}
return instances.get(0).getUri().toString();
......
......@@ -13,8 +13,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
public class TurbineControllerTest {
private MockMvc mvc = MockMvcBuilders
.standaloneSetup(new TurbineController(new String[] { "c1", "c2" }))
.build();
.standaloneSetup(new TurbineController(new String[] { "c1", "c2" })).build();
@Test
public void test_clusters() throws Exception {
......
......@@ -57,8 +57,7 @@ public class DefaultServiceInstanceConverter implements ServiceInstanceConverter
@Override
public Application convert(ServiceInstance instance) {
LOGGER.debug("Converting service '{}' running at '{}' with metadata {}",
instance.getServiceId(),
instance.getUri(), instance.getMetadata());
instance.getServiceId(), instance.getUri(), instance.getMetadata());
Application.Builder builder = Application.create(instance.getServiceId());
URI healthUrl = getHealthUrl(instance);
......
......@@ -19,7 +19,7 @@ import java.io.Serializable;
/**
* Signals that the routes needs to be recalculated.
*
*
* @author Johannes Edmeier
*/
public class RoutesOutdatedEvent implements Serializable {
......
......@@ -6,7 +6,7 @@ import org.springframework.core.io.ByteArrayResource;
/**
* Extension of ByteArrayResource with lastModified and filename.
*
*
* @author Johannes Edmeier
*/
public class InMemoryFileResource extends ByteArrayResource {
......
......@@ -198,8 +198,8 @@ public class Application implements Serializable {
@Override
public String toString() {
return "Application [id=" + id + ", name=" + name + ", managementUrl="
+ managementUrl + ", healthUrl=" + healthUrl + ", serviceUrl=" + serviceUrl + "]";
return "Application [id=" + id + ", name=" + name + ", managementUrl=" + managementUrl
+ ", healthUrl=" + healthUrl + ", serviceUrl=" + serviceUrl + "]";
}
@Override
......
......@@ -43,7 +43,6 @@ public abstract class AbstractEventNotifier implements Notifier {
}
}
protected boolean shouldNotify(ClientApplicationEvent event) {
return true;
}
......@@ -61,4 +60,4 @@ public abstract class AbstractEventNotifier implements Notifier {
public boolean isEnabled() {
return enabled;
}
}
\ No newline at end of file
}
......@@ -33,7 +33,8 @@ public class LoggingNotifier extends AbstractStatusChangeNotifier {
protected void doNotify(ClientApplicationEvent event) throws Exception {
if (event instanceof ClientApplicationStatusChangedEvent) {
LOGGER.info("Application {} ({}) is {}", event.getApplication().getName(),
event.getApplication().getId(), ((ClientApplicationStatusChangedEvent) event).getTo().getStatus());
event.getApplication().getId(),
((ClientApplicationStatusChangedEvent) event).getTo().getStatus());
} else {
LOGGER.info("Application {} ({}) {}", event.getApplication().getName(),
event.getApplication().getId(), event.getType());
......
......@@ -92,7 +92,8 @@ public class SlackNotifier extends AbstractStatusChangeNotifier {
protected String getColor(ClientApplicationEvent event) {
if (event instanceof ClientApplicationStatusChangedEvent) {
return "UP".equals(((ClientApplicationStatusChangedEvent) event).getTo().getStatus()) ? "good" : "danger";
return "UP".equals(((ClientApplicationStatusChangedEvent) event).getTo().getStatus())
? "good" : "danger";
} else {
return "#439FE0";
}
......
......@@ -17,7 +17,7 @@ package de.codecentric.boot.admin.notify.filter;
import de.codecentric.boot.admin.event.ClientApplicationEvent;
public class ApplicationIdNotificationFilter extends ExpiringNotificationFilter {
public class ApplicationIdNotificationFilter extends ExpiringNotificationFilter {
private final String id;
public ApplicationIdNotificationFilter(String id, long expiry) {
......
......@@ -17,7 +17,7 @@ package de.codecentric.boot.admin.notify.filter;
import de.codecentric.boot.admin.event.ClientApplicationEvent;
public class ApplicationNameNotificationFilter extends ExpiringNotificationFilter {
public class ApplicationNameNotificationFilter extends ExpiringNotificationFilter {
private final String name;
public ApplicationNameNotificationFilter(String name, long expiry) {
......
......@@ -59,12 +59,10 @@ public class ApplicationRegistry implements ApplicationEventPublisherAware {
Assert.hasText(application.getName(), "Name must not be null");
Assert.hasText(application.getHealthUrl(), "Health-URL must not be null");
Assert.isTrue(checkUrl(application.getHealthUrl()), "Health-URL is not valid");
Assert.isTrue(
StringUtils.isEmpty(application.getManagementUrl())
|| checkUrl(application.getManagementUrl()), "URL is not valid");
Assert.isTrue(
StringUtils.isEmpty(application.getServiceUrl())
|| checkUrl(application.getServiceUrl()), "URL is not valid");
Assert.isTrue(StringUtils.isEmpty(application.getManagementUrl())
|| checkUrl(application.getManagementUrl()), "URL is not valid");
Assert.isTrue(StringUtils.isEmpty(application.getServiceUrl())
|| checkUrl(application.getServiceUrl()), "URL is not valid");
String applicationId = generator.generateId(application);
Assert.notNull(applicationId, "ID must not be null");
......@@ -91,7 +89,6 @@ public class ApplicationRegistry implements ApplicationEventPublisherAware {
return registering;
}
/**
* Checks the syntax of the given URL.
*
......
......@@ -25,8 +25,8 @@ import de.codecentric.boot.admin.model.Application;
* Generates an SHA-1 Hash based on the applications url.
*/
public class HashingApplicationUrlIdGenerator implements ApplicationIdGenerator {
private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f' };
private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
'b', 'c', 'd', 'e', 'f' };
@Override
public String generateId(Application a) {
......
......@@ -13,7 +13,8 @@ import org.springframework.web.context.WebApplicationContext;
import de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent;
public class StatusUpdateApplicationListener {
private static final Logger LOGGER = LoggerFactory.getLogger(StatusUpdateApplicationListener.class);
private static final Logger LOGGER = LoggerFactory
.getLogger(StatusUpdateApplicationListener.class);
private final ThreadPoolTaskScheduler taskScheduler;
private final StatusUpdater statusUpdater;
private long updatePeriod = 10_000L;
......
......@@ -11,7 +11,7 @@ import de.codecentric.boot.admin.model.Application;
/**
* Provides Basic Auth headers for the {@link Application} using the metadata for "user.name" and
* "user.password".
*
*
* @author Johannes Edmeier
*/
public class BasicAuthHttpHeaderProvider implements HttpHeadersProvider {
......
......@@ -18,7 +18,6 @@ package de.codecentric.boot.admin.config;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.After;
......
......@@ -32,8 +32,8 @@ public class ApplicationEventJournalTest {
@Test
public void test_registration() {
ClientApplicationEvent emittedEvent = new ClientApplicationRegisteredEvent(Application
.create("foo").withId("bar").withHealthUrl("http://health").build());
ClientApplicationEvent emittedEvent = new ClientApplicationRegisteredEvent(
Application.create("foo").withId("bar").withHealthUrl("http://health").build());
journal.onClientApplicationEvent(emittedEvent);
Collection<ClientApplicationEvent> events = journal.getEvents();
......
......@@ -42,7 +42,7 @@ public class HazelcastJournaledEventStoreTest {
public void setup() {
HazelcastInstance hazelcast = HazelcastInstanceFactory.newHazelcastInstance(new Config());
store = new HazelcastJournaledEventStore(
hazelcast.<ClientApplicationEvent> getList("testList"));
hazelcast.<ClientApplicationEvent>getList("testList"));
}
@Test
......
package de.codecentric.boot.admin.model;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
......
......@@ -28,7 +28,8 @@ public class CompositeNotifierTest {
public void test_all_notifiers_get_notified() throws Exception {
TestNotifier notifier1 = new TestNotifier();
TestNotifier notifier2 = new TestNotifier();
CompositeNotifier compositeNotifier = new CompositeNotifier(Arrays.<Notifier>asList(notifier1,notifier2));
CompositeNotifier compositeNotifier = new CompositeNotifier(
Arrays.<Notifier>asList(notifier1, notifier2));
compositeNotifier.notify(APP_DOWN);
......
package de.codecentric.boot.admin.notify;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
......
......@@ -13,9 +13,8 @@ public class ApplicationIdNotificationFilterTest {
public void test_filterByName() {
NotificationFilter filter = new ApplicationIdNotificationFilter("cafebabe", -1L);
ClientApplicationRegisteredEvent fooEvent = new ClientApplicationRegisteredEvent(
Application.create("foo").withId("cafebabe").withHealthUrl("http://health")
.build());
ClientApplicationRegisteredEvent fooEvent = new ClientApplicationRegisteredEvent(Application
.create("foo").withId("cafebabe").withHealthUrl("http://health").build());
assertThat(filter.filter(fooEvent)).isTrue();
ClientApplicationRegisteredEvent barEvent = new ClientApplicationRegisteredEvent(
......
......@@ -48,7 +48,7 @@ public class NotificationFilterControllerTest {
String id = extractId(response);
mvc.perform(get("/api/notifications/filters")).andExpect(status().isOk())
.andExpect(jsonPath("$..id").value("1337"));
.andExpect(jsonPath("$..id").value("1337"));
mvc.perform(delete("/api/notifications/filters/{id}", id)).andExpect(status().isOk());
......
......@@ -73,8 +73,8 @@ public class ApplicationRegistryTest {
@Test
public void register() throws Exception {
Application app = registry.register(Application.create("abc")
.withHealthUrl("http://localhost:8080/health").build());
Application app = registry.register(
Application.create("abc").withHealthUrl("http://localhost:8080/health").build());
assertThat(app.getHealthUrl()).isEqualTo("http://localhost:8080/health");
assertThat(app.getName()).isEqualTo("abc");
......@@ -102,17 +102,17 @@ public class ApplicationRegistryTest {
@Test
public void getApplication() throws Exception {
Application app = registry.register(Application.create("abc")
.withHealthUrl("http://localhost/health")
.withManagementUrl("http://localhost:8080/").build());
Application app = registry
.register(Application.create("abc").withHealthUrl("http://localhost/health")
.withManagementUrl("http://localhost:8080/").build());
assertThat(registry.getApplication(app.getId())).isEqualTo(app);
assertThat(app.getManagementUrl()).isEqualTo("http://localhost:8080/");
}
@Test
public void getApplications() throws Exception {
Application app = registry.register(Application.create("abc")
.withHealthUrl("http://localhost/health").build());
Application app = registry.register(
Application.create("abc").withHealthUrl("http://localhost/health").build());
Collection<Application> applications = registry.getApplications();
assertThat(applications).containsOnly(app);
......@@ -120,12 +120,12 @@ public class ApplicationRegistryTest {
@Test
public void getApplicationsByName() throws Exception {
Application app = registry.register(Application.create("abc")
.withHealthUrl("http://localhost/health").build());
Application app2 = registry.register(Application.create("abc")
.withHealthUrl("http://localhost:8081/health").build());
Application app3 = registry.register(Application.create("zzz")
.withHealthUrl("http://localhost:8082/health").build());
Application app = registry.register(
Application.create("abc").withHealthUrl("http://localhost/health").build());
Application app2 = registry.register(
Application.create("abc").withHealthUrl("http://localhost:8081/health").build());
Application app3 = registry.register(
Application.create("zzz").withHealthUrl("http://localhost:8082/health").build());
Collection<Application> applications = registry.getApplicationsByName("abc");
assertThat(applications).containsOnly(app, app2);
......
package de.codecentric.boot.admin.registration;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
......
......@@ -29,9 +29,8 @@ public class RegistrationApplicationListenerTest {
RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator,
scheduler);
listener.onApplicationReady(
new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
verify(scheduler).scheduleAtFixedRate(isA(Runnable.class), eq(10_000L));
}
......@@ -44,9 +43,8 @@ public class RegistrationApplicationListenerTest {
scheduler);
listener.setAutoRegister(false);
listener.onApplicationReady(
new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
verify(scheduler, never()).scheduleAtFixedRate(isA(Runnable.class), eq(10_000L));
}
......@@ -62,9 +60,8 @@ public class RegistrationApplicationListenerTest {
ScheduledFuture task = mock(ScheduledFuture.class);
when(scheduler.scheduleAtFixedRate(isA(Runnable.class), eq(10_000L))).thenReturn(task);
listener.onApplicationReady(
new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null,
mock(ConfigurableWebApplicationContext.class)));
verify(scheduler).scheduleAtFixedRate(isA(Runnable.class), eq(10_000L));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment