de.codecentric.boot.admin.server.domain.entities.InstanceRepository Java Examples

The following examples show how to use de.codecentric.boot.admin.server.domain.entities.InstanceRepository. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MailNotifierTest.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    repository = mock(InstanceRepository.class);
    when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

    sender = mock(JavaMailSender.class);
    when(sender.createMimeMessage()).thenAnswer(args -> new MimeMessage(Session.getInstance(new Properties())));

    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
    templateEngine.addTemplateResolver(resolver);

    notifier = new MailNotifier(sender, repository, templateEngine);
    notifier.setTo(new String[]{"[email protected]"});
    notifier.setCc(new String[]{"[email protected]"});
    notifier.setFrom("SBA <[email protected]>");
    notifier.setBaseUrl("http://localhost:8080");
    notifier.setTemplate("/META-INF/spring-boot-admin-server/mail/status-changed.html");
}
 
Example #2
Source File: MailNotifierTest.java    From spring-boot-admin with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setup() {
	repository = mock(InstanceRepository.class);
	when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

	sender = mock(JavaMailSender.class);
	when(sender.createMimeMessage()).thenAnswer((args) -> new MimeMessage(Session.getInstance(new Properties())));

	SpringTemplateEngine templateEngine = new SpringTemplateEngine();
	ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
	resolver.setTemplateMode(TemplateMode.HTML);
	resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
	templateEngine.addTemplateResolver(resolver);

	notifier = new MailNotifier(sender, repository, templateEngine);
	notifier.setTo(new String[] { "[email protected]" });
	notifier.setCc(new String[] { "[email protected]" });
	notifier.setFrom("SBA <[email protected]>");
	notifier.setBaseUrl("http://localhost:8080");
	notifier.setTemplate("/META-INF/spring-boot-admin-server/mail/status-changed.html");
}
 
Example #3
Source File: InstanceDiscoveryListenerTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    discovery = mock(DiscoveryClient.class);
    InstanceRepository repository = new EventsourcingInstanceRepository(new InMemoryEventStore());
    registry = spy(new InstanceRegistry(repository, new HashingInstanceUrlIdGenerator()));
    listener = new InstanceDiscoveryListener(discovery, registry, repository);
}
 
Example #4
Source File: AdminServerAutoConfigurationTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleConfig() {
	this.contextRunner.run((context) -> {
		assertThat(context).getBean(InstanceRepository.class).isInstanceOf(SnapshottingInstanceRepository.class);
		assertThat(context).doesNotHaveBean(MailNotifier.class);
		assertThat(context).getBean(InstanceEventStore.class).isInstanceOf(ConcurrentMapEventStore.class);
	});
}
 
Example #5
Source File: DiscordNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
	restTemplate = mock(RestTemplate.class);
	notifier = new DiscordNotifier(repository, restTemplate);
	notifier.setWebhookUrl(webhookUri);
}
 
Example #6
Source File: MicrosoftTeamsNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	instance = Instance.create(InstanceId.of(appId)).register(
			Registration.create(appName, healthUrl).managementUrl(managementUrl).serviceUrl(serviceUrl).build());

	repository = mock(InstanceRepository.class);
	when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

	mockRestTemplate = mock(RestTemplate.class);
	notifier = new MicrosoftTeamsNotifier(repository, mockRestTemplate);
	notifier.setWebhookUrl(URI.create("http://example.com"));
}
 
Example #7
Source File: AdminServerNotifierAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties("spring.boot.admin.notify.pagerduty")
public PagerdutyNotifier pagerdutyNotifier(InstanceRepository repository,
		NotifierProxyProperties proxyProperties) {
	return new PagerdutyNotifier(repository, createNotifierRestTemplate(proxyProperties));
}
 
Example #8
Source File: AdminServerAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public EndpointDetector endpointDetector(InstanceRepository instanceRepository,
		InstanceWebClient.Builder instanceWebClientBuilder) {
	InstanceWebClient instanceWebClient = instanceWebClientBuilder.build();
	ChainingStrategy strategy = new ChainingStrategy(new QueryIndexEndpointStrategy(instanceWebClient),
			new ProbeEndpointsStrategy(instanceWebClient, this.adminServerProperties.getProbedEndpoints()));
	return new EndpointDetector(instanceRepository, strategy);
}
 
