summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/bpgenerator/TestCases/expects/createAppConfigResult.txt1
-rw-r--r--mod/bpgenerator/pom.xml2
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java231
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java62
-rw-r--r--mod/bpgenerator/version.properties4
-rw-r--r--mod/runtimeapi/pom.xml2
-rw-r--r--mod/runtimeapi/runtime-core/pom.xml6
-rw-r--r--mod/runtimeapi/runtime-web/pom.xml6
-rw-r--r--mod2/auth-service/Dockerfile2
-rw-r--r--mod2/auth-service/pom.xml2
-rw-r--r--mod2/auth-service/src/main/resources/application.properties3
-rw-r--r--mod2/catalog-service/pom.xml8
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/blueprintgenerator/DeploymentArtifactGenerator.java (renamed from mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java)24
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java17
14 files changed, 234 insertions, 136 deletions
diff --git a/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt b/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt
new file mode 100644
index 0000000..11ce552
--- /dev/null
+++ b/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt
@@ -0,0 +1 @@
+{TEST-PUB-DR_delivery_url={type=string}, TEST-PUB-DR_location={type=string}, TEST-PUB-DR_password={type=string}, TEST-PUB-DR_subscriber_id={type=string}, TEST-PUB-DR_username={type=string}, TEST-SUB-DR_delivery_url={type=string}, TEST-SUB-DR_location={type=string}, TEST-SUB-DR_password={type=string}, TEST-SUB-DR_subscriber_id={type=string}, TEST-SUB-DR_username={type=string}, TEST_PUB_MR_publish_url={type=string}, TEST_SUB_MR_subscribe_url={type=string}, service_component_name_override={type=string, default=}, testParam1={type=string, default=test-param-1}}
diff --git a/mod/bpgenerator/pom.xml b/mod/bpgenerator/pom.xml
index 86009f3..c8f8fdb 100644
--- a/mod/bpgenerator/pom.xml
+++ b/mod/bpgenerator/pom.xml
@@ -29,7 +29,7 @@
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.5.2-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath>
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
index 75864be..e9157ad 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
@@ -21,9 +21,15 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.models.blueprint.dmaap.DmaapObj;
import org.onap.blueprintgenerator.models.componentspec.CallsObj;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
@@ -31,125 +37,116 @@ import org.onap.blueprintgenerator.models.componentspec.Parameters;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-
-
-import lombok.Getter;
-import lombok.Setter;
-
@Getter
@Setter
public class Appconfig {
- private CallsObj[] service_calls;
- private TreeMap<String, DmaapObj> streams_publishes;
- private TreeMap<String, DmaapObj> streams_subscribes;
- private TreeMap<String, Object> params;
-
- @JsonAnyGetter
- public TreeMap<String, Object> getParams(){
- return params;
- }
-
- public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override,
- boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
-
- //set service calls
- CallsObj[] call = new CallsObj[0];
- this.setService_calls(call);
-
- //set the stream publishes
- TreeMap<String, DmaapObj> streamPublishes = new TreeMap<String, DmaapObj>();
- if(cs.getStreams().getPublishes().length != 0) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- if(p.getType().equals("data_router") || p.getType().equals("data router")) {
- //in this case the data router information gets added to the params so for now leave it alone
- String config = p.getConfig_key();
- DmaapObj pub = new DmaapObj();
- String name = p.getConfig_key() +"_feed";
- retInputs = pub.createOnapDmaapDRObj(retInputs, config, 'p', name, name, isDmaap);
- pub.setType(p.getType());
- streamPublishes.put(config, pub);
- } else if(p.getType().equals("message_router") || p.getType().equals("message router")) {
- String config = p.getConfig_key();
- DmaapObj pub = new DmaapObj();
- String name = p.getConfig_key() + "_topic";
- retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p', name, name, isDmaap);
- pub.setType(p.getType());
- streamPublishes.put(config, pub);
- }
- }
- }
-
- //set the stream publishes
- TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<>();
-
- if(cs.getStreams().getSubscribes().length != 0) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- if(s.getType().equals("data_router") || s.getType().equals("data router")) {
- //in this case the data router information gets added to the params so for now leave it alone
- String config = s.getConfig_key();
- DmaapObj sub = new DmaapObj();
- String name = s.getConfig_key() + "_feed";
- retInputs = sub.createOnapDmaapDRObj(retInputs, config, 'p', name, name, isDmaap);
- sub.setType(s.getType());
- streamSubscribes.put(config, sub);
- } else if(s.getType().equals("message_router") || s.getType().equals("message router")) {
- String config = s.getConfig_key();
- DmaapObj sub = new DmaapObj();
- String name = s.getConfig_key() + "_topic";
- retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's', name, name, isDmaap);
- sub.setType(s.getType());
- streamSubscribes.put(config, sub);
- }
- }
- }
-
- this.setStreams_publishes(streamPublishes);
- this.setStreams_subscribes(streamSubscribes);
-
- //set the parameters into the appconfig
- TreeMap<String, Object> parameters = new TreeMap<>();
- for(Parameters p: cs.getParameters()) {
- String pName = p.getName();
- if(p.isSourced_at_deployment()) {
- GetInput paramInput = new GetInput();
- paramInput.setBpInputName(pName);
- parameters.put(pName, paramInput);
-
- if(!p.getValue().equals("")) {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
- inputs.put("type", "string");
- inputs.put("default", p.getValue());
- retInputs.put(pName, inputs);
- } else {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
- inputs.put("type", "string");
- retInputs.put(pName, inputs);
- }
- } else {
- if("string".equals(p.getType())) {
- String val =(String) p.getValue();
- val = '"' + val + '"';
- parameters.put(pName, val);
- }
- else {
- parameters.put(pName, p.getValue());
- }
- }
- }
- if(override != null) {
- GetInput ov = new GetInput();
- ov.setBpInputName("service_component_name_override");
- parameters.put("service_component_name_override", ov);
- LinkedHashMap<String, Object> over = new LinkedHashMap<>();
- over.put("type", "string");
- over.put("default", override);
- retInputs.put("service_component_name_override", over);
- }
- this.setParams(parameters);
- return retInputs;
- }
+ private CallsObj[] service_calls;
+ private TreeMap<String, DmaapObj> streams_publishes;
+ private TreeMap<String, DmaapObj> streams_subscribes;
+ private TreeMap<String, Object> params;
+
+ @JsonAnyGetter
+ public TreeMap<String, Object> getParams() {
+ return params;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override,
+ boolean isDmaap) {
+
+ service_calls = new CallsObj[0];
+ streams_publishes = createStreamPublishes(componentSpec, inps, isDmaap);
+ streams_subscribes = createStreamSubscribes(componentSpec, inps, isDmaap);
+ params = createParameters(componentSpec, inps, override);
+
+ return inps;
+ }
+
+ private TreeMap<String, DmaapObj> createStreamPublishes(ComponentSpec componentSpec,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, boolean isDmaap) {
+ TreeMap<String, DmaapObj> streamPublishes = new TreeMap<>();
+ for (Publishes publishes : componentSpec.getStreams().getPublishes()) {
+ String config = publishes.getConfig_key();
+ DmaapObj pub = new DmaapObj();
+ if (isDataRouterType(publishes.getType())) {
+ //in this case the data router information gets added to the params so for now leave it alone
+ String name = publishes.getConfig_key() + "_feed";
+ pub.createOnapDmaapDRObj(inps, config, 'p', name, name, isDmaap);
+ } else if (isMessageRouterType(publishes.getType())) {
+ String name = publishes.getConfig_key() + "_topic";
+ pub.createOnapDmaapMRObj(inps, config, 'p', name, name, isDmaap);
+ }
+ pub.setType(publishes.getType());
+ streamPublishes.put(config, pub);
+ }
+ return streamPublishes;
+ }
+
+ private TreeMap<String, DmaapObj> createStreamSubscribes(ComponentSpec componentSpec,
+ TreeMap<String, LinkedHashMap<String, Object>> inputs, boolean isDmaap) {
+ TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<>();
+ for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) {
+ String config = subscribes.getConfig_key();
+ DmaapObj sub = new DmaapObj();
+ if (isDataRouterType(subscribes.getType())) {
+ //in this case the data router information gets added to the params so for now leave it alone
+ String name = subscribes.getConfig_key() + "_feed";
+ sub.createOnapDmaapDRObj(inputs, config, 'p', name, name, isDmaap);
+ } else if (isMessageRouterType(subscribes.getType())) {
+ String name = subscribes.getConfig_key() + "_topic";
+ sub.createOnapDmaapMRObj(inputs, config, 's', name, name, isDmaap);
+ }
+ sub.setType(subscribes.getType());
+ streamSubscribes.put(config, sub);
+ }
+ return streamSubscribes;
+ }
+
+ private TreeMap<String, Object> createParameters(ComponentSpec componentSpec,
+ TreeMap<String, LinkedHashMap<String, Object>> inputs,
+ String override) {
+ TreeMap<String, Object> parameters = new TreeMap<>();
+ for (Parameters params : componentSpec.getParameters()) {
+ String pName = params.getName();
+ if (params.isSourced_at_deployment()) {
+ GetInput paramInput = new GetInput();
+ paramInput.setBpInputName(pName);
+ parameters.put(pName, paramInput);
+
+ if (!params.getValue().equals("")) {
+ LinkedHashMap<String, Object> input = createStringInput(params.getValue());
+ inputs.put(pName, input);
+ } else {
+ LinkedHashMap<String, Object> input = new LinkedHashMap<>();
+ input.put("type", "string");
+ inputs.put(pName, input);
+ }
+ } else {
+ if ("string".equals(params.getType())) {
+ String val = (String) params.getValue();
+ val = '"' + val + '"';
+ parameters.put(pName, val);
+ } else {
+ parameters.put(pName, params.getValue());
+ }
+ }
+ }
+ handleOverride(override, parameters, inputs);
+ return parameters;
+ }
+
+ private void handleOverride(String override, TreeMap<String, Object> parameters,
+ TreeMap<String, LinkedHashMap<String, Object>> inps) {
+ if (override != null) {
+ GetInput ov = new GetInput();
+ ov.setBpInputName("service_component_name_override");
+ parameters.put("service_component_name_override", ov);
+ LinkedHashMap<String, Object> over = new LinkedHashMap<>();
+ over.put("type", "string");
+ over.put("default", override);
+ inps.put("service_component_name_override", over);
+ }
+ }
}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java
new file mode 100644
index 0000000..173d230
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java
@@ -0,0 +1,62 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 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.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.blueprint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+import org.junit.Test;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+
+public class AppconfigTest {
+
+ @Test
+ public void createAppconfigShouldReturnExpectedResult() throws FileNotFoundException {
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ TreeMap<String, LinkedHashMap<String, Object>> result = new Appconfig().createAppconfig(inputs, cs, "", false);
+
+ assertEquals(getExpectedStringFromFile(), result.toString());
+ }
+
+ private String getExpectedStringFromFile() throws FileNotFoundException {
+ File file = new File("TestCases/expects/createAppConfigResult.txt");
+ InputStream inputStream = new FileInputStream(file);
+ return readFromInputStream(inputStream);
+ }
+
+ private String readFromInputStream(InputStream inputStream) {
+ return new BufferedReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8))
+ .lines()
+ .collect(Collectors.joining(""));
+ }
+}
diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties
index 3f9d877..eabef1f 100644
--- a/mod/bpgenerator/version.properties
+++ b/mod/bpgenerator/version.properties
@@ -1,6 +1,6 @@
major=1
-minor=5
-patch=2
+minor=6
+patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT
diff --git a/mod/runtimeapi/pom.xml b/mod/runtimeapi/pom.xml
index 112a9d7..2243250 100644
--- a/mod/runtimeapi/pom.xml
+++ b/mod/runtimeapi/pom.xml
@@ -34,7 +34,7 @@ limitations under the License.
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
<name>dcaegen2-platform-mod-runtimeapi</name>
<description>MOD Runtime API</description>
<properties>
diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml
index 15eda39..349e654 100644
--- a/mod/runtimeapi/runtime-core/pom.xml
+++ b/mod/runtimeapi/runtime-core/pom.xml
@@ -25,12 +25,12 @@ limitations under the License.
<parent>
<artifactId>runtimeapi</artifactId>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>runtime-core</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
<dependencies>
<dependency>
@@ -46,7 +46,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.5.1</version>
+ <version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml
index 6842cba..8c0ab9d 100644
--- a/mod/runtimeapi/runtime-web/pom.xml
+++ b/mod/runtimeapi/runtime-web/pom.xml
@@ -24,10 +24,10 @@ limitations under the License.
<parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
</parent>
<artifactId>runtime-web</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>runtime-web</name>
<description>MOD Runtime Web Module</description>
@@ -35,7 +35,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtime-core</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/mod2/auth-service/Dockerfile b/mod2/auth-service/Dockerfile
index aa8707f..b125fc0 100644
--- a/mod2/auth-service/Dockerfile
+++ b/mod2/auth-service/Dockerfile
@@ -11,4 +11,4 @@ COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} .
ENTRYPOINT ["java", \
"-Djava.security.egd=file:/dev/./urandom", \
- "-jar", "auth-service-1.0.0-SNAPSHOT.jar"] \ No newline at end of file
+ "-jar", "mod-auth-service.jar"] \ No newline at end of file
diff --git a/mod2/auth-service/pom.xml b/mod2/auth-service/pom.xml
index 75782f4..3723584 100644
--- a/mod2/auth-service/pom.xml
+++ b/mod2/auth-service/pom.xml
@@ -40,7 +40,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<dockerfile-maven-plugin.version>1.4.10</dockerfile-maven-plugin.version>
- <docker.image.name>${project.groupId}.${project.artifactId}</docker.image.name>
+ <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
</properties>
<dependencies>
diff --git a/mod2/auth-service/src/main/resources/application.properties b/mod2/auth-service/src/main/resources/application.properties
index f3f5d37..f02d084 100644
--- a/mod2/auth-service/src/main/resources/application.properties
+++ b/mod2/auth-service/src/main/resources/application.properties
@@ -22,8 +22,7 @@
server.port=8082
-#spring.data.mongodb.host=mongo_db
-spring.data.mongodb.host=localhost
+spring.data.mongodb.host=mongo_db
#spring.data.mongodb.host=zlecdyh2bdcc1s2dokr05.ec53e7.dyh2b.tci.att.com
spring.data.mongodb.port=27017
spring.data.mongodb.database=dcae_mod
diff --git a/mod2/catalog-service/pom.xml b/mod2/catalog-service/pom.xml
index 37aaf46..fee27ec 100644
--- a/mod2/catalog-service/pom.xml
+++ b/mod2/catalog-service/pom.xml
@@ -38,10 +38,16 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>2.2.9.RELEASE</spring-boot.version>
<dockerfile-maven-plugin.version>1.4.10</dockerfile-maven-plugin.version>
- <docker.image.name>${project.groupId}.${project.artifactId}</docker.image.name>
+ <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
</properties>
<dependencies>
<dependency>
+ <groupId>org.onap.dcaegen2.platform.mod</groupId>
+ <artifactId>blueprint-generator</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/blueprintgenerator/DeploymentArtifactGenerator.java
index 24c31ed..5d7668d 100644
--- a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/blueprintgenerator/DeploymentArtifactGenerator.java
@@ -18,19 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.dcaegen2.platform.mod.mock;
+package org.onap.dcaegen2.platform.mod.blueprintgenerator;
+import com.google.gson.Gson;
+import org.onap.blueprintgenerator.models.blueprint.Blueprint;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.dcaegen2.platform.mod.model.specification.Specification;
import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGeneratorStrategy;
import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
import java.util.Map;
/**
* Mock implementation for DeploymentArtifactGenerator
*/
@Component
-public class MockDeploymentArtifactGenerator implements DeploymentArtifactGeneratorStrategy {
+public class DeploymentArtifactGenerator implements DeploymentArtifactGeneratorStrategy {
/**
* null implementation.
@@ -38,8 +43,19 @@ public class MockDeploymentArtifactGenerator implements DeploymentArtifactGenera
* @param release
* @return
*/
- @Override
+
+ @Override
public Map<String, Object> generateForRelease(Specification activeSpec, String release) {
- return null;
+
+ ComponentSpec inboundComponentSpec = new ComponentSpec();
+ inboundComponentSpec.createComponentSpecFromString(new Gson().toJson(activeSpec.getSpecContent()));
+
+ Blueprint blueprint = new Blueprint().createBlueprint(inboundComponentSpec,"",'d',"","");
+
+ Map<String, Object> modifiedResponse = new HashMap<>();
+ modifiedResponse.put("content", blueprint.blueprintToString());
+ modifiedResponse.put("fileName", "filenamePlaceholder" + ".yaml");
+ return modifiedResponse;
}
+
}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java
index 749d8b1..9074650 100644
--- a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java
@@ -25,8 +25,11 @@ import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifac
import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.DeploymentArtifactNotFound;
import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother;
import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -36,6 +39,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.*;
@@ -99,6 +103,19 @@ class DeploymentArtifactServiceImplTest {
}
@Test
+ void test_GenerateForRelease_shouldReturnCorrectBlueprint(){
+ Specification specification = SpecificationObjectMother.getMockSpecification(DeploymentType.K8S);
+ when(deploymentArtifactGeneratorStrategy.generateForRelease(specification, "")).thenReturn(DeploymentArtifactObjectMother.createBlueprintResponse());
+ Map<String, Object> response = deploymentArtifactGeneratorStrategy.generateForRelease(specification, "");
+ verify(deploymentArtifactGeneratorStrategy, atLeastOnce()).generateForRelease(specification,"");
+ assertThat(response).isNotNull();
+ assertThat(response.get("content")).isNotNull();
+ assertThat(response.get("fileName")).isNotNull();
+ assertThat((String)response.get("content")).contains("tosca_definitions_version");
+
+ }
+
+ @Test
void test_GenerateBlueprint_shouldReturnCorrectBlueprint() throws Exception{
setupMockBehaviours();