diff options
3 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java index 03d42d5..b213a45 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java @@ -95,6 +95,7 @@ public class App { dataRouterSubscriber.start(); ArrayList<Configurable> configurables = new ArrayList<>(); configurables.add(dataRouterSubscriber); + configurables.add(mapperConfig); DynamicConfiguration dynamicConfiguration = new DynamicConfiguration(configurables, mapperConfig); Undertow.builder() diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java index ffb09ba..bd4eafb 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java @@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.pmmapper.model; import java.net.MalformedURLException;
import java.net.URL;
+import org.onap.dcaegen2.services.pmmapper.config.Configurable;
import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
@@ -32,7 +33,7 @@ import lombok.NoArgsConstructor; @Getter
@EqualsAndHashCode
@NoArgsConstructor
-public class MapperConfig {
+public class MapperConfig implements Configurable{
public static final String CLIENT_NAME = "pm-mapper";
@@ -161,4 +162,15 @@ public class MapperConfig { @SerializedName("pm-mapper-filter")
MeasFilterConfig filterConfig;
+
+ @Override
+ public void reconfigure(MapperConfig mapperConfig) {
+ if(!this.equals(mapperConfig)) {
+ this.streamsSubscribes = mapperConfig.getStreamsSubscribes();
+ this.streamsPublishes = mapperConfig.getStreamsPublishes();
+ this.busControllerSubscriptionEndpoint = mapperConfig.getBusControllerSubscriptionEndpoint();
+ this.dmaapDRFeedId = mapperConfig.getDmaapDRFeedId();
+ this.dmaapDRDeleteEndpoint = mapperConfig.getDmaapDRDeleteEndpoint();
+ }
+ }
}
\ No newline at end of file diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfigurationTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfigurationTest.java index 67510da..8840825 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfigurationTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfigurationTest.java @@ -150,4 +150,20 @@ public class DynamicConfigurationTest { verify(configurable, times(1)).reconfigure(modifiedMapperConfig); } + + @Test + public void testMapperConfigReconfiguration() throws Exception { + ConfigHandler configHandler = new ConfigHandler(sender); + JsonObject modifiedConfigJson = new JsonParser().parse(config).getAsJsonObject(); + modifiedConfigJson.addProperty("dmaap_dr_delete_endpoint","http://modified-delete-endpoint/1"); + String newConfig = modifiedConfigJson.toString(); + + when(sender.send(any())).thenReturn(config,newConfig); + + MapperConfig originalConfig = configHandler.getMapperConfig(); + MapperConfig modifiedConfig = configHandler.getMapperConfig(); + + originalConfig.reconfigure(modifiedConfig); + assertEquals(originalConfig, modifiedConfig); + } } |