diff options
author | emartin <ephraim.martin@est.tech> | 2019-03-27 15:07:27 +0000 |
---|---|---|
committer | emartin <ephraim.martin@est.tech> | 2019-03-27 15:07:27 +0000 |
commit | 36605ed860a6eb7fca09156c6e8ae6ebf5259ea3 (patch) | |
tree | 1307af1e1536777a05055161ac79ff19510779f2 /src | |
parent | a7da4421da0595dfadf6853f96b2d5f04ff35ec2 (diff) |
Enable MapperConfig to be reconfigurable
Change-Id: Ifa4a186e85cb85758d70a9eb5437d9893f236427
Issue-ID: DCAEGEN2-1357
Signed-off-by: emartin <ephraim.martin@est.tech>
Diffstat (limited to 'src')
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); + } } |