Example #9
Source File: AdminServerNotifierAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties("spring.boot.admin.notify.letschat")
public LetsChatNotifier letsChatNotifier(InstanceRepository repository,
		NotifierProxyProperties proxyProperties) {
	return new LetsChatNotifier(repository, createNotifierRestTemplate(proxyProperties));
}
 
Example #10
Source File: AdminServerAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public EndpointDetector endpointDetector(InstanceRepository instanceRepository,
                                         InstanceWebClient instanceWebClient) {
    ChainingStrategy strategy = new ChainingStrategy(
        new QueryIndexEndpointStrategy(instanceWebClient),
        new ProbeEndpointsStrategy(instanceWebClient, adminServerProperties.getProbedEndpoints())
    );
    return new EndpointDetector(instanceRepository, strategy);
}
 
Example #11
Source File: AdminServerNotifierAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties("spring.boot.admin.notify.telegram")
public TelegramNotifier telegramNotifier(InstanceRepository repository,
		NotifierProxyProperties proxyProperties) {
	return new TelegramNotifier(repository, createNotifierRestTemplate(proxyProperties));
}
 
Example #12
Source File: InstanceDiscoveryListenerTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	this.discovery = mock(DiscoveryClient.class);
	InstanceRepository repository = new EventsourcingInstanceRepository(new InMemoryEventStore());
	this.registry = spy(new InstanceRegistry(repository, new HashingInstanceUrlIdGenerator()));
	this.listener = new InstanceDiscoveryListener(this.discovery, this.registry, repository);
}
 
Example #13
Source File: TelegramNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

	restTemplate = mock(RestTemplate.class);
	notifier = new TelegramNotifier(repository, restTemplate);
	notifier.setDisableNotify(false);
	notifier.setAuthToken("--token-");
	notifier.setChatId("-room-");
	notifier.setParseMode("HTML");
	notifier.setApiUrl("https://telegram.com");
}
 
Example #14
Source File: PagerdutyNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
	restTemplate = mock(RestTemplate.class);

	notifier = new PagerdutyNotifier(repository, restTemplate);
	notifier.setServiceKey("--service--");
	notifier.setClient("TestClient");
	notifier.setClientUrl(URI.create("http://localhost"));
}
 
Example #15
Source File: MossServerDiscoveryAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
                                                           InstanceRegistry registry,
                                                           InstanceRepository repository) {
    MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
    listener.setConverter(serviceInstanceConverter);
    return listener;
}
 
Example #16
Source File: HipchatNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

	restTemplate = mock(RestTemplate.class);
	notifier = new HipchatNotifier(repository, restTemplate);
	notifier.setNotify(true);
	notifier.setAuthToken("--token-");
	notifier.setRoomId("-room-");
	notifier.setUrl(URI.create("http://localhost/v2"));
}
 
Example #17
Source File: RemindingNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	this.repository = mock(InstanceRepository.class);
	when(this.repository.find(any())).thenReturn(Mono.empty());
	when(this.repository.find(instance1.getId())).thenReturn(Mono.just(instance1));
	when(this.repository.find(instance2.getId())).thenReturn(Mono.just(instance2));
}
 
Example #18
Source File: HipchatNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

    restTemplate = mock(RestTemplate.class);
    notifier = new HipchatNotifier(repository);
    notifier.setNotify(true);
    notifier.setAuthToken("--token-");
    notifier.setRoomId("-room-");
    notifier.setUrl(URI.create("http://localhost/v2"));
    notifier.setRestTemplate(restTemplate);
}
 
Example #19
Source File: TelegramNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

    restTemplate = mock(RestTemplate.class);
    notifier = new TelegramNotifier(repository);
    notifier.setDisableNotify(false);
    notifier.setAuthToken("--token-");
    notifier.setChatId("-room-");
    notifier.setParseMode("HTML");
    notifier.setApiUrl("https://telegram.com");
    notifier.setRestTemplate(restTemplate);
}
 
