summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java40
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java60
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java104
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java129
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java42
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java92
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java270
7 files changed, 0 insertions, 737 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java
deleted file mode 100644
index 4775825..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java
+++ /dev/null
@@ -1,40 +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.core;
-
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-
-@Command(subcommands = {
- BlueprintCommand.class,
- PolicyCommand.class
-})
-public class App implements Runnable {
- public static void main(String...args) {
- CommandLine.run(new App(), args);
- }
-
- @Override
- public void run() {
- CommandLine.usage(this, System.out);
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java
deleted file mode 100644
index 7627930..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.blueprintgenerator.core;
-
-import org.onap.blueprintgenerator.models.blueprint.Blueprint;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "blueprint", description = "Command used to generate blueprints from component spec")
-public class BlueprintCommand implements Runnable {
- private static final char STANDARD_BLUEPRINT = 'o';
- private static final char DMAAP_BLUEPRINT = 'd';
-
- @Option(names = {"-i", "--component-spec"}, description = "Path to component spec file", required = true)
- private String componentSpecPath;
-
- @Option(names = {"-p", "--blueprint-path"}, description = "Path to directory that blueprints are output to", required = true)
- private String blueprintOutputPath;
-
- @Option(names = {"-n", "--blueprint-name"}, description = "Name of the blueprint", defaultValue = "")
- private String blueprintName;
-
- @Option(names = {"-t", "--imports"}, description = "Path to the import file", defaultValue = "")
- private String importsPath;
-
- @Option(names={"-o", "--service-name-override"}, description="Value used to override the service name", defaultValue = "")
- private String serviceNameOverride;
-
- @Option(names={"-d", "--dmaap-plugin"}, description = "Flag used to indicate blueprint uses the DMaaP plugin.")
- private boolean dmaapPlugin;
-
- @Override
- public void run() {
- ComponentSpec inboundComponentSpec = new ComponentSpec();
- inboundComponentSpec.createComponentSpecFromFile(componentSpecPath);
- System.out.println(dmaapPlugin ? DMAAP_BLUEPRINT : STANDARD_BLUEPRINT);
- Blueprint generatedBlueprint = new Blueprint().createBlueprint(inboundComponentSpec, this.blueprintName,
- dmaapPlugin ? DMAAP_BLUEPRINT : STANDARD_BLUEPRINT, importsPath, serviceNameOverride);
- generatedBlueprint.blueprintToYaml(blueprintOutputPath, this.blueprintName, inboundComponentSpec);
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java
deleted file mode 100644
index 3a4b457..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java
+++ /dev/null
@@ -1,104 +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.core;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Fixes {
- private static ArrayList<String> lines = new ArrayList<String>();
- private static String line = null;
-
- public static void fixSingleQuotes(File f) throws IOException {
- File translateFile = f;
- try {
- FileReader fr = new FileReader(translateFile);
- BufferedReader br = new BufferedReader(fr);
- while((line = br.readLine()) != null) {
-// lines.add(ensureNoSingleQuotes(line));
- if(line.contains("'")) {
- line = line.replace("'", "");
- }
- if(line.contains("\"\"") && (line.contains("m") || line.contains("M"))) {
- line = line.replaceAll("\"\"", "\"");
- }
- lines.add(line);
-
- }
- fr.close();
- br.close();
- FileWriter fw = new FileWriter(translateFile);
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f, true)));
- for(String s: lines) {
- out.println();
- out.write(s);
- out.flush();
- }
-
- out.close();
- fw.close();
- line = null;
- lines = new ArrayList<String>();
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Remove single quotes from a line from a blueprint
- */
- private static String ensureNoSingleQuotes(String line) {
- // TODO: Should probably use regex instead
- // REVIEW: The condition under which to remove the single quotes
- if ((line.contains("concat") || line.contains("default: ")) && line.contains("'")) {
- return line.replace("'", "");
- } else {
- return line;
- }
- }
-
- /**
- * Takes in an entire blueprint (YAML) in a string buffer and post processes it to apply
- * "fixes" like removing unwanted single quotes.
- */
- public static String applyFixes(String bp) {
- List<String> lines = new ArrayList<String>();
-
- String[] linesPre = bp.split("\n");
- System.out.println(String.format("To post-processing #lines: %d", linesPre.length));
-
- for (String line : linesPre) {
- lines.add(ensureNoSingleQuotes(line));
- }
-
- return String.join("\n", lines);
- }
-
-
-}
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
deleted file mode 100644
index 7c3193e..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*============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.
- 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 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;
-import org.onap.blueprintgenerator.models.blueprint.Node;
-import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNode;
-import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNodeProperties;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-
-import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue;
-
-public class PgaasNodeBuilder {
-
- private static final String PGAAS_NODE_TYPE = "dcae.nodes.pgaas.database";
- private static final String PGAAS_NODE_NAME_POSTFIX = "_pgaasdb";
- private static final String WRITER_FQDN_POSTFIX = "_database_writerfqdn";
- private static final String NAME_POSTFIX = "_database_name";
- private static final boolean USE_EXISTING = true;
- 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) {
- TreeMap<String, String> databases = cs.getAuxilary().getDatabases();
- if (databases == null) {
- throw new DatabasesNotFoundException("databases section not found in componentspec");
- }
- 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, 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) {
- PgaasNode pgaasNode = new PgaasNode();
- String dbName = database.getKey();
- pgaasNode.setType(PGAAS_NODE_TYPE);
- pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName));
- nodeTemplate.put(dbName + PGAAS_NODE_NAME_POSTFIX, pgaasNode);
- }
-
- private static PgaasNodeProperties buildPgaasNodeProperties(String dbName) {
- PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties();
-
- GetInput nameValue = new GetInput();
- nameValue.setBpInputName(dbName + NAME_POSTFIX);
- pgaasNodeProperties.setName(nameValue);
-
- GetInput writerfqdnValue = new GetInput();
- writerfqdnValue.setBpInputName(dbName + WRITER_FQDN_POSTFIX);
- pgaasNodeProperties.setWriterfqdn(writerfqdnValue);
-
- pgaasNodeProperties.setUseExisting(USE_EXISTING);
-
- return pgaasNodeProperties;
- }
-
- 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()) {
- LinkedHashMap<String, String> relationship = new LinkedHashMap<>();
- relationship.put("type", DB_RELATIONSHIP_TYPE);
- relationship.put("target", database.getKey() + PGAAS_NODE_NAME_POSTFIX);
- relationships.add(relationship);
- }
- return relationships;
- }
-
- 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()) {
- String name = database.getKey().toUpperCase();
-
- envVariables.put("<<", "*envs");
-
- GetInput nameValue = new GetInput();
- 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);
-
- GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user");
- envVariables.put(name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue);
-
- GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password");
- envVariables.put(name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue);
- }
- return envVariables;
- }
-
- private static GetAttribute buildGetAttributeValue(String dbName, String owner, String type) {
- GetAttribute attribute = new GetAttribute();
- attribute.setAttribute(Arrays.asList(dbName + PGAAS_NODE_NAME_POSTFIX, owner, type));
- return attribute;
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java
deleted file mode 100644
index 81a7911..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.blueprintgenerator.core;
-
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.policymodel.PolicyModel;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "policy", description = "Command used to generate policy model from component spec")
-public class PolicyCommand implements Runnable{
- @Option(names = {"-i", "--component-spec"}, description = "Path to component spec file", required = true)
- private String componentSpecPath;
-
- @Option(names = {"-p", "--model-path"}, description = "Path to directory that models are output to", required = true)
- private String modelOutputPath;
-
- @Override
- public void run() {
- ComponentSpec inboundComponentSpec = new ComponentSpec();
- inboundComponentSpec.createComponentSpecFromFile(componentSpecPath);
- new PolicyModel().createPolicyModels(inboundComponentSpec, this.modelOutputPath);
- }
-}
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
deleted file mode 100644
index 1c3713b..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*============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 org.onap.blueprintgenerator.models.blueprint.GetInput;
-import org.onap.blueprintgenerator.models.blueprint.Node;
-import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNode;
-import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNodeProperties;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.policy_info.TypePolicy;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.TreeMap;
-
-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) {
- List<TypePolicy> policyList = cs.getPolicyInfo().getTypePolicyList();
- for (TypePolicy policy : policyList) {
- addPolicyNodesToNodeTemplate(policy, nodeTemplate);
- addPolicyInputs(policy, inps);
- }
- }
-
- private static void addPolicyInputs(TypePolicy policy, TreeMap<String, LinkedHashMap<String, Object>> inps) {
- String defaultValue = policy.getPolicy_id() != null ? policy.getPolicy_id() : "";
- inps.put(policy.getNode_label() + "_policy_id", getInputValue("string", "policy_id", defaultValue));
- }
-
- 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 addPolicyNodesToNodeTemplate(TypePolicy policy, TreeMap<String, Node> nodeTemplate) {
- PolicyNode policyNode = new PolicyNode();
- policyNode.setType(POLICY_NODE_TYPE);
- policyNode.setPolicyNodeProperties(getPolicyNodeProperties(policy));
- nodeTemplate.put(policy.getNode_label(), policyNode);
- }
-
- private static PolicyNodeProperties getPolicyNodeProperties(TypePolicy policy) {
- PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties();
-
- GetInput policyIdGetInput = new GetInput();
- policyIdGetInput.setBpInputName(policy.getNode_label() + "_policy_id");
- policyNodeProperties.setPolicyId(policyIdGetInput);
-
- policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id());
-
- return policyNodeProperties;
- }
-
- 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) {
- LinkedHashMap<String, String> relationship = new LinkedHashMap<>();
- relationship.put("type", POLICY_RELATIONSHIP_TYPE);
- relationship.put("target", policy.getNode_label());
- relationships.add(relationship);
- }
- return relationships;
- }
-}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
deleted file mode 100644
index f9fa2cb..0000000
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
+++ /dev/null
@@ -1,270 +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.core;
-
-import java.util.ArrayList;
-import java.util.TreeMap;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.blueprintgenerator.models.componentspec.Artifacts;
-import org.onap.blueprintgenerator.models.componentspec.Auxilary;
-import org.onap.blueprintgenerator.models.componentspec.CallsObj;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Container;
-import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
-import org.onap.blueprintgenerator.models.componentspec.Host;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
-import org.onap.blueprintgenerator.models.componentspec.Policy;
-import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
-import org.onap.blueprintgenerator.models.componentspec.Publishes;
-import org.onap.blueprintgenerator.models.componentspec.Self;
-import org.onap.blueprintgenerator.models.componentspec.Services;
-import org.onap.blueprintgenerator.models.componentspec.Streams;
-import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-import org.onap.blueprintgenerator.models.componentspec.Volumes;
-
-@Getter @Setter
-public class TestComponentSpec {
- private String componentSpecAsString = "{\r\n" +
- " \"self\": {\r\n" +
- " \"component_type\": \"docker\",\r\n" +
- " \"description\": \"Test component spec\",\r\n" +
- " \"name\": \"test.component.spec\",\r\n" +
- " \"version\": \"1.0.1\"\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"service\": {\r\n" +
- " \"calls\": [],\r\n" +
- " \"provides\": []\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"streams\": {\r\n" +
- " \"publishes\": [{\r\n" +
- " \"config_key\": \"TEST-PUB-DR\",\r\n" +
- " \"format\": \"dataformat_Hello_World_PM\",\r\n" +
- " \"type\": \"data_router\",\r\n" +
- " \"version\": \"1.0.0\"\r\n" +
- " },\r\n" +
- " {\r\n" +
- " \"config_key\": \"TEST-PUB-MR\",\r\n" +
- " \"format\": \"dataformat_Hello_World_PM\",\r\n" +
- " \"type\": \"message_router\",\r\n" +
- " \"version\": \"1.0.0\"\r\n" +
- " }\r\n" +
- " ],\r\n" +
- "\r\n" +
- " \"subscribes\": [{\r\n" +
- " \"config_key\": \"TEST-SUB-MR\",\r\n" +
- " \"format\": \"dataformat_Hello_World_PM\",\r\n" +
- " \"route\": \"/TEST_HELLO_WORLD_SUB_MR\",\r\n" +
- " \"type\": \"message_router\",\r\n" +
- " \"version\": \"1.0.0\"\r\n" +
- " },\r\n" +
- " {\r\n" +
- " \"config_key\": \"TEST-SUB-DR\",\r\n" +
- " \"format\": \"dataformat_Hello_World_PM\",\r\n" +
- " \"route\": \"/TEST-HELLO-WORLD-SUB-DR\",\r\n" +
- " \"type\": \"data_router\",\r\n" +
- " \"version\": \"1.0.0\"\r\n" +
- " } \r\n" +
- " ]\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"parameters\":\r\n" +
- " [\r\n" +
- " {\r\n" +
- " \"name\": \"testParam1\",\r\n" +
- " \"description\": \"test parameter 1\",\r\n" +
- " \"value\": \"test-param-1\",\r\n" +
- " \"type\": \"string\",\r\n" +
- " \"sourced_at_deployment\": true,\r\n" +
- " \"designer_editable\": true,\r\n" +
- " \"policy_editable\": true,\r\n" +
- " \"policy_group\": \"Test_Parameters\",\r\n" +
- " \"required\": true\r\n" +
- " }\r\n" +
- " ],\r\n" +
- "\r\n" +
- " \"auxilary\": {\r\n" +
- " \"healthcheck\": {\r\n" +
- " \"type\": \"docker\",\r\n" +
- " \"interval\": \"300s\",\r\n" +
- " \"timeout\": \"120s\",\r\n" +
- " \"script\": \"/etc/init.d/nagios status\"\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"databases\" : {\r\n" +
- " \"TestDB1\": \"PGaaS\",\r\n" +
- " \"TestDB2\": \"PGaaS\"\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"policy\": {\r\n" +
- " \"trigger_type\": \"docker\",\r\n" +
- " \"script_path\": \"/opt/app/manager/bin/reconfigure.sh\"\r\n" +
- " },\r\n" +
- " \"volumes\": [\r\n" +
- " {\r\n" +
- " \"container\": {\r\n" +
- " \"bind\": \"/opt/app/manager/config/hostname\"\r\n" +
- " },\r\n" +
- " \"host\": {\r\n" +
- " \"path\": \"/etc/hostname\",\r\n" +
- " \"mode\": \"ro\"\r\n" +
- " }\r\n" +
- " }\r\n" +
- "\r\n" +
- " ],\r\n" +
- " \"ports\": [\r\n" +
- " \"80:80\"\r\n" +
- " ]\r\n" +
- " },\r\n" +
- "\r\n" +
- " \"artifacts\": [{\r\n" +
- " \"type\": \"docker image\",\r\n" +
- " \"uri\": \"test.tester\"\r\n" +
- " }] \r\n" +
- "\r\n" +
- "}";
- private ComponentSpec componentSpec;
-
- public TestComponentSpec() {
- this.componentSpec = createComponentSpec();
- }
-
- private ComponentSpec createComponentSpec(){
- //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);
-
- Services services = new Services();
- CallsObj[] calls = new CallsObj[0];
- ProvidesObj[] provides = new ProvidesObj[0];
- services.setCalls(calls);
- services.setProvides(provides);
- manualSpec.setServices(null);
-
- 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);
-
- 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);
-
- 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:80");
-
- TreeMap<String, String> dataBases = new TreeMap<>();
- 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);
-
- Artifacts[] artifacts = new Artifacts[1];
- Artifacts art = new Artifacts();
- art.setType("docker image");
- art.setUri("test.tester");
-
- artifacts[0] = art;
- manualSpec.setArtifacts(artifacts);
- return manualSpec;
- }
-}