summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2020-06-26 12:56:51 +0200
committerTomasz Wrobel <tomasz.wrobel@nokia.com>2020-08-10 09:18:18 +0200
commitbc2e6287569ed6a848acf31b26097f54934baf9b (patch)
tree2d974bbd9c74ea586a69c94ceeea3e17e15c085d
parente996e07eea9189ffd89418047eb26293ef33e419 (diff)
Add factories for Ext tls parameters
Code cleanup, renames Issue-ID: DCAEGEN2-2251 Change-Id: Ibf36780473480210bea1c76d117b28c71831487a Signed-off-by: kjaniak <kornel.janiak@nokia.com> Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java37
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java51
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java14
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java12
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java99
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java153
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java481
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java13
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java107
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java (renamed from mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java)23
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java74
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java102
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java38
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java (renamed from mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java)6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java37
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java43
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java54
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java19
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java809
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java21
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java62
24 files changed, 1306 insertions, 976 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
new file mode 100644
index 0000000..16eca51
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
@@ -0,0 +1,37 @@
+/*============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.common.blueprint;
+
+
+import lombok.experimental.UtilityClass;
+
+import java.util.LinkedHashMap;
+
+@UtilityClass
+public class BlueprintHelper {
+
+ public static LinkedHashMap<String, Object> createInputValue(String type, String description, Object defaultValue) {
+ LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
+ inputMap.put("type", type);
+ inputMap.put("description", description);
+ inputMap.put("default", defaultValue);
+ return inputMap;
+ }
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java
index a22d588..7c3193e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -19,6 +20,11 @@
*/
package org.onap.blueprintgenerator.core;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
import org.onap.blueprintgenerator.exception.DatabasesNotFoundException;
import org.onap.blueprintgenerator.models.GetAttribute;
import org.onap.blueprintgenerator.models.blueprint.GetInput;
@@ -27,7 +33,7 @@ import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNode;
import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNodeProperties;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import java.util.*;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue;
public class PgaasNodeBuilder {
@@ -39,29 +45,22 @@ public class PgaasNodeBuilder {
private static final String DB_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on";
-
- public static void addPgaasNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate, TreeMap<String, LinkedHashMap<String, Object>> inps) {
+ public static void addPgaasNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate,
+ TreeMap<String, LinkedHashMap<String, Object>> inps) {
TreeMap<String, String> databases = cs.getAuxilary().getDatabases();
- if(databases == null){
+ if (databases == null) {
throw new DatabasesNotFoundException("databases section not found in componentspec");
}
- for(Map.Entry<String, String> database : databases.entrySet()){
+ for (Map.Entry<String, String> database : databases.entrySet()) {
addPgaasNode(database, nodeTemplate);
addPgaasInputs(database, inps);
}
}
- private static void addPgaasInputs(Map.Entry<String, String> database, TreeMap<String, LinkedHashMap<String, Object>> inps) {
- inps.put(database.getKey() + NAME_POSTFIX, getInputValue("string", "db name", ""));
- inps.put(database.getKey() + WRITER_FQDN_POSTFIX, getInputValue("string", "db writerfqdn", ""));
- }
-
- private static LinkedHashMap<String, Object> getInputValue(String type, String description, Object defaultValue) {
- LinkedHashMap<String, Object> inputValueMap = new LinkedHashMap();
- inputValueMap.put("type", type);
- inputValueMap.put("description", description);
- inputValueMap.put("default", defaultValue);
- return inputValueMap;
+ private static void addPgaasInputs(Map.Entry<String, String> database,
+ TreeMap<String, LinkedHashMap<String, Object>> inps) {
+ inps.put(database.getKey() + NAME_POSTFIX, createInputValue("string", "db name", ""));
+ inps.put(database.getKey() + WRITER_FQDN_POSTFIX, createInputValue("string", "db writerfqdn", ""));
}
private static void addPgaasNode(Map.Entry<String, String> database, TreeMap<String, Node> nodeTemplate) {
@@ -69,18 +68,18 @@ public class PgaasNodeBuilder {
String dbName = database.getKey();
pgaasNode.setType(PGAAS_NODE_TYPE);
pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName));
- nodeTemplate.put(dbName + PGAAS_NODE_NAME_POSTFIX , pgaasNode);
+ nodeTemplate.put(dbName + PGAAS_NODE_NAME_POSTFIX, pgaasNode);
}
private static PgaasNodeProperties buildPgaasNodeProperties(String dbName) {
PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties();
GetInput nameValue = new GetInput();
- nameValue.setGet_input(dbName + NAME_POSTFIX);
+ nameValue.setBpInputName(dbName + NAME_POSTFIX);
pgaasNodeProperties.setName(nameValue);
GetInput writerfqdnValue = new GetInput();
- writerfqdnValue.setGet_input(dbName + WRITER_FQDN_POSTFIX);
+ writerfqdnValue.setBpInputName(dbName + WRITER_FQDN_POSTFIX);
pgaasNodeProperties.setWriterfqdn(writerfqdnValue);
pgaasNodeProperties.setUseExisting(USE_EXISTING);
@@ -90,7 +89,7 @@ public class PgaasNodeBuilder {
public static ArrayList<LinkedHashMap<String, String>> getPgaasNodeRelationships(ComponentSpec cs) {
ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>();
- for(Map.Entry<String, String> database : cs.getAuxilary().getDatabases().entrySet()){
+ for (Map.Entry<String, String> database : cs.getAuxilary().getDatabases().entrySet()) {
LinkedHashMap<String, String> relationship = new LinkedHashMap<>();
relationship.put("type", DB_RELATIONSHIP_TYPE);
relationship.put("target", database.getKey() + PGAAS_NODE_NAME_POSTFIX);
@@ -101,23 +100,23 @@ public class PgaasNodeBuilder {
public static LinkedHashMap<String, Object> getEnvVariables(TreeMap<String, String> databases) {
LinkedHashMap<String, Object> envVariables = new LinkedHashMap<String, Object>();
- for(Map.Entry<String, String> database : databases.entrySet()){
+ for (Map.Entry<String, String> database : databases.entrySet()) {
String name = database.getKey().toUpperCase();
envVariables.put("<<", "*envs");
GetInput nameValue = new GetInput();
- nameValue.setGet_input(name.toLowerCase() + NAME_POSTFIX);
+ nameValue.setBpInputName(name.toLowerCase() + NAME_POSTFIX);
envVariables.put(name + "_DB_NAME", nameValue);
GetAttribute adminHostValue = buildGetAttributeValue(name.toLowerCase(), "admin", "host");
- envVariables.put( name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue);
+ envVariables.put(name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue);
GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user");
- envVariables.put( name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue);
+ envVariables.put(name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue);
GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password");
- envVariables.put( name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue);
+ envVariables.put(name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue);
}
return envVariables;
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java
index a947ab7..1c3713b 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -36,9 +37,10 @@ public class PolicyNodeBuilder {
private static final String POLICY_NODE_TYPE = "clamp.nodes.policy";
private static final String POLICY_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on";
- public static void addPolicyNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate, TreeMap<String, LinkedHashMap<String, Object>> inps) {
+ public static void addPolicyNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate,
+ TreeMap<String, LinkedHashMap<String, Object>> inps) {
List<TypePolicy> policyList = cs.getPolicyInfo().getTypePolicyList();
- for(TypePolicy policy: policyList){
+ for (TypePolicy policy : policyList) {
addPolicyNodesToNodeTemplate(policy, nodeTemplate);
addPolicyInputs(policy, inps);
}
@@ -54,7 +56,7 @@ public class PolicyNodeBuilder {
inputValueMap.put("type", type);
inputValueMap.put("description", description);
inputValueMap.put("default", defaultValue);
- return inputValueMap;
+ return inputValueMap;
}
private static void addPolicyNodesToNodeTemplate(TypePolicy policy, TreeMap<String, Node> nodeTemplate) {
@@ -68,7 +70,7 @@ public class PolicyNodeBuilder {
PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties();
GetInput policyIdGetInput = new GetInput();
- policyIdGetInput.setGet_input(policy.getNode_label() + "_policy_id");
+ policyIdGetInput.setBpInputName(policy.getNode_label() + "_policy_id");
policyNodeProperties.setPolicyId(policyIdGetInput);
policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id());
@@ -79,7 +81,7 @@ public class PolicyNodeBuilder {
public static ArrayList<LinkedHashMap<String, String>> getPolicyRelationships(ComponentSpec cs) {
ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>();
List<TypePolicy> policyList = cs.getPolicyInfo().getTypePolicyList();
- for(TypePolicy policy: policyList){
+ for (TypePolicy policy : policyList) {
LinkedHashMap<String, String> relationship = new LinkedHashMap<>();
relationship.put("type", POLICY_RELATIONSHIP_TYPE);
relationship.put("target", policy.getNode_label());
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 04745dc..b39a8ec 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
@@ -1,8 +1,9 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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
@@ -23,6 +24,7 @@ package org.onap.blueprintgenerator.models.blueprint;
import java.util.LinkedHashMap;
import java.util.TreeMap;
+import org.onap.blueprintgenerator.models.blueprint.dmaap.DmaapObj;
import org.onap.blueprintgenerator.models.componentspec.CallsObj;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Parameters;
@@ -113,7 +115,7 @@ public class Appconfig {
String pName = p.getName();
if(p.isSourced_at_deployment()) {
GetInput paramInput = new GetInput();
- paramInput.setGet_input(pName);
+ paramInput.setBpInputName(pName);
parameters.put(pName, paramInput);
if(!p.getValue().equals("")) {
@@ -139,7 +141,7 @@ public class Appconfig {
}
if(override != null) {
GetInput ov = new GetInput();
- ov.setGet_input("service_component_name_override");
+ ov.setBpInputName("service_component_name_override");
parameters.put("service_component_name_override", ov);
LinkedHashMap<String, Object> over = new LinkedHashMap<String, Object>();
over.put("type", "string");
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java
deleted file mode 100644
index 97dafc7..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. 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 java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.Getter; import lombok.Setter;
-
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
-public class DmaapInfo {
- private GetInput topic_url;
- private GetInput username;
- private GetInput password;
- private GetInput location;
- private GetInput delivery_url;
- private GetInput subscriber_id;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRInfo(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
- stringType.put("type", "string");
-
- config = config.replaceAll("-", "_");
- if(type == 'p') {
- config = config + "_publish_url";
- }
- else if(type == 's') {
- config = config+ "_subscribe_url";
- }
-
- GetInput topic = new GetInput();
- topic.setGet_input(config);
- this.setTopic_url(topic);
-
- retInputs.put(config, stringType);
-
- return retInputs;
- }
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRInfo(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
- stringType.put("type", "string");
-
- GetInput username = new GetInput();
- username.setGet_input(config + "_" + "username");
- this.setUsername(username);
- retInputs.put(config + "_" + "username", stringType);
-
- GetInput password = new GetInput();
- password.setGet_input(config + "_" + "password");
- this.setPassword(password);
- retInputs.put(config + "_" + "password", stringType);
-
- GetInput location = new GetInput();
- location.setGet_input(config + "_" + "location");
- this.setLocation(location);
- retInputs.put(config + "_" + "location", stringType);
-
- GetInput deliveryUrl = new GetInput();
- deliveryUrl.setGet_input(config + "_" + "delivery_url");
- this.setDelivery_url(deliveryUrl);
- retInputs.put(config + "_" + "delivery_url", stringType);
-
- GetInput subscriberID = new GetInput();
- subscriberID.setGet_input(config + "_" + "subscriber_id");
- this.setSubscriber_id(subscriberID);
- retInputs.put(config + "_" + "subscriber_id", stringType);
-
-
- return retInputs;
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java
deleted file mode 100644
index cf97dec..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**============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 com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-@Getter
-@Setter
-@NoArgsConstructor
-public class ExternalTlsInfo {
-
- static final String USE_EXTERNAL_TLS_FIELD = "use_external_tls";
-
- private static final String DEFAULT_CA = "RA";
- private static final Object DEFAULT_CERT_TYPE = "P12";
-
- private static final String INPUT_PREFIX = "external_cert_";
- private static final String EXTERNAL_CERT_DIRECTORY_FIELD = "external_cert_directory";
- private static final String CA_NAME_FIELD = "ca_name";
- private static final String CERT_TYPE_FIELD = "cert_type";
- private static final String EXTERNAL_CERTIFICATE_PARAMETERS_FIELD = "external_certificate_parameters";
-
- @JsonProperty(EXTERNAL_CERT_DIRECTORY_FIELD)
- private String externalCertDirectory;
-
- @JsonProperty(USE_EXTERNAL_TLS_FIELD)
- private GetInput useExternalTls;
-
- @JsonProperty(CA_NAME_FIELD)
- private GetInput caName;
-
- @JsonProperty(CERT_TYPE_FIELD)
- private GetInput certType;
-
- @JsonProperty(EXTERNAL_CERTIFICATE_PARAMETERS_FIELD)
- private ExternalCertificateParameters externalCertificateParameters;
-
- static ExternalTlsInfo createFromComponentSpec(ComponentSpec cs) {
- ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
- TreeMap<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
-
- externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get("cert_directory"));
- externalTlsInfoBp.setUseExternalTls(createGetInput(USE_EXTERNAL_TLS_FIELD));
- externalTlsInfoBp.setCaName(createGetInput(CA_NAME_FIELD));
- externalTlsInfoBp.setCertType(createGetInput(CERT_TYPE_FIELD));
-
- ExternalCertificateParameters externalCertificateParameters =
- ExternalCertificateParameters.create();
- externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParameters);
-
- return externalTlsInfoBp;
- }
-
- static Map<String, LinkedHashMap<String, Object>> createInputMapFromComponentSpec(ComponentSpec cs){
- Map<String, LinkedHashMap<String, Object>> retInputs = new HashMap<>();
-
- Map<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
- LinkedHashMap<String, Object> useTlsFlagInput = Properties.makeInput("boolean",
- "Flag to indicate external tls enable/disable.",
- tlsInfoCs.get(USE_EXTERNAL_TLS_FIELD));
- retInputs.put(addPrefix(USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
-
- LinkedHashMap<String, Object> caNameInputMap = Properties.makeInput("string",
- "Name of Certificate Authority configured on CertService side.",
- DEFAULT_CA);
- retInputs.put(addPrefix(CA_NAME_FIELD), caNameInputMap);
-
- LinkedHashMap<String, Object> certTypeInputMap = Properties.makeInput("string",
- "Format of provided certificates",
- DEFAULT_CERT_TYPE);
- retInputs.put(addPrefix(CERT_TYPE_FIELD), certTypeInputMap);
-
- retInputs.putAll(ExternalCertificateParameters.createInputMap());
- return retInputs;
- }
-
- private static GetInput createGetInput(String fieldName) {
- return new GetInput(addPrefix(fieldName));
- }
-
- private static String addPrefix(String fieldName) {
- return INPUT_PREFIX + fieldName;
- }
-
- @Getter
- @Setter
- @NoArgsConstructor
- public static class ExternalCertificateParameters {
-
- private static final String DEFAULT_COMMON_NAME = "sample.onap.org";
- private static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org";
-
- private static final String COMMON_NAME_FIELD = "common_name";
- private static final String SANS_FIELD = "sans";
-
- @JsonProperty(COMMON_NAME_FIELD)
- private GetInput commonName;
-
- @JsonProperty(SANS_FIELD)
- private GetInput sans;
-
-
- private static ExternalCertificateParameters create() {
- ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters();
- externalCertificateParameters.setCommonName(createGetInput(COMMON_NAME_FIELD));
- externalCertificateParameters.setSans(createGetInput(SANS_FIELD));
- return externalCertificateParameters;
- }
-
- private static Map<String, LinkedHashMap<String, Object>> createInputMap(){
- Map<String, LinkedHashMap<String, Object>> retInputs = new LinkedHashMap<>();
-
- LinkedHashMap<String, Object> commonNameInputMap = Properties.makeInput("string",
- "Common name which should be present in certificate.",
- DEFAULT_COMMON_NAME);
- retInputs.put(addPrefix(COMMON_NAME_FIELD), commonNameInputMap);
-
- LinkedHashMap<String, Object> sansInputMap = Properties.makeInput("string",
- "\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
- "Delimiter - : Should contain common_name value and other FQDNs under which given " +
- "component is accessible.\"",
- DEFAULT_SANS);
- retInputs.put(addPrefix(SANS_FIELD), sansInputMap);
- return retInputs;
- }
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
index 351c2b2..3d5ca3d 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
@@ -1,9 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ 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.
@@ -22,6 +21,7 @@
package org.onap.blueprintgenerator.models.blueprint;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -33,5 +33,6 @@ import lombok.Setter;
@AllArgsConstructor
public class GetInput {
- private Object get_input;
+ @JsonProperty("get_input")
+ private Object bpInputName;
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
index d7947f8..5087066 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
@@ -1,15 +1,14 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ 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
+ 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,
@@ -21,167 +20,183 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
-
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.blueprintgenerator.common.blueprint.BlueprintHelper;
+import org.onap.blueprintgenerator.models.blueprint.tls.ExternalCertificateParametersFactory;
+import org.onap.blueprintgenerator.models.blueprint.tls.ExternalTlsInfoFactory;
+import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo;
import org.onap.blueprintgenerator.models.componentspec.Auxilary;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.Getter;
-import lombok.Setter;
-
@Getter
@Setter
@JsonInclude(value = Include.NON_NULL)
public class Properties {
- private Appconfig application_config;
- private Auxilary docker_config;
- private Object image;
- private GetInput location_id;
- private String service_component_type;
- private TreeMap<String, Object> log_info;
- private String dns_name;
- private Object replicas;
- private String name;
- private GetInput topic_name;
- private GetInput feed_name;
- ArrayList<DmaapStreams> streams_publishes;
- ArrayList<DmaapStreams> streams_subscribes;
- private TlsInfo tls_info;
- private ExternalTlsInfo external_cert;
- private ResourceConfig resource_config;
- private GetInput always_pull_image;
- //private boolean useExisting;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
- //set the image
- GetInput image = new GetInput();
- image.setGet_input("image");
- this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("image", img);
-
- //set the location id
- GetInput location = new GetInput();
- location.setGet_input("location_id");
- this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
-
- //set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
-
- //set the replicas
- GetInput replica = new GetInput();
- replica.setGet_input("replicas");
- this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = makeInput("integer", "number of instances", 1);
- retInputs.put("replicas", rep);
-
- //set the dns name
- //this.setDns_name(cs.getSelf().getName());
-
- //set the name
- //this.setName(cs.getSelf().getName());
-
- //set the docker config
- Auxilary aux = cs.getAuxilary();
+
+ private Appconfig application_config;
+ private Auxilary docker_config;
+ private Object image;
+ private GetInput location_id;
+ private String service_component_type;
+ private TreeMap<String, Object> log_info;
+ private String dns_name;
+ private Object replicas;
+ private String name;
+ private GetInput topic_name;
+ private GetInput feed_name;
+ ArrayList<DmaapStreams> streams_publishes;
+ ArrayList<DmaapStreams> streams_subscribes;
+ private TlsInfo tls_info;
+ private ExternalTlsInfo external_cert;
+ private ResourceConfig resource_config;
+ private GetInput always_pull_image;
+ //private boolean useExisting;
+ private ExternalTlsInfoFactory externalCertFactory;
+
+ public Properties() {
+ ExternalCertificateParametersFactory externalCertificateDataFactory = new ExternalCertificateParametersFactory();
+ externalCertFactory = new ExternalTlsInfoFactory(externalCertificateDataFactory);
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+
+ //set the image
+ GetInput image = new GetInput();
+ image.setBpInputName("image");
+ this.setImage(image);
+ LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
+ img.put("type", "string");
+ img.put("default", cs.getArtifacts()[0].getUri());
+ retInputs.put("image", img);
+
+ //set the location id
+ GetInput location = new GetInput();
+ location.setBpInputName("location_id");
+ this.setLocation_id(location);
+ LinkedHashMap<String, Object> locMap = new LinkedHashMap();
+ locMap.put("type", "string");
+ locMap.put("default", "");
+ retInputs.put("location_id", locMap);
+
+ //set the log info
+ this.setLog_info(cs.getAuxilary().getLog_info());
+
+ //set the replicas
+ GetInput replica = new GetInput();
+ replica.setBpInputName("replicas");
+ this.setReplicas(replica);
+ LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ retInputs.put("replicas", rep);
+
+ //set the dns name
+ //this.setDns_name(cs.getSelf().getName());
+
+ //set the name
+ //this.setName(cs.getSelf().getName());
+
+ //set the docker config
+ Auxilary aux = cs.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
- this.setDocker_config(aux);
-
- //set the app config
- Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, false);
- this.setApplication_config(app);
-
- // set always_pull_image
- this.always_pull_image = new GetInput();
- this.always_pull_image.setGet_input("always_pull_image");
- LinkedHashMap<String, Object> inputAlwaysPullImage = makeInput("boolean",
- "Set to true if the image should always be pulled",
- true);
- retInputs.put("always_pull_image", inputAlwaysPullImage);
-
-
- //set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
-
- //set the tls info for internal and external communication
- if (cs.getAuxilary().getTls_info() != null) {
- addTlsInfo(cs, retInputs);
- addExternalTlsInfo(cs, retInputs);
- }
-
- //set the reource config
- ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
- this.setResource_config(resource);
-
- return retInputs;
- }
-
- public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
- //set the image
- GetInput image = new GetInput();
- image.setGet_input("tag_version");
- this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("tag_version", img);
-
-
- //set the location id
- GetInput location = new GetInput();
- location.setGet_input("location_id");
- this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
-
- //set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
-
- //set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
-
- //set the tls info for internal and external communication
- if (cs.getAuxilary().getTls_info() != null) {
- addTlsInfo(cs, retInputs);
- addExternalTlsInfo(cs, retInputs);
- }
-
- //set the replicas
- GetInput replica = new GetInput();
- replica.setGet_input("replicas");
- this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = makeInput("integer", "number of instances", 1);
- retInputs.put("replicas", rep);
+ this.setDocker_config(aux);
+
+ //set the app config
+ Appconfig app = new Appconfig();
+ retInputs = app.createAppconfig(retInputs, cs, override, false);
+ this.setApplication_config(app);
+
+ // set always_pull_image
+ this.always_pull_image = new GetInput();
+ this.always_pull_image.setBpInputName("always_pull_image");
+ LinkedHashMap<String, Object> inputAlwaysPullImage = BlueprintHelper.createInputValue("boolean",
+ "Set to true if the image should always be pulled",
+ true);
+ retInputs.put("always_pull_image", inputAlwaysPullImage);
+
+ //set service component type
+ String sType = cs.getSelf().getName();
+ sType = sType.replace('.', '-');
+ this.setService_component_type(sType);
+
+ //set the tls info for internal and external communication
+ TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ if (tls_info != null) {
+ addTlsInfo(cs, retInputs);
+ if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
+ retInputs.putAll(addExternalTlsInfo(cs));
+ }
+ }
+
+ //set the reource config
+ ResourceConfig resource = new ResourceConfig();
+ retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ this.setResource_config(resource);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ retInputs = inps;
+
+ //set the image
+ GetInput image = new GetInput();
+ image.setBpInputName("tag_version");
+ this.setImage(image);
+ LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
+ img.put("type", "string");
+ img.put("default", cs.getArtifacts()[0].getUri());
+ retInputs.put("tag_version", img);
+
+ //set the location id
+ GetInput location = new GetInput();
+ location.setBpInputName("location_id");
+ this.setLocation_id(location);
+ LinkedHashMap<String, Object> locMap = new LinkedHashMap();
+ locMap.put("type", "string");
+ locMap.put("default", "");
+ retInputs.put("location_id", locMap);
+
+ //set the log info
+ this.setLog_info(cs.getAuxilary().getLog_info());
+
+ //set service component type
+ String sType = cs.getSelf().getName();
+ sType = sType.replace('.', '-');
+ this.setService_component_type(sType);
+
+ //set the tls info for internal and external communication
+ TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ if (tls_info != null) {
+ addTlsInfo(cs, retInputs);
+ if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
+ retInputs.putAll(addExternalTlsInfo(cs));
+ }
+ }
+
+ //set the replicas
+ GetInput replica = new GetInput();
+ replica.setBpInputName("replicas");
+ this.setReplicas(replica);
+ LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ retInputs.put("replicas", rep);
// //set the dns name
// this.setDns_name(cs.getSelf().getName());
@@ -189,95 +204,89 @@ public class Properties {
// //set the name
// this.setName(cs.getSelf().getName());
- //set the docker config
- Auxilary aux = cs.getAuxilary();
+ //set the docker config
+ Auxilary aux = cs.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
- this.setDocker_config(aux);
-
- //set the appconfig
- Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, true);
- this.setApplication_config(app);
-
- //set the stream publishes
- ArrayList<DmaapStreams> pubStreams = new ArrayList();
- if (cs.getStreams().getPublishes() != null) {
- for (Publishes p : cs.getStreams().getPublishes()) {
- if (p.getType().equals("message_router") || p.getType().equals("message router")) {
- String topic = p.getConfig_key() + "_topic";
- DmaapStreams mrStreams = new DmaapStreams();
- retInputs = mrStreams.createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
- pubStreams.add(mrStreams);
- } else if (p.getType().equals("data_router") || p.getType().equals("data router")) {
- String feed = p.getConfig_key() + "_feed";
- DmaapStreams drStreams = new DmaapStreams();
- retInputs = drStreams.createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
- pubStreams.add(drStreams);
- }
- }
- }
-
- //set the stream subscribes
- ArrayList<DmaapStreams> subStreams = new ArrayList();
- if (cs.getStreams().getSubscribes() != null) {
- for (Subscribes s : cs.getStreams().getSubscribes()) {
- if (s.getType().equals("message_router") || s.getType().equals("message router")) {
- String topic = s.getConfig_key() + "_topic";
- DmaapStreams mrStreams = new DmaapStreams();
- retInputs = mrStreams.createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
- subStreams.add(mrStreams);
- } else if (s.getType().equals("data_router") || s.getType().equals("data router")) {
- String feed = s.getConfig_key() + "_feed";
- DmaapStreams drStreams = new DmaapStreams();
- retInputs = drStreams.createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
- subStreams.add(drStreams);
- }
- }
- }
-
- if (pubStreams.size() != 0) {
- this.setStreams_publishes(pubStreams);
- }
- if (subStreams.size() != 0) {
- this.setStreams_subscribes(subStreams);
- }
-
- //set the reource config
- ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
- this.setResource_config(resource);
-
-
- return retInputs;
- }
-
- private void addTlsInfo(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> retInputs) {
- TlsInfo tlsInfo = new TlsInfo();
- tlsInfo.setCertDirectory((String) cs.getAuxilary().getTls_info().get("cert_directory"));
- GetInput useTLSFlag = new GetInput();
- useTLSFlag.setGet_input("use_tls");
- tlsInfo.setUseTls(useTLSFlag);
- this.setTls_info(tlsInfo);
- LinkedHashMap<String, Object> useTlsFlagInput = makeInput("boolean",
- "flag to indicate tls enable/disable",
- cs.getAuxilary().getTls_info().get("use_tls"));
- retInputs.put("use_tls", useTlsFlagInput);
- }
-
- private void addExternalTlsInfo(ComponentSpec cs, Map<String, LinkedHashMap<String, Object>> retInputs) {
- if(cs.getAuxilary().getTls_info().get(ExternalTlsInfo.USE_EXTERNAL_TLS_FIELD) == null)
- return;
- this.setExternal_cert(ExternalTlsInfo.createFromComponentSpec(cs));
- retInputs.putAll(ExternalTlsInfo.createInputMapFromComponentSpec(cs));
- }
-
- static LinkedHashMap<String, Object> makeInput(String type, String description, Object defaultValue) {
- LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
- inputMap.put("type", type);
- inputMap.put("description", description);
- inputMap.put("default", defaultValue);
- return inputMap;
- }
+ this.setDocker_config(aux);
+
+ //set the appconfig
+ Appconfig app = new Appconfig();
+ retInputs = app.createAppconfig(retInputs, cs, override, true);
+ this.setApplication_config(app);
+
+ //set the stream publishes
+ ArrayList<DmaapStreams> pubStreams = new ArrayList();
+ if (cs.getStreams().getPublishes() != null) {
+ for (Publishes p : cs.getStreams().getPublishes()) {
+ if (p.getType().equals("message_router") || p.getType().equals("message router")) {
+ String topic = p.getConfig_key() + "_topic";
+ DmaapStreams mrStreams = new DmaapStreams();
+ retInputs = mrStreams
+ .createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ pubStreams.add(mrStreams);
+ } else if (p.getType().equals("data_router") || p.getType().equals("data router")) {
+ String feed = p.getConfig_key() + "_feed";
+ DmaapStreams drStreams = new DmaapStreams();
+ retInputs = drStreams
+ .createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ pubStreams.add(drStreams);
+ }
+ }
+ }
+
+ //set the stream subscribes
+ ArrayList<DmaapStreams> subStreams = new ArrayList();
+ if (cs.getStreams().getSubscribes() != null) {
+ for (Subscribes s : cs.getStreams().getSubscribes()) {
+ if (s.getType().equals("message_router") || s.getType().equals("message router")) {
+ String topic = s.getConfig_key() + "_topic";
+ DmaapStreams mrStreams = new DmaapStreams();
+ retInputs = mrStreams
+ .createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ subStreams.add(mrStreams);
+ } else if (s.getType().equals("data_router") || s.getType().equals("data router")) {
+ String feed = s.getConfig_key() + "_feed";
+ DmaapStreams drStreams = new DmaapStreams();
+ retInputs = drStreams
+ .createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ subStreams.add(drStreams);
+ }
+ }
+ }
+
+ if (pubStreams.size() != 0) {
+ this.setStreams_publishes(pubStreams);
+ }
+ if (subStreams.size() != 0) {
+ this.setStreams_subscribes(subStreams);
+ }
+
+ //set the reource config
+ ResourceConfig resource = new ResourceConfig();
+ retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ this.setResource_config(resource);
+
+ return retInputs;
+ }
+
+ private void addTlsInfo(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> retInputs) {
+ TlsInfo tlsInfo = new TlsInfo();
+ tlsInfo.setCertDirectory((String) cs.getAuxilary().getTls_info().get("cert_directory"));
+ GetInput useTLSFlag = new GetInput();
+ useTLSFlag.setBpInputName("use_tls");
+ tlsInfo.setUseTls(useTLSFlag);
+ this.setTls_info(tlsInfo);
+ LinkedHashMap<String, Object> useTlsFlagInput = BlueprintHelper.createInputValue("boolean",
+ "flag to indicate tls enable/disable",
+ cs.getAuxilary().getTls_info().get("use_tls"));
+ retInputs.put("use_tls", useTlsFlagInput);
+ }
+
+ private Map<String, LinkedHashMap<String, Object>> addExternalTlsInfo(ComponentSpec cs) {
+ this.setExternal_cert(externalCertFactory.createFromComponentSpec(cs));
+ return externalCertFactory.createInputListFromComponentSpec(cs);
+ }
+
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
index f1a9a17..13aa0d0 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -23,8 +24,6 @@ package org.onap.blueprintgenerator.models.blueprint;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@@ -91,11 +90,11 @@ public class ResourceConfig {
TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
GetInput cpu = new GetInput();
- cpu.setGet_input(name + "cpu_limit");
+ cpu.setBpInputName(name + "cpu_limit");
lim.put("cpu", cpu);
GetInput memL = new GetInput();
- memL.setGet_input(name + "memory_limit");
+ memL.setBpInputName(name + "memory_limit");
lim.put("memory", memL);
retInputs.put(name + "cpu_limit", m);
@@ -107,11 +106,11 @@ public class ResourceConfig {
TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
GetInput cpuR = new GetInput();
- cpuR.setGet_input(name + "cpu_request");
+ cpuR.setBpInputName(name + "cpu_request");
req.put("cpu", cpuR);
GetInput memR = new GetInput();
- memR.setGet_input(name + "memory_request");
+ memR.setBpInputName(name + "memory_request");
req.put("memory", memR);
retInputs.put(name + "cpu_request", m);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
index f81bf9a..1055fbd 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
@@ -1,8 +1,9 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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
@@ -106,7 +107,7 @@ public class StartInputs {
}
else {
GetInput env = new GetInput();
- env.setGet_input("envs");
+ env.setBpInputName("envs");
this.setEnvs(env);
eMap.put("default", "{}");
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
new file mode 100644
index 0000000..464fc4a
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
@@ -0,0 +1,107 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.dmaap;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
+
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
+public class DmaapInfo {
+
+ private static final String UNDERSCORE = "_";
+
+ private GetInput topic_url;
+ private GetInput username;
+ private GetInput password;
+ private GetInput location;
+ private GetInput delivery_url;
+ private GetInput subscriber_id;
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRInfo(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ stringType.put("type", "string");
+
+ config = config.replaceAll("-", "_");
+ if (type == 'p') {
+ config = config + "_publish_url";
+ } else if (type == 's') {
+ config = config + "_subscribe_url";
+ }
+
+ GetInput topic = new GetInput();
+ topic.setBpInputName(config);
+ this.setTopic_url(topic);
+
+ retInputs.put(config, stringType);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRInfo(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
+ stringType.put("type", "string");
+
+ String userNameInputName = createInputName(config, "username");
+ GetInput username = new GetInput(userNameInputName);
+ this.setUsername(username);
+ retInputs.put(userNameInputName, stringType);
+
+ String passwordInputName = createInputName(config, "password");
+ GetInput password = new GetInput(passwordInputName);
+ this.setPassword(password);
+ retInputs.put(passwordInputName, stringType);
+
+ String locationInputName = createInputName(config, "location");
+ GetInput location = new GetInput(locationInputName);
+ this.setLocation(location);
+ retInputs.put(locationInputName, stringType);
+
+ String deliveryUrlInputName = createInputName(config, "delivery_url");
+ GetInput deliveryUrl = new GetInput(deliveryUrlInputName);
+ this.setDelivery_url(deliveryUrl);
+ retInputs.put(deliveryUrlInputName, stringType);
+
+ String subscriberIdInputName = createInputName(config, "subscriber_id");
+ GetInput subscriberID = new GetInput(subscriberIdInputName);
+ this.setSubscriber_id(subscriberID);
+ retInputs.put(subscriberIdInputName, stringType);
+
+ return retInputs;
+ }
+
+ private String createInputName(String config, String inputName) {
+ return config + UNDERSCORE + inputName;
+ }
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
index 7d78e3d..6af69e5 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
@@ -1,8 +1,9 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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
@@ -18,15 +19,17 @@
*/
-package org.onap.blueprintgenerator.models.blueprint;
-
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
+package org.onap.blueprintgenerator.models.blueprint.dmaap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
+
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
-import lombok.Getter; import lombok.Setter;
@JsonInclude(value=Include.NON_NULL)
@Getter @Setter
public class DmaapObj {
@@ -53,13 +56,13 @@ public class DmaapObj {
this.setDmaap_info(infoType);
//set username
GetInput u = new GetInput();
- u.setGet_input(config + "_" + num +"_aaf_username");
+ u.setBpInputName(config + "_" + num +"_aaf_username");
this.setUser(u);
retInputs.put(config + "_" + num +"_aaf_username", stringType);
//set password
GetInput p = new GetInput();
- p.setGet_input(config + "_" + num +"_aaf_password");
+ p.setBpInputName(config + "_" + num +"_aaf_password");
this.setPass(p);
retInputs.put(config + "_" + num +"_aaf_password", stringType);
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java
new file mode 100644
index 0000000..546a809
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java
@@ -0,0 +1,74 @@
+/*============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.tls;
+
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_COMMON_NAME;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_SANS;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.onap.blueprintgenerator.models.blueprint.tls.api.ExternalCertificateDataFactory;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters;
+
+/**
+ * Factory class for providing parameters of ExternalCertificate. Allow to get ExternalCertificateParameters Object and
+ * input list
+ */
+public class ExternalCertificateParametersFactory extends ExternalCertificateDataFactory {
+
+ /**
+ * Create ExternalCertificateParameters Object
+ *
+ * @return ExternalCertificateParameters
+ */
+ public ExternalCertificateParameters create() {
+ ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters();
+ externalCertificateParameters.setCommonName(createPrefixedGetInput(COMMON_NAME_FIELD));
+ externalCertificateParameters.setSans(createPrefixedGetInput(SANS_FIELD));
+ return externalCertificateParameters;
+ }
+
+ /**
+ * Create input list for ExternalCertificateParameters
+ *
+ * @return Input list
+ */
+ public Map<String, LinkedHashMap<String, Object>> createInputList() {
+ Map<String, LinkedHashMap<String, Object>> retInputs = new LinkedHashMap<>();
+
+ LinkedHashMap<String, Object> commonNameInputMap = createInputValue("string",
+ "Common name which should be present in certificate.",
+ DEFAULT_COMMON_NAME);
+ retInputs.put(addPrefix(COMMON_NAME_FIELD), commonNameInputMap);
+
+ LinkedHashMap<String, Object> sansInputMap = createInputValue("string",
+ "\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
+ "Delimiter - : Should contain common_name value and other FQDNs under which given " +
+ "component is accessible.\"",
+ DEFAULT_SANS);
+ retInputs.put(addPrefix(SANS_FIELD), sansInputMap);
+
+ return retInputs;
+ }
+
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java
new file mode 100644
index 0000000..e954afc
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java
@@ -0,0 +1,102 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. 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.tls;
+
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CA_NAME_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_DIRECTORY_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_TYPE_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_CA;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_CERT_TYPE;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import org.onap.blueprintgenerator.models.blueprint.tls.api.ExternalCertificateDataFactory;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+
+/**
+ * Factory class for providing ExternalTlsInfo data. Allow to get ExternalTlsInfo Object and Inputs list.
+ */
+public class ExternalTlsInfoFactory extends ExternalCertificateDataFactory {
+
+ private ExternalCertificateParametersFactory externalCertificateParametersFactory;
+
+ /**
+ * Constructor for ExternalTlsInfoFactory
+ *
+ * @param externalCertificateDataFactory Factory providing external certificate parameters.
+ */
+ public ExternalTlsInfoFactory(ExternalCertificateParametersFactory externalCertificateDataFactory) {
+ this.externalCertificateParametersFactory = externalCertificateDataFactory;
+ }
+
+ /**
+ * Create ExternalTlsInfo from ComponentSpec Object
+ *
+ * @param cs ComponentSpec Object
+ * @return ExternalTlsInfo Object
+ */
+ public ExternalTlsInfo createFromComponentSpec(ComponentSpec cs) {
+ ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
+ TreeMap<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
+
+ externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get(CERT_DIRECTORY_FIELD));
+ externalTlsInfoBp.setUseExternalTls(createPrefixedGetInput(USE_EXTERNAL_TLS_FIELD));
+ externalTlsInfoBp.setCaName(createPrefixedGetInput(CA_NAME_FIELD));
+ externalTlsInfoBp.setCertType(createPrefixedGetInput(CERT_TYPE_FIELD));
+ externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParametersFactory.create());
+
+ return externalTlsInfoBp;
+ }
+
+ /**
+ * Create input list from ComponentSpec Object
+ *
+ * @param cs ComponentSpec Object
+ * @return Input list
+ */
+ public Map<String, LinkedHashMap<String, Object>> createInputListFromComponentSpec(ComponentSpec cs) {
+ Map<String, LinkedHashMap<String, Object>> retInputs = new HashMap<>();
+
+ Map<String, Object> externalTlsInfoCs = cs.getAuxilary().getTls_info();
+ LinkedHashMap<String, Object> useTlsFlagInput = createInputValue("boolean",
+ "Flag to indicate external tls enable/disable.",
+ externalTlsInfoCs.get(USE_EXTERNAL_TLS_FIELD));
+ retInputs.put(addPrefix(USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
+
+ LinkedHashMap<String, Object> caNameInputMap = createInputValue("string",
+ "Name of Certificate Authority configured on CertService side.",
+ DEFAULT_CA);
+ retInputs.put(addPrefix(CA_NAME_FIELD), caNameInputMap);
+
+ LinkedHashMap<String, Object> certTypeInputMap = createInputValue("string",
+ "Format of provided certificates",
+ DEFAULT_CERT_TYPE);
+ retInputs.put(addPrefix(CERT_TYPE_FIELD), certTypeInputMap);
+
+ retInputs.putAll(externalCertificateParametersFactory.createInputList());
+ return retInputs;
+ }
+
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java
new file mode 100644
index 0000000..cdbfd32
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java
@@ -0,0 +1,38 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. 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.tls;
+
+public class TlsConstants {
+
+ public static final String EXTERNAL_CERT_DIRECTORY_FIELD = "external_cert_directory";
+ public static final String CERT_DIRECTORY_FIELD = "cert_directory";
+ public static final String INPUT_PREFIX = "external_cert_";
+ public static final String USE_EXTERNAL_TLS_FIELD = "use_external_tls";
+ public static final String CA_NAME_FIELD = "ca_name";
+ public static final String EXTERNAL_CERTIFICATE_PARAMETERS_FIELD = "external_certificate_parameters";
+ public static final String COMMON_NAME_FIELD = "common_name";
+ public static final String SANS_FIELD = "sans";
+ public static final String CERT_TYPE_FIELD = "cert_type";
+
+ public static final String DEFAULT_CA = "RA";
+ public static final Object DEFAULT_CERT_TYPE = "P12";
+ public static final String DEFAULT_COMMON_NAME = "sample.onap.org";
+ public static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org";
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java
index 2130fe3..027f996 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -17,12 +18,13 @@
============LICENSE_END=========================================================
*/
-package org.onap.blueprintgenerator.models.blueprint;
+package org.onap.blueprintgenerator.models.blueprint.tls;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
@Getter
@Setter
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java
new file mode 100644
index 0000000..21b20e4
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java
@@ -0,0 +1,37 @@
+/*============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.tls.api;
+
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
+
+
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.INPUT_PREFIX;
+
+public abstract class ExternalCertificateDataFactory {
+
+ protected static GetInput createPrefixedGetInput(String fieldName) {
+ return new GetInput(addPrefix(fieldName));
+ }
+
+ protected static String addPrefix(String fieldName) {
+ return INPUT_PREFIX + fieldName;
+ }
+
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java
new file mode 100644
index 0000000..e3ccca1
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java
@@ -0,0 +1,43 @@
+/*============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.tls.impl;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
+
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD;
+
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class ExternalCertificateParameters {
+
+ @JsonProperty(COMMON_NAME_FIELD)
+ private GetInput commonName;
+
+ @JsonProperty(SANS_FIELD)
+ private GetInput sans;
+
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java
new file mode 100644
index 0000000..588dbb5
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java
@@ -0,0 +1,54 @@
+/*============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.tls.impl;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.blueprintgenerator.models.blueprint.GetInput;
+
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CA_NAME_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_TYPE_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.EXTERNAL_CERTIFICATE_PARAMETERS_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.EXTERNAL_CERT_DIRECTORY_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class ExternalTlsInfo {
+
+ @JsonProperty(EXTERNAL_CERT_DIRECTORY_FIELD)
+ private String externalCertDirectory;
+
+ @JsonProperty(USE_EXTERNAL_TLS_FIELD)
+ private GetInput useExternalTls;
+
+ @JsonProperty(CA_NAME_FIELD)
+ private GetInput caName;
+
+ @JsonProperty(CERT_TYPE_FIELD)
+ private GetInput certType;
+
+ @JsonProperty(EXTERNAL_CERTIFICATE_PARAMETERS_FIELD)
+ private ExternalCertificateParameters externalCertificateParameters;
+
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
index e84901c..37d7d2d 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -15,7 +16,6 @@
See the License for the specific language governing permissions and
limitations under the License.
============LICENSE_END=========================================================
-
*/
package org.onap.blueprintgenerator.models.dmaapbp;
@@ -33,7 +33,6 @@ import org.onap.blueprintgenerator.models.blueprint.Properties;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-import org.onap.blueprintgenerator.models.onapbp.OnapNode;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -129,7 +128,7 @@ public class DmaapNode extends Node{
//create and set the properties
Properties props = new Properties();
GetInput topicInput = new GetInput();
- topicInput.setGet_input(name + "_name");
+ topicInput.setBpInputName(name + "_name");
props.setFeed_name(topicInput);
//props.setUseExisting(true);
retInputs.put(name + "_name", stringType);
@@ -149,7 +148,7 @@ public class DmaapNode extends Node{
//create and set the properties
Properties props = new Properties();
GetInput topicInput = new GetInput();
- topicInput.setGet_input(name + "_name");
+ topicInput.setBpInputName(name + "_name");
props.setTopic_name(topicInput);
//props.setUseExisting(true);
retInputs.put(name + "_name", stringType);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
index b26d45d..e2847d7 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
@@ -1,7 +1,8 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -23,10 +24,8 @@ package org.onap.blueprintgenerator.models.dmaapbp;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-import org.onap.blueprintgenerator.models.blueprint.Appconfig;
import org.onap.blueprintgenerator.models.blueprint.GetInput;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -66,7 +65,7 @@ public class DmaapStreams {
//set the location
GetInput location = new GetInput();
- location.setGet_input(key + "_" + name + "_location");
+ location.setBpInputName(key + "_" + name + "_location");
retInputs.put(key + "_" + name + "_location", stringType);
this.setLocation(location);
@@ -75,25 +74,25 @@ public class DmaapStreams {
if(o == 's') {
//set the username
GetInput username = new GetInput();
- username.setGet_input(key + "_" + name + "_username");
+ username.setBpInputName(key + "_" + name + "_username");
this.setUsername(username);
retInputs.put(key + "_" + name + "_username", stringType);
//set the password
GetInput password = new GetInput();
- password.setGet_input(key + "_" + name + "_password");
+ password.setBpInputName(key + "_" + name + "_password");
this.setPassword(password);
retInputs.put(key + "_" + name + "_password", stringType);
//set privileged
GetInput priviliged = new GetInput();
- priviliged.setGet_input(key + "_" + name + "_priviliged");
+ priviliged.setBpInputName(key + "_" + name + "_priviliged");
this.setPrivileged(priviliged);
retInputs.put(key + "_" + name + "_priviliged", stringType);
//set decompress
GetInput decompress = new GetInput();
- decompress.setGet_input(key + "_" + name + "_decompress");
+ decompress.setBpInputName(key + "_" + name + "_decompress");
this.setDecompress(decompress);
retInputs.put(key + "_" + name + "_decompress", stringType);
@@ -110,10 +109,10 @@ public class DmaapStreams {
} else {
//set the client role
GetInput client = new GetInput();
- client.setGet_input(key + "_" + name + "_client_role");
+ client.setBpInputName(key + "_" + name + "_client_role");
this.setClient_role(client);
retInputs.put(key + "_" + name + "_client_role", stringType);
}
return retInputs;
}
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
index 4ebd23c..1c7e592 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
@@ -1,36 +1,39 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. 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=========================================================
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ 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.core;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -55,393 +58,401 @@ import org.onap.blueprintgenerator.models.componentspec.Volumes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapNode;
import org.onap.blueprintgenerator.models.onapbp.OnapNode;
import org.onap.blueprintgenerator.models.policymodel.PolicyModel;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
import picocli.CommandLine;
-
// TODO: Auto-generated Javadoc
+
/**
* The Class BlueprintGeneratorTest.
*/
public class BlueprintGeneratorTest {
- /**
- * Component spec test.
- *
- * @throws JsonParseException the json parse exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
-
- @Test
- public void componentSpecTest() throws JsonParseException, JsonMappingException, IOException {
-
- ComponentSpec spec = new ComponentSpec();
- TestComponentSpec test = new TestComponentSpec();
- spec.createComponentSpecFromString(test.getCs());
-
- //Manually fill a component spec object with the values from the file itself
- ComponentSpec manualSpec = new ComponentSpec();
-
- Self self = new Self();
- self.setComponent_type("docker");
- self.setDescription("Test component spec");
- self.setName("test.component.spec");
- self.setVersion("1.0.1");
- manualSpec.setSelf(self);
-
- //assertEquals(manualSpec.getSelf(), spec.getSelf());
-
- Services services = new Services();
- CallsObj[] calls = new CallsObj[0];
- ProvidesObj[] provides = new ProvidesObj[0];
- services.setCalls(calls);
- services.setProvides(provides);
- manualSpec.setServices(null);
-
- //assertEquals(manualSpec.getServices(), spec.getServices());
-
- Streams streams = new Streams();
- Publishes[] publishes = new Publishes[2];
- Publishes pub1 = new Publishes();
- pub1.setConfig_key("TEST-PUB-DR");
- pub1.setFormat("dataformat_Hello_World_PM");
- pub1.setType("data_router");
- pub1.setVersion("1.0.0");
-
- Publishes pub2 = new Publishes();
- pub2.setConfig_key("TEST-PUB-MR");
- pub2.setFormat("dataformat_Hello_World_PM");
- pub2.setType("message_router");
- pub2.setVersion("1.0.0");
- publishes[0] = pub1;
- publishes[1] = pub2;
- streams.setPublishes(publishes);
-
- Subscribes[] subscribes = new Subscribes[2];
- Subscribes sub1 = new Subscribes();
- sub1.setConfig_key("TEST-SUB-MR");
- sub1.setFormat("dataformat_Hello_World_PM");
- sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
- sub1.setType("message_router");
- sub1.setVersion("1.0.0");
-
- Subscribes sub2 = new Subscribes();
- sub2.setConfig_key("TEST-SUB-DR");
- sub2.setFormat("dataformat_Hello_World_PM");
- sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
- sub2.setType("data_router");
- sub2.setVersion("1.0.0");
- subscribes[0] = sub1;
- subscribes[1] = sub2;
- streams.setSubscribes(subscribes);
-
- manualSpec.setStreams(streams);
-
- //assertEquals(manualSpec.getStreams(), spec.getStreams());
-
- Parameters[] parameters = new Parameters[1];
- Parameters par1 = new Parameters();
- par1.setName("testParam1");
- par1.setValue("test-param-1");
- par1.setDescription("test parameter 1");
- par1.setSourced_at_deployment(true);
- par1.setDesigner_editable(true);
- par1.setPolicy_editable(true);
- par1.setPolicy_group("Test_Parameters");
- par1.setRequired(true);
- par1.setType("string");
- parameters[0] = par1;
-
- manualSpec.setParameters(parameters);
-
- //assertEquals(manualSpec.getParameters(), spec.getParameters());
-
- Auxilary auxilary = new Auxilary();
- HealthCheck healthcheck = new HealthCheck();
- healthcheck.setInterval("300s");
- healthcheck.setTimeout("120s");
- healthcheck.setScript("/etc/init.d/nagios status");
- healthcheck.setType("docker");
- auxilary.setHealthcheck(healthcheck);
-
- Volumes[] volumes = new Volumes[1];
- Volumes vol1 = new Volumes();
- Container con1 = new Container();
- con1.setBind("/opt/app/manager/config/hostname");
- Host host1 = new Host();
- host1.setPath("/etc/hostname");
- host1.setMode("ro");
- vol1.setContainer(con1);
- vol1.setHost(host1);
-
-
- volumes[0] = vol1;
-
- auxilary.setVolumes(volumes);
-
- ArrayList<Object> ports = new ArrayList();
- ports.add("80:90");
- ports.add("99:99");
-
- TreeMap<String, String> dataBases = new TreeMap<String, String>();
- dataBases.put("TestDB1", "PGaaS");
- dataBases.put("TestDB2", "PGaaS");
- auxilary.setDatabases(dataBases);
-
- Policy pol = new Policy();
- pol.setTrigger_type("docker");
- pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
- auxilary.setPolicy(pol);
-
- auxilary.setPorts(ports);
-
- manualSpec.setAuxilary(auxilary);
-
- //assertEquals(manualSpec.getAuxilary(), spec.getAuxilary());
-
- Artifacts[] artifacts = new Artifacts[1];
- Artifacts art = new Artifacts();
- art.setType("docker image");
- art.setUri("test.tester");
-
- artifacts[0] = art;
- manualSpec.setArtifacts(artifacts);
-
- //assertEquals(manualSpec.getArtifacts(), spec.getArtifacts());
- }
-
- /**
- * Tosca definition test.
- */
- @Test
- public void toscaDefinitionTest() {
- ComponentSpec cs = new ComponentSpec();
- TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- assertEquals(bp.getTosca_definitions_version(), "cloudify_dsl_1_3");
- }
-
- /**
- * Imports test.
- */
- @Test
- public void importsTest() {
- ComponentSpec cs = new ComponentSpec();
- TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- ArrayList<String> imps = new ArrayList<String>();
-
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
- assertEquals(bp.getImports(), imps);
- }
-
- @Test
- public void inputTest() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
-
- //mr inputs
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
- stringType.put("type", "string");
-
-
- //necessary inputs
- LinkedHashMap<String, Object> tag = new LinkedHashMap<String, Object>();
- tag.put("type", "string");
- String tester = "test.tester";
- tag.put("default", '"' + tester + '"');
- String tagVersion = "tag_version";
- inputs.put("tag_version", tag);
-
- inputs.put("log_directory", stringType);
-
- LinkedHashMap cert = new LinkedHashMap();
- cert.put("type", "string");
- cert.put("default", "");
- inputs.put("cert_directory", cert);
-
- LinkedHashMap<String, Object> env = new LinkedHashMap();
- env.put("default", "{}");
- inputs.put("envs", env);
-
- LinkedHashMap port = new LinkedHashMap();
- port.put("type", "string");
- port.put("description", "Kubernetes node port on which collector is exposed");
- port.put("default", "99");
- inputs.put("external_port", port);
-
- LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
- rep.put("type", "integer");
- rep.put("description", "number of instances");
- rep.put("default", 1);
- inputs.put("replicas", rep);
-
- LinkedHashMap<String, Object> aaf = new LinkedHashMap();
- aaf.put("type", "boolean");
- aaf.put("default", false);
- inputs.put("use_tls", aaf);
-
- //parmaeter input
- LinkedHashMap<String, Object> test = new LinkedHashMap<String, Object>();
- test.put("type", "string");
- String testParam = "test-param-1";
- test.put("default", '"' + testParam + '"');
- inputs.put("testParam1", test);
-
- //mr/dr inputs
- inputs.put("TEST-PUB-DR_feed0_client_role", stringType);
- inputs.put("TEST-PUB-DR_feed0_password", stringType);
- inputs.put("TEST-PUB-DR_feed0_username", stringType);
- inputs.put("TEST-PUB-MR_topic1_aaf_password", stringType);
- inputs.put("TEST-PUB-MR_topic1_aaf_username", stringType);
- inputs.put("TEST-PUB-MR_topic1_client_role", stringType);
- inputs.put("TEST-SUB-DR_feed1_client_role", stringType);
- inputs.put("TEST-SUB-DR_feed1_password", stringType);
- inputs.put("TEST-SUB-DR_feed1_username", stringType);
- inputs.put("TEST-SUB-MR_topic0_client_role", stringType);
- inputs.put("TEST-SUB-MR_topic2_aaf_password", stringType);
- inputs.put("TEST-SUB-MR_topic2_aaf_username", stringType);
- inputs.put("namespace", stringType);
- inputs.put("idn_fqdn", cert);
- inputs.put("feed0_name", stringType);
- inputs.put("feed1_name", stringType);
- inputs.put("topic0_name", stringType);
- inputs.put("topic1_name", stringType);
-
- LinkedHashMap<String, Object> cpu = new LinkedHashMap();
- cpu.put("type", "string");
- cpu.put("default", "250m");
- inputs.put("test.component.spec_cpu_limit", cpu);
- inputs.put("test.component.spec_cpu_request", cpu);
-
- LinkedHashMap<String, Object> mem = new LinkedHashMap();
- mem.put("type", "string");
- mem.put("default", "128Mi");
- inputs.put("test.component.spec_memory_limit", mem);
- inputs.put("test.component.spec_memory_request", mem);
-
- assertEquals(true, true);
- }
- @Test
- public void interfaceTest() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
-
- OnapNode testNode = new OnapNode();
-
- //set the type
- testNode.setType("dcae.nodes.ContainerizedServiceComponent");
-
- ArrayList<String> ports = new ArrayList<String>();
- ports.add("concat: [\"80:\", {get_input: external_port }]");
- ports.add("concat: [\"99:\", {get_input: external_port }]");
- assertEquals(true, true);
- }
-
- @Test
- public void parametersTest() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
-
- GetInput par = (GetInput) node.getProperties().getApplication_config().getParams().get("testParam1");
- assertEquals(par.getGet_input(), "testParam1");
- }
-
- @Test
- public void streamPublishesTest() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'o', "", "");
-
- OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
-
- boolean test = false;
- if(!node.getProperties().getApplication_config().getStreams_publishes().isEmpty()) {
- test = true;
- System.out.println("tst");
- }
-
- assertEquals(true, test);
- }
-
-
- @Test
- public void dmaapPluginTest() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- Blueprint bp = new Blueprint();
- bp = bp.createBlueprint(cs, "", 'd', "", "");
-
- DmaapNode dmaap = (DmaapNode) bp.getNode_templates().get("test.component.spec");
-
- //check if the stream publishes and subscribes are not null to see if the dmaap plugin was invoked properly
- boolean d = false;
-
- if(dmaap.getProperties().getStreams_publishes() != null || dmaap.getProperties().getStreams_subscribes() != null) {
- d = true;
- }
- assertEquals(true, d);
- }
-
- @Test
- public void testPrintInstructionsBlueprintCommand() {
- BlueprintCommand objUnderTest = new BlueprintCommand();
- CommandLine cli = new CommandLine(objUnderTest);
- PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class);
- ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
- cli.usage(mockStdOutWriter);
- verify(mockStdOutWriter, times(1)).print(any(Object.class));
-
- }
-
- @Test
- public void testPrintInstructionsPolicyCommand() {
- PolicyCommand objUnderTest = new PolicyCommand();
- CommandLine cli = new CommandLine(objUnderTest);
- PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class);
- ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
- cli.usage(mockStdOutWriter);
- verify(mockStdOutWriter, times(1)).print(any(Object.class));
- }
-
- @Test
- public void testPolicyModels() {
- ComponentSpec cs = new ComponentSpec();
- cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
-
- PolicyModel p = new PolicyModel();
- p.createPolicyModels(cs, "TestModels");
-
- assertEquals(true, true);
- }
+ /**
+ * Component spec test.
+ *
+ * @throws JsonParseException the json parse exception
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+
+ @Test
+ public void componentSpecTest() throws JsonParseException, JsonMappingException, IOException {
+
+ ComponentSpec spec = new ComponentSpec();
+ TestComponentSpec test = new TestComponentSpec();
+ spec.createComponentSpecFromString(test.getCs());
+
+ //Manually fill a component spec object with the values from the file itself
+ ComponentSpec manualSpec = new ComponentSpec();
+
+ Self self = new Self();
+ self.setComponent_type("docker");
+ self.setDescription("Test component spec");
+ self.setName("test.component.spec");
+ self.setVersion("1.0.1");
+ manualSpec.setSelf(self);
+
+ //assertEquals(manualSpec.getSelf(), spec.getSelf());
+
+ Services services = new Services();
+ CallsObj[] calls = new CallsObj[0];
+ ProvidesObj[] provides = new ProvidesObj[0];
+ services.setCalls(calls);
+ services.setProvides(provides);
+ manualSpec.setServices(null);
+
+ //assertEquals(manualSpec.getServices(), spec.getServices());
+
+ Streams streams = new Streams();
+ Publishes[] publishes = new Publishes[2];
+ Publishes pub1 = new Publishes();
+ pub1.setConfig_key("TEST-PUB-DR");
+ pub1.setFormat("dataformat_Hello_World_PM");
+ pub1.setType("data_router");
+ pub1.setVersion("1.0.0");
+
+ Publishes pub2 = new Publishes();
+ pub2.setConfig_key("TEST-PUB-MR");
+ pub2.setFormat("dataformat_Hello_World_PM");
+ pub2.setType("message_router");
+ pub2.setVersion("1.0.0");
+ publishes[0] = pub1;
+ publishes[1] = pub2;
+ streams.setPublishes(publishes);
+
+ Subscribes[] subscribes = new Subscribes[2];
+ Subscribes sub1 = new Subscribes();
+ sub1.setConfig_key("TEST-SUB-MR");
+ sub1.setFormat("dataformat_Hello_World_PM");
+ sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
+ sub1.setType("message_router");
+ sub1.setVersion("1.0.0");
+
+ Subscribes sub2 = new Subscribes();
+ sub2.setConfig_key("TEST-SUB-DR");
+ sub2.setFormat("dataformat_Hello_World_PM");
+ sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
+ sub2.setType("data_router");
+ sub2.setVersion("1.0.0");
+ subscribes[0] = sub1;
+ subscribes[1] = sub2;
+ streams.setSubscribes(subscribes);
+
+ manualSpec.setStreams(streams);
+
+ //assertEquals(manualSpec.getStreams(), spec.getStreams());
+
+ Parameters[] parameters = new Parameters[1];
+ Parameters par1 = new Parameters();
+ par1.setName("testParam1");
+ par1.setValue("test-param-1");
+ par1.setDescription("test parameter 1");
+ par1.setSourced_at_deployment(true);
+ par1.setDesigner_editable(true);
+ par1.setPolicy_editable(true);
+ par1.setPolicy_group("Test_Parameters");
+ par1.setRequired(true);
+ par1.setType("string");
+ parameters[0] = par1;
+
+ manualSpec.setParameters(parameters);
+
+ //assertEquals(manualSpec.getParameters(), spec.getParameters());
+
+ Auxilary auxilary = new Auxilary();
+ HealthCheck healthcheck = new HealthCheck();
+ healthcheck.setInterval("300s");
+ healthcheck.setTimeout("120s");
+ healthcheck.setScript("/etc/init.d/nagios status");
+ healthcheck.setType("docker");
+ auxilary.setHealthcheck(healthcheck);
+
+ Volumes[] volumes = new Volumes[1];
+ Volumes vol1 = new Volumes();
+ Container con1 = new Container();
+ con1.setBind("/opt/app/manager/config/hostname");
+ Host host1 = new Host();
+ host1.setPath("/etc/hostname");
+ host1.setMode("ro");
+ vol1.setContainer(con1);
+ vol1.setHost(host1);
+
+ volumes[0] = vol1;
+
+ auxilary.setVolumes(volumes);
+
+ ArrayList<Object> ports = new ArrayList();
+ ports.add("80:90");
+ ports.add("99:99");
+
+ TreeMap<String, String> dataBases = new TreeMap<String, String>();
+ dataBases.put("TestDB1", "PGaaS");
+ dataBases.put("TestDB2", "PGaaS");
+ auxilary.setDatabases(dataBases);
+
+ Policy pol = new Policy();
+ pol.setTrigger_type("docker");
+ pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
+ auxilary.setPolicy(pol);
+
+ auxilary.setPorts(ports);
+
+ manualSpec.setAuxilary(auxilary);
+
+ //assertEquals(manualSpec.getAuxilary(), spec.getAuxilary());
+
+ Artifacts[] artifacts = new Artifacts[1];
+ Artifacts art = new Artifacts();
+ art.setType("docker image");
+ art.setUri("test.tester");
+
+ artifacts[0] = art;
+ manualSpec.setArtifacts(artifacts);
+
+ //assertEquals(manualSpec.getArtifacts(), spec.getArtifacts());
+ }
+
+ /**
+ * Tosca definition test.
+ */
+ @Test
+ public void toscaDefinitionTest() {
+ ComponentSpec cs = new ComponentSpec();
+ TestComponentSpec test = new TestComponentSpec();
+ cs.createComponentSpecFromString(test.getCs());
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ assertEquals(bp.getTosca_definitions_version(), "cloudify_dsl_1_3");
+ }
+
+ /**
+ * Imports test.
+ */
+ @Test
+ public void importsTest() {
+ ComponentSpec cs = new ComponentSpec();
+ TestComponentSpec test = new TestComponentSpec();
+ cs.createComponentSpecFromString(test.getCs());
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ ArrayList<String> imps = new ArrayList<String>();
+
+ imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
+ imps.add(
+ "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
+ imps.add(
+ "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
+ assertEquals(bp.getImports(), imps);
+ }
+
+ @Test
+ public void inputTest() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+
+ //mr inputs
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ stringType.put("type", "string");
+
+ //necessary inputs
+ LinkedHashMap<String, Object> tag = new LinkedHashMap<String, Object>();
+ tag.put("type", "string");
+ String tester = "test.tester";
+ tag.put("default", '"' + tester + '"');
+ String tagVersion = "tag_version";
+ inputs.put("tag_version", tag);
+
+ inputs.put("log_directory", stringType);
+
+ LinkedHashMap cert = new LinkedHashMap();
+ cert.put("type", "string");
+ cert.put("default", "");
+ inputs.put("cert_directory", cert);
+
+ LinkedHashMap<String, Object> env = new LinkedHashMap();
+ env.put("default", "{}");
+ inputs.put("envs", env);
+
+ LinkedHashMap port = new LinkedHashMap();
+ port.put("type", "string");
+ port.put("description", "Kubernetes node port on which collector is exposed");
+ port.put("default", "99");
+ inputs.put("external_port", port);
+
+ LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
+ rep.put("type", "integer");
+ rep.put("description", "number of instances");
+ rep.put("default", 1);
+ inputs.put("replicas", rep);
+
+ LinkedHashMap<String, Object> aaf = new LinkedHashMap();
+ aaf.put("type", "boolean");
+ aaf.put("default", false);
+ inputs.put("use_tls", aaf);
+
+ //parmaeter input
+ LinkedHashMap<String, Object> test = new LinkedHashMap<String, Object>();
+ test.put("type", "string");
+ String testParam = "test-param-1";
+ test.put("default", '"' + testParam + '"');
+ inputs.put("testParam1", test);
+
+ //mr/dr inputs
+ inputs.put("TEST-PUB-DR_feed0_client_role", stringType);
+ inputs.put("TEST-PUB-DR_feed0_password", stringType);
+ inputs.put("TEST-PUB-DR_feed0_username", stringType);
+ inputs.put("TEST-PUB-MR_topic1_aaf_password", stringType);
+ inputs.put("TEST-PUB-MR_topic1_aaf_username", stringType);
+ inputs.put("TEST-PUB-MR_topic1_client_role", stringType);
+ inputs.put("TEST-SUB-DR_feed1_client_role", stringType);
+ inputs.put("TEST-SUB-DR_feed1_password", stringType);
+ inputs.put("TEST-SUB-DR_feed1_username", stringType);
+ inputs.put("TEST-SUB-MR_topic0_client_role", stringType);
+ inputs.put("TEST-SUB-MR_topic2_aaf_password", stringType);
+ inputs.put("TEST-SUB-MR_topic2_aaf_username", stringType);
+ inputs.put("namespace", stringType);
+ inputs.put("idn_fqdn", cert);
+ inputs.put("feed0_name", stringType);
+ inputs.put("feed1_name", stringType);
+ inputs.put("topic0_name", stringType);
+ inputs.put("topic1_name", stringType);
+
+ LinkedHashMap<String, Object> cpu = new LinkedHashMap();
+ cpu.put("type", "string");
+ cpu.put("default", "250m");
+ inputs.put("test.component.spec_cpu_limit", cpu);
+ inputs.put("test.component.spec_cpu_request", cpu);
+
+ LinkedHashMap<String, Object> mem = new LinkedHashMap();
+ mem.put("type", "string");
+ mem.put("default", "128Mi");
+ inputs.put("test.component.spec_memory_limit", mem);
+ inputs.put("test.component.spec_memory_request", mem);
+
+ assertEquals(true, true);
+ }
+
+ @Test
+ public void interfaceTest() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
+
+ OnapNode testNode = new OnapNode();
+
+ //set the type
+ testNode.setType("dcae.nodes.ContainerizedServiceComponent");
+
+ ArrayList<String> ports = new ArrayList<String>();
+ ports.add("concat: [\"80:\", {get_input: external_port }]");
+ ports.add("concat: [\"99:\", {get_input: external_port }]");
+ assertEquals(true, true);
+ }
+
+ @Test
+ public void parametersTest() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
+
+ GetInput par = (GetInput) node.getProperties().getApplication_config().getParams().get("testParam1");
+ assertEquals(par.getBpInputName(), "testParam1");
+ }
+
+ @Test
+ public void streamPublishesTest() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'o', "", "");
+
+ OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
+
+ boolean test = false;
+ if (!node.getProperties().getApplication_config().getStreams_publishes().isEmpty()) {
+ test = true;
+ System.out.println("tst");
+ }
+
+ assertEquals(true, test);
+ }
+
+ @Test
+ public void dmaapPluginTest() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", 'd', "", "");
+
+ DmaapNode dmaap = (DmaapNode) bp.getNode_templates().get("test.component.spec");
+
+ //check if the stream publishes and subscribes are not null to see if the dmaap plugin was invoked properly
+ boolean d = false;
+
+ if (dmaap.getProperties().getStreams_publishes() != null
+ || dmaap.getProperties().getStreams_subscribes() != null) {
+ d = true;
+ }
+ assertEquals(true, d);
+ }
+
+ @Test
+ public void testPrintInstructionsBlueprintCommand() {
+ BlueprintCommand objUnderTest = new BlueprintCommand();
+ CommandLine cli = new CommandLine(objUnderTest);
+ PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class);
+ ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+ cli.usage(mockStdOutWriter);
+ verify(mockStdOutWriter, times(1)).print(any(Object.class));
+
+ }
+
+ @Test
+ public void testPrintInstructionsPolicyCommand() {
+ PolicyCommand objUnderTest = new PolicyCommand();
+ CommandLine cli = new CommandLine(objUnderTest);
+ PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class);
+ ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+ cli.usage(mockStdOutWriter);
+ verify(mockStdOutWriter, times(1)).print(any(Object.class));
+ }
+
+ @Test
+ public void testPolicyModels() {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile("TestCases/testComponentSpec.json");
+
+ PolicyModel p = new PolicyModel();
+ p.createPolicyModels(cs, "TestModels");
+
+ assertEquals(true, true);
+ }
+
+ private void assertContainsInputWithDefault(Blueprint bp, String inputName, Object defaultValue) {
+ LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
+ assertNotNull(input);
+ assertEquals(defaultValue, input.get("default"));
+ }
+
+ private String inQuotes(String filedName) {
+ return String.format("\"%s\"", filedName);
+ }
}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java
index 6bd7b40..8adf03d 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java
@@ -1,4 +1,4 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2020 Nokia. All rights reserved.
@@ -23,9 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
-import org.onap.blueprintgenerator.models.blueprint.ExternalTlsInfo;
import org.onap.blueprintgenerator.models.blueprint.Node;
-import org.onap.blueprintgenerator.models.blueprint.TlsInfo;
+import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import java.util.Arrays;
@@ -95,16 +96,16 @@ public class TlsInfoTest {
ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert();
assertNotNull(externalTlsInfo);
- assertEquals("external_cert_ca_name", externalTlsInfo.getCaName().getGet_input());
- assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getGet_input());
- assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getGet_input());
+ assertEquals("external_cert_ca_name", externalTlsInfo.getCaName().getBpInputName());
+ assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getBpInputName());
+ assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getBpInputName());
assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory());
- ExternalTlsInfo.ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters();
+ ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters();
assertNotNull(extCertParams);
- assertEquals("external_cert_common_name", extCertParams.getCommonName().getGet_input());
- assertEquals("external_cert_sans", extCertParams.getSans().getGet_input());
+ assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName());
+ assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName());
}
private void assertBlueprintContainsTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) {
@@ -115,7 +116,7 @@ public class TlsInfoTest {
//should create proper tlsInfo object in node properties
TlsInfo tlsInfo = node.getProperties().getTls_info();
- assertEquals("use_tls", tlsInfo.getUseTls().getGet_input());
+ assertEquals("use_tls", tlsInfo.getUseTls().getBpInputName());
assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory());
}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java
new file mode 100644
index 0000000..e854b19
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java
@@ -0,0 +1,62 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. 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.tls;
+
+import org.junit.Test;
+import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_COMMON_NAME;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_SANS;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.INPUT_PREFIX;
+import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD;
+
+public class ExternalCertificateParametersFactoryTest {
+
+ private static final String PREFIXED_COMMON_NAME_FIELD = INPUT_PREFIX + COMMON_NAME_FIELD;
+ private static final String PREFIXED_SANS_FIELD = INPUT_PREFIX + SANS_FIELD;
+ private static final String DEFAULT = "default";
+
+ @Test
+ public void shouldCreateExternalCertificatePropertiesObject() {
+ // given
+ ExternalCertificateParametersFactory cut = new ExternalCertificateParametersFactory();
+ // when
+ ExternalCertificateParameters result = cut.create();
+ // then
+ assertEquals(result.getCommonName().getBpInputName(), PREFIXED_COMMON_NAME_FIELD);
+ assertEquals(result.getSans().getBpInputName(), PREFIXED_SANS_FIELD);
+ }
+
+ @Test
+ public void shouldCreateCorrectInputListWithDefaultValuesTakenFromComponentSpec() {
+ // given
+ ExternalCertificateParametersFactory cut = new ExternalCertificateParametersFactory();
+ // when
+ Map<String, LinkedHashMap<String, Object>> result = cut.createInputList();
+ // then
+ assertEquals(DEFAULT_COMMON_NAME, result.get(PREFIXED_COMMON_NAME_FIELD).get(DEFAULT));
+ assertEquals(DEFAULT_SANS, result.get(PREFIXED_SANS_FIELD).get(DEFAULT));
+ }
+}