Example #20
Source File: OpsGenieNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
    restTemplate = mock(RestTemplate.class);

    notifier = new OpsGenieNotifier(repository);
    notifier.setApiKey("--service--");
    notifier.setRestTemplate(restTemplate);
    notifier.setUser("--user--");
    notifier.setSource("--source--");
    notifier.setEntity("--entity--");
    notifier.setTags("--tag1--,--tag2--");
    notifier.setActions("--action1--,--action2--");
}
 
Example #21
Source File: DiscordNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
    restTemplate = mock(RestTemplate.class);
    notifier = new DiscordNotifier(repository);
    notifier.setRestTemplate(restTemplate);
    notifier.setWebhookUrl(webhookUri);
}
 
Example #22
Source File: PagerdutyNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
    restTemplate = mock(RestTemplate.class);

    notifier = new PagerdutyNotifier(repository);
    notifier.setServiceKey("--service--");
    notifier.setClient("TestClient");
    notifier.setClientUrl(URI.create("http://localhost"));
    notifier.setRestTemplate(restTemplate);
}
 
Example #23
Source File: LetsChatNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    InstanceRepository repository = mock(InstanceRepository.class);
    when(repository.find(instance.getId())).thenReturn(Mono.just(instance));

    restTemplate = mock(RestTemplate.class);
    notifier = new LetsChatNotifier(repository);
    notifier.setUsername(user);
    notifier.setUrl(URI.create(host));
    notifier.setRoom(room);
    notifier.setToken(token);
    notifier.setRestTemplate(restTemplate);
}
 
Example #24
Source File: SlackNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
	restTemplate = mock(RestTemplate.class);

	notifier = new SlackNotifier(repository, restTemplate);
	notifier.setUsername(user);
	notifier.setWebhookUrl(URI.create("http://localhost/"));
}
 
Example #25
Source File: SlackNotifierTest.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    repository = mock(InstanceRepository.class);
    when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
    restTemplate = mock(RestTemplate.class);

    notifier = new SlackNotifier(repository);
    notifier.setUsername(user);
    notifier.setWebhookUrl(URI.create("http://localhost/"));
    notifier.setRestTemplate(restTemplate);
}
 
Example #26
Source File: MossServerDiscoveryAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
                                                               InstanceRegistry registry,
                                                               InstanceRepository repository) {
    MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
    listener.setConverter(serviceInstanceConverter);
    return listener;
}
 
Example #27
Source File: OpsGenieNotifierTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
	repository = mock(InstanceRepository.class);
	when(repository.find(INSTANCE.getId())).thenReturn(Mono.just(INSTANCE));
	restTemplate = mock(RestTemplate.class);

	notifier = new OpsGenieNotifier(repository, restTemplate);
	notifier.setApiKey("--service--");
	notifier.setUser("--user--");
	notifier.setSource("--source--");
	notifier.setEntity("--entity--");
	notifier.setTags("--tag1--,--tag2--");
	notifier.setActions("--action1--,--action2--");
}
 
Example #28
Source File: AdminServerDiscoveryAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = "spring.boot.admin.discovery")
public InstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
                                                           DiscoveryClient discoveryClient,
                                                           InstanceRegistry registry,
                                                           InstanceRepository repository) {
    InstanceDiscoveryListener listener = new InstanceDiscoveryListener(discoveryClient, registry, repository);
    listener.setConverter(serviceInstanceConverter);
    return listener;
}
 
Example #29
Source File: MossServerDiscoveryAutoConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
                                                               InstanceRegistry registry,
                                                               InstanceRepository repository) {
    MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
    listener.setConverter(serviceInstanceConverter);
    listener.setIgnoredServices(Sets.newHashSet("consul"));
    return listener;
}
 
Example #30
Source File: AdminServerAutoConfiguration.java    From spring-boot-admin with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public StatusUpdater statusUpdater(InstanceRepository instanceRepository,
		InstanceWebClient.Builder instanceWebClientBulder) {
	return new StatusUpdater(instanceRepository, instanceWebClientBulder.build());
}