Skip to content

Commit

Permalink
Feature/allow multiple notification urls (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
saschadoemer authored Oct 23, 2023
1 parent 791a317 commit 9d19095
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/de/app/fivegla/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.Collections;
import java.util.List;

/**
* The main class of the application.
Expand Down Expand Up @@ -56,8 +56,8 @@ public class Application {
@Value("${app.fiware.contextBrokerUrl}")
private String contextBrokerUrl;

@Value("${app.fiware.subscriptions.notificationUrl}")
private String notificationUrl;
@Value("${app.fiware.subscriptions.notificationUrls}")
private String[] notificationUrls;

@Value("${app.fiware.tenant}")
private String tenant;
Expand Down Expand Up @@ -123,7 +123,7 @@ public StatusService statusService() {
*/
@Bean
public SubscriptionService subscriptionService() {
return new SubscriptionService(contextBrokerUrl, tenant, Collections.singletonList(notificationUrl));
return new SubscriptionService(contextBrokerUrl, tenant, List.of(notificationUrls));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ app:
contextBrokerUrl: ${CONTEXT_BROKER_URL}
subscriptions:
enabled: true
notificationUrl: ${NOTIFICATION_URL}
notificationUrls: ${NOTIFICATION_URLS}
tenant: ${FIWARE_TENANT}
cors:
allowed-origins: ${CORS_ALLOWED_ORIGINS}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.app.fivegla;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
class ApplicationConfigurationIntegrationTest extends SpringBootIntegrationTestBase {

@Value("${app.fiware.subscriptions.notificationUrls}")
private String[] notificationUrls;

@Test
void givenValidConfigurationWhenResolvingNotificationUrlsThenReturnValidUrls() {
assertThat(notificationUrls).isNotEmpty();
assertThat(notificationUrls.length).isEqualTo(2);
assertThat(notificationUrls[0]).isEqualTo("https://cygnus1.5gla.de");
assertThat(notificationUrls[1]).isEqualTo("https://cygnus2.5gla.de");
}

}
2 changes: 1 addition & 1 deletion src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ app:
contextBrokerUrl: https://orion.5gla.de
subscriptions:
enabled: false
notificationUrl: https://cygnus.5gla.de
notificationUrls: https://cygnus1.5gla.de, https://cygnus2.5gla.de
tenant: default
cors:
allowed-origins: "http://localhost:8080,https://app.5gla.de/"
Expand Down

0 comments on commit 9d19095

Please sign in to comment.