summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-01-18 09:39:44 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-01-21 11:34:46 +0100
commit4a39a56b42b5ee8586cf91f79187e317491ec003 (patch)
treec7c9c05c05b4df59bf9e2da96525a5f6382a8b05 /mod/bpgenerator
parent6345bc31e13829b84115b3f1de9e384b1f91c2ab (diff)
BPGenerator - fix placement of service component name override
Issue-ID: DCAEGEN2-2481 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I32c3d2eb1e08dbcfe5b8ec57394a000a76150f00
Diffstat (limited to 'mod/bpgenerator')
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java3
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java14
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java42
-rw-r--r--mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/PropertiesServiceTest.java3
4 files changed, 34 insertions, 28 deletions
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java
index a9675f5..dfe02f0 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. All rights reserved.
* * ================================================================================
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
@@ -54,6 +55,8 @@ public class Properties {
private String service_component_type;
+ private GetInput service_component_name_override;
+
private Map<String, Object> log_info;
private String dns_name;
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java
index f0d0e50..494620c 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. All rights reserved.
* * ================================================================================
* * Modifications Copyright (c) 2021 Nokia
* * ================================================================================
@@ -25,15 +26,12 @@
package org.onap.blueprintgenerator.service.common;
-import org.onap.blueprintgenerator.constants.Constants;
import org.onap.blueprintgenerator.model.common.Appconfig;
import org.onap.blueprintgenerator.model.common.Dmaap;
import org.onap.blueprintgenerator.model.common.GetInput;
import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
import org.onap.blueprintgenerator.model.componentspec.common.Calls;
import org.onap.blueprintgenerator.model.componentspec.common.Parameters;
-import org.onap.blueprintgenerator.model.componentspec.common.Publishes;
-import org.onap.blueprintgenerator.model.componentspec.common.Subscribes;
import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -66,14 +64,12 @@ public class AppConfigService {
*
* @param inputs Inputs
* @param onapComponentSpec Onap Component Specification
- * @param override Parameter to Service Component Override
* @param isDmaap Dmaap Argument
* @return
*/
public Map<String, Object> createAppconfig(
Map<String, LinkedHashMap<String, Object>> inputs,
OnapComponentSpec onapComponentSpec,
- String override,
boolean isDmaap) {
Map<String, Object> response = new HashMap<>();
@@ -119,13 +115,7 @@ public class AppConfigService {
}
}
}
- if (override != null) {
- GetInput ov = new GetInput();
- ov.setBpInputName(Constants.SERVICE_COMPONENT_NAME_OVERRIDE);
- parameters.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, ov);
- LinkedHashMap<String, Object> over = blueprintHelperService.createStringInput(override);
- inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, over);
- }
+
appconfig.setParams(parameters);
response.put("appconfig", appconfig);
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java
index be79b25..382cc2b 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. All rights reserved.
* * ================================================================================
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
@@ -23,9 +24,15 @@
package org.onap.blueprintgenerator.service.common;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import org.onap.blueprintgenerator.constants.Constants;
import org.onap.blueprintgenerator.model.common.Appconfig;
import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.Properties;
import org.onap.blueprintgenerator.model.common.ResourceConfig;
import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary;
import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
@@ -35,20 +42,12 @@ import org.onap.blueprintgenerator.model.dmaap.Streams;
import org.onap.blueprintgenerator.model.dmaap.TlsInfo;
import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
import org.onap.blueprintgenerator.service.dmaap.StreamsService;
-import org.onap.blueprintgenerator.model.common.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author : Ravi Mantena
- * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to create Properties
- * Node
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to create Properties Node
*/
@Service("onapPropertiesService")
public class PropertiesService {
@@ -71,9 +70,9 @@ public class PropertiesService {
/**
* Creates ONAP properties
*
- * @param inputs Inputs
+ * @param inputs Inputs
* @param onapComponentSpec OnapComponentSpec
- * @param override Override
+ * @param override Override
* @return
*/
public Map<String, Object> createOnapProperties(
@@ -113,7 +112,7 @@ public class PropertiesService {
properties.setDocker_config(onapAuxilary);
Map<String, Object> appConfigResponse =
- appConfigService.createAppconfig(inputs, onapComponentSpec, override, false);
+ appConfigService.createAppconfig(inputs, onapComponentSpec, false);
inputs = (Map<String, LinkedHashMap<String, Object>>) appConfigResponse.get("inputs");
properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig"));
@@ -131,6 +130,9 @@ public class PropertiesService {
sType = sType.replace('.', '-');
properties.setService_component_type(sType);
+ inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE,
+ addServiceComponentNameOverride(override, properties));
+
Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
addTlsInfo(onapComponentSpec, inputs, properties);
@@ -154,9 +156,9 @@ public class PropertiesService {
/**
* Creates Dmaap properties
*
- * @param inputs Inputs
+ * @param inputs Inputs
* @param onapComponentSpec OnapComponentSpec
- * @param override Override
+ * @param override Override
* @return
*/
public Map<String, Object> createDmaapProperties(
@@ -189,6 +191,9 @@ public class PropertiesService {
sType = sType.replace('.', '-');
properties.setService_component_type(sType);
+ inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE,
+ addServiceComponentNameOverride(override, properties));
+
Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
addTlsInfo(onapComponentSpec, inputs, properties);
@@ -210,7 +215,7 @@ public class PropertiesService {
properties.setDocker_config(onapAuxilary);
Map<String, Object> appConfigResponse =
- appConfigService.createAppconfig(inputs, onapComponentSpec, override, true);
+ appConfigService.createAppconfig(inputs, onapComponentSpec, true);
inputs = (Map<String, LinkedHashMap<String, Object>>) appConfigResponse.get("inputs");
properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig"));
@@ -308,6 +313,13 @@ public class PropertiesService {
return response;
}
+ private LinkedHashMap<String, Object> addServiceComponentNameOverride(String override, Properties properties) {
+ GetInput overrideGetInput = new GetInput();
+ overrideGetInput.setBpInputName(Constants.SERVICE_COMPONENT_NAME_OVERRIDE);
+ properties.setService_component_name_override(overrideGetInput);
+ return blueprintHelperService.createStringInput(override != null ? override : "");
+ }
+
private void addTlsInfo(
OnapComponentSpec onapComponentSpec,
Map<String, LinkedHashMap<String, Object>> inputs,
diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/PropertiesServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/PropertiesServiceTest.java
index 520d2d2..a598315 100644
--- a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/PropertiesServiceTest.java
+++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/PropertiesServiceTest.java
@@ -103,7 +103,7 @@ public class PropertiesServiceTest {
@Test
public void shouldReturnInputsAndPropertiesForOnap() {
//given
- when(appConfigService.createAppconfig(any(), eq(getOnapComponentSpec()), eq(""), eq(false)))
+ when(appConfigService.createAppconfig(any(), eq(getOnapComponentSpec()), eq(false)))
.thenReturn((Map<String, Object>) resourceConfigResponse);
//when
@@ -278,6 +278,7 @@ public class PropertiesServiceTest {
expectedProperties.setImage(getGetInput(image));
expectedProperties.setLocation_id(getGetInput("location_id"));
expectedProperties.setService_component_type("test-Name");
+ expectedProperties.setService_component_name_override(getGetInput("service_component_name_override"));
expectedProperties.setLog_info(Collections.emptyMap());
expectedProperties.setReplicas(getGetInput("replicas"));
expectedProperties.setTls_info(getTlsInfo());