diff options
Diffstat (limited to 'mod/bpgenerator/src')
78 files changed, 0 insertions, 6657 deletions
diff --git a/mod/bpgenerator/src/assembly/dep.xml b/mod/bpgenerator/src/assembly/dep.xml deleted file mode 100644 index daf6771..0000000 --- a/mod/bpgenerator/src/assembly/dep.xml +++ /dev/null @@ -1,52 +0,0 @@ -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>bundle</id> - <formats> - <format>tar.gz</format> - </formats> - <files> - <file> - <source>target/${project.artifactId}-${project.version}.jar</source> - <outputDirectory>lib</outputDirectory> - </file> - </files> - <fileSets> -<!-- - <fileSet> - <directory>src/main/scripts</directory> - <outputDirectory>bin</outputDirectory> - <includes> - <include>**/*.sh</include> - </includes> - <fileMode>0755</fileMode> - </fileSet> - <fileSet> - <directory>etc</directory> - <outputDirectory>conf</outputDirectory> - </fileSet> ---> - <fileSet> - <!-- src/main/scripts may be a better choice because src/main/resources is packaged by maven into the jar --> - <directory>src/main/resources/bin</directory> - <outputDirectory>bin</outputDirectory> - <includes> - <include>**/*.*</include> - </includes> - <fileMode>0755</fileMode> - </fileSet> - <fileSet> - <directory>src/main/resources/conf</directory> - <outputDirectory>conf</outputDirectory> - </fileSet> - - </fileSets> - <dependencySets> - <dependencySet> - <includes> - <include>*:jar</include> - </includes> - <outputDirectory>lib</outputDirectory> - </dependencySet> - </dependencySets> -</assembly> 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 deleted file mode 100644 index c3b1453..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java +++ /dev/null @@ -1,76 +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.common.blueprint; - - -import lombok.experimental.UtilityClass; - -import java.util.LinkedHashMap; - -@UtilityClass -public class BlueprintHelper { - - public static final String INTEGER_TYPE = "integer"; - public static final String BOOLEAN_TYPE = "boolean"; - public static final String STRING_TYPE = "string"; - - 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; - } - - public static LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) { - LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>(); - inputMap.put("type", type); - inputMap.put("default", defaultValue); - return inputMap; - } - - public static LinkedHashMap<String, Object> createIntegerInput(String description, Object defaultValue){ - return createInputValue(INTEGER_TYPE, description, defaultValue); - } - - public static LinkedHashMap<String, Object> createBooleanInput(String description, Object defaultValue){ - return createInputValue(BOOLEAN_TYPE, description, defaultValue); - } - - public static LinkedHashMap<String, Object> createStringInput(String description, Object defaultValue){ - return createInputValue(STRING_TYPE, description, defaultValue); - } - - public static LinkedHashMap<String, Object> createStringInput(Object defaultValue){ - return createInputValue(STRING_TYPE, defaultValue); - } - - public static String joinUnderscore(String firstValue, String secondValue){ - return firstValue + "_" + secondValue; - } - - public static boolean isDataRouterType(String type) { - return type.equals("data_router") || type.equals("data router"); - } - - public static boolean isMessageRouterType(String type) { - return type.equals("message_router") || type.equals("message router"); - } -} 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; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java deleted file mode 100644 index c9b2149..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java +++ /dev/null @@ -1,24 +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.exception; - -public class DatabasesNotFoundException extends RuntimeException { - public DatabasesNotFoundException(String message) { super(message);} -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java deleted file mode 100644 index 56184ff..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java +++ /dev/null @@ -1,34 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -public class GetAttribute { - - @JsonProperty("get_attribute") - private Object attribute; -} 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 deleted file mode 100644 index e9157ad..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java +++ /dev/null @@ -1,152 +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.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.dmaap.DmaapObj; -import org.onap.blueprintgenerator.models.componentspec.CallsObj; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -@Getter -@Setter -public class Appconfig { - - private CallsObj[] service_calls; - private TreeMap<String, DmaapObj> streams_publishes; - private TreeMap<String, DmaapObj> streams_subscribes; - private TreeMap<String, Object> params; - - @JsonAnyGetter - public TreeMap<String, Object> getParams() { - return params; - } - - public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig( - TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override, - boolean isDmaap) { - - service_calls = new CallsObj[0]; - streams_publishes = createStreamPublishes(componentSpec, inps, isDmaap); - streams_subscribes = createStreamSubscribes(componentSpec, inps, isDmaap); - params = createParameters(componentSpec, inps, override); - - return inps; - } - - private TreeMap<String, DmaapObj> createStreamPublishes(ComponentSpec componentSpec, - TreeMap<String, LinkedHashMap<String, Object>> inps, boolean isDmaap) { - TreeMap<String, DmaapObj> streamPublishes = new TreeMap<>(); - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - String config = publishes.getConfig_key(); - DmaapObj pub = new DmaapObj(); - if (isDataRouterType(publishes.getType())) { - //in this case the data router information gets added to the params so for now leave it alone - String name = publishes.getConfig_key() + "_feed"; - pub.createOnapDmaapDRObj(inps, config, 'p', name, name, isDmaap); - } else if (isMessageRouterType(publishes.getType())) { - String name = publishes.getConfig_key() + "_topic"; - pub.createOnapDmaapMRObj(inps, config, 'p', name, name, isDmaap); - } - pub.setType(publishes.getType()); - streamPublishes.put(config, pub); - } - return streamPublishes; - } - - private TreeMap<String, DmaapObj> createStreamSubscribes(ComponentSpec componentSpec, - TreeMap<String, LinkedHashMap<String, Object>> inputs, boolean isDmaap) { - TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<>(); - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - String config = subscribes.getConfig_key(); - DmaapObj sub = new DmaapObj(); - if (isDataRouterType(subscribes.getType())) { - //in this case the data router information gets added to the params so for now leave it alone - String name = subscribes.getConfig_key() + "_feed"; - sub.createOnapDmaapDRObj(inputs, config, 'p', name, name, isDmaap); - } else if (isMessageRouterType(subscribes.getType())) { - String name = subscribes.getConfig_key() + "_topic"; - sub.createOnapDmaapMRObj(inputs, config, 's', name, name, isDmaap); - } - sub.setType(subscribes.getType()); - streamSubscribes.put(config, sub); - } - return streamSubscribes; - } - - private TreeMap<String, Object> createParameters(ComponentSpec componentSpec, - TreeMap<String, LinkedHashMap<String, Object>> inputs, - String override) { - TreeMap<String, Object> parameters = new TreeMap<>(); - for (Parameters params : componentSpec.getParameters()) { - String pName = params.getName(); - if (params.isSourced_at_deployment()) { - GetInput paramInput = new GetInput(); - paramInput.setBpInputName(pName); - parameters.put(pName, paramInput); - - if (!params.getValue().equals("")) { - LinkedHashMap<String, Object> input = createStringInput(params.getValue()); - inputs.put(pName, input); - } else { - LinkedHashMap<String, Object> input = new LinkedHashMap<>(); - input.put("type", "string"); - inputs.put(pName, input); - } - } else { - if ("string".equals(params.getType())) { - String val = (String) params.getValue(); - val = '"' + val + '"'; - parameters.put(pName, val); - } else { - parameters.put(pName, params.getValue()); - } - } - } - handleOverride(override, parameters, inputs); - return parameters; - } - - private void handleOverride(String override, TreeMap<String, Object> parameters, - TreeMap<String, LinkedHashMap<String, Object>> inps) { - if (override != null) { - GetInput ov = new GetInput(); - ov.setBpInputName("service_component_name_override"); - parameters.put("service_component_name_override", ov); - LinkedHashMap<String, Object> over = new LinkedHashMap<>(); - over.put("type", "string"); - over.put("default", override); - inps.put("service_component_name_override", over); - } - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java deleted file mode 100644 index f2ef7aa..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java +++ /dev/null @@ -1,151 +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 com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import java.util.regex.Pattern; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.core.Fixes; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.dmaapbp.DmaapBlueprint; -import org.onap.blueprintgenerator.models.onapbp.OnapBlueprint; - -@Getter @Setter -@JsonInclude(JsonInclude.Include.NON_NULL) - -public class Blueprint { - - - private String tosca_definitions_version; - - private String description; - - private ArrayList<String> imports; - - private TreeMap<String, LinkedHashMap<String, Object>> inputs; - - private TreeMap<String, Node> node_templates; - - public Blueprint createBlueprint(ComponentSpec cs, String name, char bpType, String importPath, String override) { - Blueprint bp = new Blueprint(); - if(bpType == 'o') { - OnapBlueprint onap = new OnapBlueprint(); - bp = onap.createOnapBlueprint(cs, importPath, override); - bp = bp.setQuotations(bp); - } - - if(bpType == 'd') { - DmaapBlueprint dmaap = new DmaapBlueprint(); - bp = dmaap.createDmaapBlueprint(cs, importPath, override); - bp = bp.setQuotations(bp); - } - return bp; - } - - public Blueprint setQuotations(Blueprint bp) { - for(String s: bp.getInputs().keySet()) { - LinkedHashMap<String, Object> temp = bp.getInputs().get(s); - if(temp.get("type") == "string") { - String def = (String) temp.get("default"); - if(def != null){ - def = def.replaceAll("\"$", "").replaceAll("^\"", ""); - } - def = '"' + def + '"'; - temp.replace("default", def); - bp.getInputs().replace(s, temp); - } - } - - return bp; - } - - public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) { - File outputFile; - String name = bluePrintName.equals("") ? cs.getSelf().getName() : bluePrintName; - if(name.contains(".")) { - name = name.replaceAll(Pattern.quote("."), "_"); - } - if(name.contains(" ")) { - name = name.replaceAll(" ", ""); - } - String file = name + ".yaml"; - outputFile = new File(outputPath, file); - outputFile.getParentFile().mkdirs(); - try { - outputFile.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n'; - String description = "#description: " + cs.getSelf().getDescription() + '\n'; - - try(BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, false))) { - writer.write(description); - writer.write(version); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - - //read the translated blueprint into the file - ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - - try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)))) { - blueprintMapper.writeValue(out, this); - } catch (IOException e) { - throw new RuntimeException(e); - } - - try { - Fixes.fixSingleQuotes(outputFile); - } catch (IOException e) { - throw new RuntimeException(e); - } - - System.out.println("Blueprint created"); - } - - public String blueprintToString() { - String ret = ""; - - ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - try { - ret = blueprintMapper.writerWithDefaultPrettyPrinter().writeValueAsString(this); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - - return Fixes.applyFixes(ret); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java deleted file mode 100644 index d0d79a4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java +++ /dev/null @@ -1,43 +0,0 @@ -/*============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; - -public final class BpConstants { - - private BpConstants() {} - - public static final String CLOUDIFY_DSL_1_3 = "cloudify_dsl_1_3"; - - public static final String CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap"; - public static final String CONTENERIZED_SERVICE_COMPONENT = "dcae.nodes.ContainerizedServiceComponent"; - public static final String FEED = "dcaegen2.nodes.Feed"; - public static final String TOPIC = "dcaegen2.nodes.Topic"; - public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events"; - public static final String PUBLISH_FILES = "dcaegen2.relationships.publish_files"; - public static final String SUBSCRIBE_TO_EVENTS = "dcaegen2.relationships.subscribe_to_events"; - public static final String SUBSCRIBE_TO_FILES = "dcaegen2.relationships.subscribe_to_files"; - - public static final String TOSCA_DATATYPES_ROOT = "tosca.datatypes.Root"; - public static final String TOSCA_NODES_ROOT = "tosca.nodes.Root"; - public static final String TOSCA_SIMPLE_YAML = "tosca_simple_yaml_1_0_0"; - - public static final String MEMORY_LIMIT = "128Mi"; - public static final String CPU_LIMIT = "250m"; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java deleted file mode 100644 index edc257c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java +++ /dev/null @@ -1,57 +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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonRawValue; - -import lombok.Getter; import lombok.Setter; -import lombok.NoArgsConstructor; - -// TODO: Auto-generated Javadoc -/** - * The Class ConcatObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter -//@Builder - -/** - * Instantiates a new concat obj. - */ -@NoArgsConstructor -@JsonInclude(value=Include.NON_NULL) - -public class ConcatObj { - - /** The concat. */ - private ArrayList<Object> concat; -} - 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 deleted file mode 100644 index 3d5ca3d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java +++ /dev/null @@ -1,38 +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.models.blueprint; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class GetInput { - - @JsonProperty("get_input") - private Object bpInputName; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java deleted file mode 100644 index 1f9bf1c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java +++ /dev/null @@ -1,55 +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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; import lombok.Setter; -import lombok.NoArgsConstructor; - -// TODO: Auto-generated Javadoc -/** - * The Class GetProperty. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter -//@Builder - -/** - * Instantiates a new gets the property. - */ -@NoArgsConstructor -@JsonInclude(value=Include.NON_NULL) - -public class GetProperty { - - /** The get property. */ - private ArrayList<String> get_property; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java deleted file mode 100644 index 7b55e17..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java +++ /dev/null @@ -1,67 +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 com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -@JsonInclude(value=Include.NON_NULL) -public class Imports { - /** The imports. */ - private ArrayList<String> imports; - - public static ArrayList<String> createOnapImports() { - ArrayList<String> imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dcaepolicyplugin?version=2.4.0"); - return imps; - } - - public static ArrayList<String> createDmaapImports(){ - ArrayList<String> imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dmaap?version=1.5.0"); - return imps; - } - - public static ArrayList<String> createImportsFromFile(String path) { - ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - File importPath = new File(path); - try { - Imports imports = importMapper.readValue(importPath, Imports.class); - imports.getImports().removeIf(String::isBlank); - return imports.getImports(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java deleted file mode 100644 index 435059e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.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.models.blueprint; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import lombok.Getter; import lombok.Setter; - -@Getter @Setter -public class Interfaces { - private Start start; - public TreeMap<String, LinkedHashMap<String, Object>> createInterface(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){ - //create the start object - Start start = new Start(); - TreeMap<String, LinkedHashMap<String, Object>> retInputs = start.createOnapStart(inps, cs); - this.setStart(start); - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java deleted file mode 100644 index ee75ce0..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java +++ /dev/null @@ -1,35 +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 lombok.Getter; import lombok.Setter; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -@Getter @Setter -public class Node { - private String type; - private TreeMap<String, Interfaces> interfaces; - private Properties properties; - private ArrayList<LinkedHashMap<String, String>> relationships; -} 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 deleted file mode 100644 index 9aa5354..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java +++ /dev/null @@ -1,290 +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.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createBooleanInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createIntegerInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD; - -import com.fasterxml.jackson.annotation.JsonIgnore; -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.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; - - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) -public class Properties { - - private static final String EMPTY_VALUE = ""; - - ArrayList<DmaapStreams> streams_publishes; - ArrayList<DmaapStreams> streams_subscribes; - 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; - private TlsInfo tls_info; - private ExternalTlsInfo external_cert; - private ResourceConfig resource_config; - private GetInput always_pull_image; - private Boolean useExisting; - @JsonIgnore - 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 componentSpec, String override) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - - //set the image - GetInput image = new GetInput(); - image.setBpInputName("image"); - this.setImage(image); - retInputs.put("image", createStringInput(componentSpec.getImageUri())); - - //set the location id - GetInput location = new GetInput(); - location.setBpInputName("location_id"); - this.setLocation_id(location); - retInputs.put("location_id", createStringInput(EMPTY_VALUE)); - - //set the log info - this.setLog_info(componentSpec.getAuxilary().getLog_info()); - - //set the replicas - GetInput replica = new GetInput(); - replica.setBpInputName("replicas"); - this.setReplicas(replica); - LinkedHashMap<String, Object> rep = createIntegerInput("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 = componentSpec.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, componentSpec, 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 = createBooleanInput( - "Set to true if the image should always be pulled", - true); - retInputs.put("always_pull_image", inputAlwaysPullImage); - - //set service component type - String serviceComponentType = componentSpec.getSelfName().replace('.', '-'); - this.setService_component_type(serviceComponentType); - - //set the tls info for internal and external communication - TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info(); - if (tls_info != null) { - addTlsInfo(componentSpec, retInputs); - if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) { - retInputs.putAll(addExternalTlsInfo(componentSpec)); - } - } - - //set the reource config - ResourceConfig resource = new ResourceConfig(); - retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName()); - this.setResource_config(resource); - - return retInputs; - } - - public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties( - TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - - //set the image - GetInput image = new GetInput(); - image.setBpInputName("tag_version"); - this.setImage(image); - retInputs.put("tag_version", createStringInput(componentSpec.getImageUri())); - - //set the location id - GetInput location = new GetInput(); - location.setBpInputName("location_id"); - this.setLocation_id(location); - retInputs.put("location_id", createStringInput(EMPTY_VALUE)); - - //set the log info - this.setLog_info(componentSpec.getAuxilary().getLog_info()); - - //set service component type - String serviceComponentType = componentSpec.getSelfName().replace('.', '-'); - this.setService_component_type(serviceComponentType); - - //set the tls info for internal and external communication - TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info(); - if (tls_info != null) { - addTlsInfo(componentSpec, retInputs); - if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) { - retInputs.putAll(addExternalTlsInfo(componentSpec)); - } - } - - //set the replicas - GetInput replica = new GetInput(); - replica.setBpInputName("replicas"); - this.setReplicas(replica); - LinkedHashMap<String, Object> rep = createIntegerInput("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 = componentSpec.getAuxilary(); -// if(aux.getPorts() != null) { -// retInputs = aux.createPorts(retInputs); -// } - this.setDocker_config(aux); - - //set the appconfig - Appconfig app = new Appconfig(); - retInputs = app.createAppconfig(retInputs, componentSpec, override, true); - this.setApplication_config(app); - - //set the stream publishes - ArrayList<DmaapStreams> pubStreams = new ArrayList<>(); - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - if (isMessageRouterType(publishes.getType())) { - String topic = publishes.getConfig_key() + "_topic"; - DmaapStreams mrStreams = new DmaapStreams(); - retInputs = mrStreams - .createStreams(inps, componentSpec, topic, publishes.getType(), publishes.getConfig_key(), - publishes.getRoute(), 'p'); - pubStreams.add(mrStreams); - } else if (isDataRouterType(publishes.getType())) { - String feed = publishes.getConfig_key() + "_feed"; - DmaapStreams drStreams = new DmaapStreams(); - retInputs = drStreams - .createStreams(inps, componentSpec, feed, publishes.getType(), publishes.getConfig_key(), - publishes.getRoute(), 'p'); - pubStreams.add(drStreams); - } - } - } - - //set the stream subscribes - ArrayList<DmaapStreams> subStreams = new ArrayList<>(); - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - if (isMessageRouterType(subscribes.getType())) { - String topic = subscribes.getConfig_key() + "_topic"; - DmaapStreams mrStreams = new DmaapStreams(); - retInputs = mrStreams - .createStreams(inps, componentSpec, topic, subscribes.getType(), subscribes.getConfig_key(), - subscribes.getRoute(), 's'); - subStreams.add(mrStreams); - } else if (isDataRouterType(subscribes.getType())) { - String feed = subscribes.getConfig_key() + "_feed"; - DmaapStreams drStreams = new DmaapStreams(); - retInputs = drStreams - .createStreams(inps, componentSpec, feed, subscribes.getType(), subscribes.getConfig_key(), - subscribes.getRoute(), 's'); - subStreams.add(drStreams); - } - } - } - - if (!pubStreams.isEmpty()) { - this.setStreams_publishes(pubStreams); - } - if (!subStreams.isEmpty()) { - this.setStreams_subscribes(subStreams); - } - - //set the reource config - ResourceConfig resource = new ResourceConfig(); - retInputs = resource.createResourceConfig(retInputs, componentSpec.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 = createBooleanInput( - "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 deleted file mode 100644 index 3618be3..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java +++ /dev/null @@ -1,115 +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.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CPU_LIMIT; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.MEMORY_LIMIT; - -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -//TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter -@Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Builder - -/** - * Instantiates a new resource config obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new resource config obj. - * - * @param limits the limits - * @param requests the requests - */ -@AllArgsConstructor - -public class ResourceConfig { - - private TreeMap<String, GetInput> limits; - private TreeMap<String, GetInput> requests; - - - /** - * Creates the resource config. - * - * @param inputs the inputs - * @param name the name - * @return the tree map - */ - public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig( - TreeMap<String, LinkedHashMap<String, Object>> inputs, String name) { - - String namePrefix = getNamePrefix(name); - - limits = createInputs(inputs, namePrefix, "limit"); - requests = createInputs(inputs, namePrefix, "request"); - - return inputs; - } - - private TreeMap<String, GetInput> createInputs(TreeMap<String, LinkedHashMap<String, Object>> inputs, - String namePrefix, - String inputType) { - - LinkedHashMap<String, Object> memoryLimit = createStringInput(MEMORY_LIMIT); - LinkedHashMap<String, Object> cpuLimit = createStringInput(CPU_LIMIT); - - final String cpuKey = namePrefix + "cpu_" + inputType; - final String memoryKey = namePrefix + "memory_" + inputType; - TreeMap<String, GetInput> inps = new TreeMap<>(); - - insertInput("cpu", cpuKey, inps); - insertInput("memory", memoryKey, inps); - - inputs.put(cpuKey, cpuLimit); - inputs.put(memoryKey, memoryLimit); - - return inps; - } - - private void insertInput(String type, String name, TreeMap<String, GetInput> inputs) { - GetInput input = new GetInput(); - input.setBpInputName(name); - inputs.put(type, input); - } - - private String getNamePrefix(String name) { - return (name == null || name.isEmpty()) ? "" : name + "_"; - } -} - diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java deleted file mode 100644 index 0b03777..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java +++ /dev/null @@ -1,47 +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.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -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 Start { - private StartInputs inputs; - private LinkedHashMap<String, Object> envs; - - public TreeMap<String, LinkedHashMap<String, Object>> createOnapStart(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs) { - - //create the start inputs - StartInputs inputs = new StartInputs(); - inputs.createOnapStartInputs(inps, cs); - this.setInputs(inputs); - - return inps; - } -} 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 deleted file mode 100644 index a0cfe20..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java +++ /dev/null @@ -1,118 +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.models.blueprint; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -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 StartInputs { - private ArrayList<String> ports; - private Object envs; - - public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){ - - int count = 0; - ArrayList<String> portList = new ArrayList<>(); - Auxilary aux = cs.getAuxilary(); - - if (aux.getPorts() != null) { - - for(Object p : aux.getPorts()) { - String[] ports = p.toString().split(":"); - String internal - = String.format("concat: [\"%s:\", {get_input: external_port_%d}]" - , ports[0], count); - portList.add(internal); - - LinkedHashMap<String, Object> portType = new LinkedHashMap<>(); - portType.put("type", "string"); - portType.put("default", ports[1]); - inps.put("external_port_" + count, portType); - - count++; - } - - } - - this.setPorts(portList); -// ArrayList<String> port = new ArrayList<String>(); -// String external = ""; -// if(cs.getAuxilary().getPorts() != null) { -// for(String s: cs.getAuxilary().getPorts()) { -// //create the ports -// String portNumber = ""; -// StringBuffer buf = new StringBuffer(); -// for(int i = 0; i < s.length(); i++) { -// if(!(s.charAt(i) == ':')) { -// buf.append(s.charAt(i)); -// } -// else { -// external = s.replace(buf.toString() + ":", ""); -// break; -// } -// } -// portNumber = buf.toString(); -// String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]"; -// port.add(p); -// } -// } -// this.setPorts(port); -// //add the external port input -// if(cs.getAuxilary().getPorts() != null) { -// stringType.put("type", "string"); -// stringType.put("description", "Kubernetes node port on which collector is exposed"); -// stringType.put("default", "'" + external + "'") ; -// retInputs.put("external_port", stringType); -// } - - //set the envs - LinkedHashMap<String, Object> eMap = new LinkedHashMap<>(); - if(cs.getAuxilary().getDatabases() != null){ - //set db env variables - LinkedHashMap<String, Object> envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases()); - this.setEnvs(envVars); - eMap.put("default", "&envs {}"); - } - else { - GetInput env = new GetInput(); - env.setBpInputName("envs"); - this.setEnvs(env); - eMap.put("default", "{}"); - } - inps.put("envs", eMap); - - - return inps; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java deleted file mode 100644 index 7137cdb..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java +++ /dev/null @@ -1,69 +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.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.HealthCheck; -import org.onap.blueprintgenerator.models.onapbp.OnapNode; - -import lombok.Getter; import lombok.Setter; - - -public class TemplateNode extends OnapNode{ - -// public void createTemplateNode() { -// //dummy inputs just used for the inputs so i can reuse code -// TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<String, LinkedHashMap<String, Object>>(); -// -// //create a dummy componentspec to set the values later on -// ComponentSpec cs = new ComponentSpec(); -// Auxilary aux = new Auxilary(); -// HealthCheck health = new HealthCheck(); -// health.setEndpoint("/healthcheck"); -// health.setInterval("15s"); -// health.setTimeout("1s"); -// health.setType("https"); -// aux.setHealthcheck(health); -// String[] ports = new String[1]; -// ports[0] = "9999:9999"; -// aux.setPorts(ports); -// cs.setAuxilary(aux); -// -// //set the type -// this.setType("dcae.nodes.ContainerizedPlatformComponent"); -// -// //set the interface -// Interfaces inter = new Interfaces(); -// inter.createOnapInterface(inps, cs); -// TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>(); -// interfaces.put("cloudify.interfaces.lifecycle", inter); -// this.setInterfaces(interfaces); -// -// -// //create the properties -// Properties props = new Properties(); -// props.createTemplateProperties(cs); -// this.setProperties(props); -// } -} 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 deleted file mode 100644 index 0cec284..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java +++ /dev/null @@ -1,105 +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.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) { - LinkedHashMap<String, Object> stringType = new LinkedHashMap<>(); - 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); - - inps.put(config, stringType); - - return inps; - } - - 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/dmaap/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java deleted file mode 100644 index 30f59e2..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java +++ /dev/null @@ -1,83 +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.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; - -@JsonInclude(value=Include.NON_NULL) -@Getter @Setter -public class DmaapObj { - private Object dmaap_info; - private String type; - private GetInput pass; - private GetInput user; - - public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, - String config, char type, String n, String num, boolean isDmaap) { - LinkedHashMap<String, Object> stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the dmaapinfo - DmaapInfo info = new DmaapInfo(); - if(!isDmaap){ - info.createOnapDmaapMRInfo(inps, config, type); - this.setDmaap_info(info); - } - else{ - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); - //set username - GetInput u = new GetInput(); - u.setBpInputName(config + "_" + num +"_aaf_username"); - this.setUser(u); - inps.put(config + "_" + num +"_aaf_username", stringType); - - //set password - GetInput p = new GetInput(); - p.setBpInputName(config + "_" + num +"_aaf_password"); - this.setPass(p); - inps.put(config + "_" + num +"_aaf_password", stringType); - } - return inps; - } - public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num, boolean isDmaap) { - - //set the dmaapinfo - DmaapInfo info = new DmaapInfo(); - if(!isDmaap){ - info.createOnapDmaapDRInfo(inps, config, type); - this.setDmaap_info(info); - } - else { - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); - } - return inps; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java deleted file mode 100644 index 35f958e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java +++ /dev/null @@ -1,35 +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.pgaas; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.Node; - -@Getter -@Setter -@NoArgsConstructor -public class PgaasNode extends Node { - - @JsonProperty("properties") - private PgaasNodeProperties pgaasNodeProperties; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java deleted file mode 100644 index 709c66e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.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.models.blueprint.pgaas; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -@Getter @Setter -@NoArgsConstructor -public class PgaasNodeProperties { - - @JsonProperty("writerfqdn") - private GetInput writerfqdn; - - @JsonProperty("name") - private GetInput name; - - @JsonProperty("use_existing") - private boolean useExisting; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java deleted file mode 100644 index b4740df..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java +++ /dev/null @@ -1,34 +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.policy; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.Node; - -@Getter @Setter -@NoArgsConstructor -public class PolicyNode extends Node { - - @JsonProperty("properties") - private PolicyNodeProperties policyNodeProperties; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java deleted file mode 100644 index 6d23b23..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java +++ /dev/null @@ -1,37 +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.policy; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -@Getter @Setter -@NoArgsConstructor -public class PolicyNodeProperties { - - @JsonProperty("policy_id") - private GetInput policyId; - - @JsonProperty("policy_model_id") - private String policyModelId; -} 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 deleted file mode 100644 index 546a809..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java +++ /dev/null @@ -1,74 +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.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 deleted file mode 100644 index e954afc..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java +++ /dev/null @@ -1,102 +0,0 @@ -/*============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 deleted file mode 100644 index cdbfd32..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/*============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/tls/TlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java deleted file mode 100644 index 027f996..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java +++ /dev/null @@ -1,39 +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.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 -@NoArgsConstructor -public class TlsInfo { - - @JsonProperty("cert_directory") - private String certDirectory; - - @JsonProperty("use_tls") - private GetInput useTls; -} 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 deleted file mode 100644 index 21b20e4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java +++ /dev/null @@ -1,37 +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.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 deleted file mode 100644 index e3ccca1..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java +++ /dev/null @@ -1,43 +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.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 deleted file mode 100644 index 588dbb5..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java +++ /dev/null @@ -1,54 +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.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/componentspec/Artifacts.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java deleted file mode 100644 index 198dc19..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java +++ /dev/null @@ -1,63 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new artifacts. - */ -@NoArgsConstructor - -/** - * Instantiates a new artifacts. - * - * @param type the type - * @param uri the uri - */ - -@JsonInclude(JsonInclude.Include.NON_NULL) -@EqualsAndHashCode -//Called in Component Spec Object -public class Artifacts { - - /** The type. */ - private String type; - - /** The uri. */ - private String uri; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java deleted file mode 100644 index 58e1e0c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java +++ /dev/null @@ -1,127 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.TreeMap; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new auxilary. - */ -@NoArgsConstructor - -/** - * Instantiates a new auxilary. - * - * @param healthcheck the healthcheck - * @param volumes the volumes - * @param policy the policy - * @param ports the ports - * @param reconfigs the reconfigs - * @param databases the databases - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in component Spec Object -public class Auxilary { - - /** The healthcheck. */ - private HealthCheck healthcheck; - - /**log-directory**/ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap<String, Object> log_info; - - /**tls-info**/ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap<String, Object> tls_info; - - /** The volumes. */ - private Volumes[] volumes; - - /** The policy. */ - private Policy policy; - - /** The ports. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private ArrayList<Object> ports; - - /** The reconfigs. */ - private ReconfigsObj reconfigs; - - /** The databases. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap<String, String> databases; - - -// public TreeMap<String, LinkedHashMap<String, Object>> createPorts(TreeMap<String, LinkedHashMap<String, Object>> inps) { -// TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; -// LinkedHashMap<String, Object> portType = new LinkedHashMap(); -// portType.put("type", "string"); -// -// ArrayList<Object> ports = new ArrayList(); -// String external = ""; -// boolean foundPort = false; -// for(Object o: this.getPorts()) { -// String internal = ""; -// String p = o.toString(); -// for(int i = 0; i < p.length(); i++) { -// if(p.charAt(i) == ':') { -// internal = '"' + internal + '"'; -// internal = "concat: ['" + internal + "', {get_input: external_port}]"; -// ports.add(internal); -// } -// if(p.charAt(i) == ':' && !foundPort) { -// external = p.substring(i); -// portType.put("default", external); -// retInputs.put("external_port", portType); -// -// } -// internal = internal + p.charAt(i); -// -// } -// } -// -// this.setPorts(ports); -// return retInputs; -// } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java deleted file mode 100644 index d130632..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java +++ /dev/null @@ -1,45 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - - -// TODO: Auto-generated Javadoc -/** - * The Class CallsObj. - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called from service obj -public class CallsObj { - - /** The config key. */ - private String config_key; - - /** The request. */ - private RequestResponseObj request; - - /** The response. */ - private RequestResponseObj response; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java deleted file mode 100644 index 0cd2b72..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java +++ /dev/null @@ -1,166 +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.models.componentspec; - -import java.io.File; -import java.io.IOException; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -import lombok.Getter; -import lombok.Setter; -import lombok.NoArgsConstructor; -import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo; - -// TODO: Auto-generated Javadoc - -/** - * The Class ComponentSpec. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter -@Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new component spec. - */ -@NoArgsConstructor - -/** - * Instantiates a new component spec. - * - * @param self the self - * @param services the services - * @param streams the streams - * @param parameters the parameters - * @param auxilary the auxilary - * @param artifacts the artifacts - */ - -@JsonInclude(value = Include.NON_NULL) -//main object that the component spec file is written in -public class ComponentSpec { - - /** - * The self. - */ - private Self self; - - /** - * The services. - */ - private Services services; - - /** - * The streams. - */ - private Streams streams; - - /** - * The parameters. - */ - private Parameters[] parameters; - - /** - * The auxilary. - */ - private Auxilary auxilary; - - @JsonProperty("policy_info") - private PolicyInfo policyInfo; - - /** - * The artifacts. - */ - private Artifacts[] artifacts; - - /** - * Creates the component spec from file. - * - * @param path the path - */ - public void createComponentSpecFromFile(String path) { - ObjectMapper componentMapper = new ObjectMapper(); - File specPathFile = new File(path); - ComponentSpec cs = new ComponentSpec(); - - try { - cs = componentMapper.readValue(specPathFile, ComponentSpec.class); - } catch (IOException e) { - throw new RuntimeException(e); - } - - //set all the pieces of the component spec - this.setSelf(cs.getSelf()); - this.setArtifacts(cs.getArtifacts()); - this.setAuxilary(cs.getAuxilary()); - this.setParameters(cs.getParameters()); - this.setServices(cs.getServices()); - this.setStreams(cs.getStreams()); - this.setPolicyInfo(cs.getPolicyInfo()); - } - - - /** - * Creates the component spec from string. - * - * @param specString the spec string - */ - public void createComponentSpecFromString(String specString) { - ObjectMapper componentMapper = new ObjectMapper(); - ComponentSpec cs = new ComponentSpec(); - try { - cs = componentMapper.readValue(specString, ComponentSpec.class); - } catch (IOException e) { - throw new RuntimeException(e); - } - - //set all the pieces of the component spec - this.setSelf(cs.getSelf()); - this.setArtifacts(cs.getArtifacts()); - this.setAuxilary(cs.getAuxilary()); - this.setParameters(cs.getParameters()); - this.setServices(cs.getServices()); - this.setStreams(cs.getStreams()); - } - - public String getImageUri() { - return artifacts[0].getUri(); - } - - public String getSelfName() { - return this.self.getName(); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java deleted file mode 100644 index 785df35..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java +++ /dev/null @@ -1,62 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -// TODO: Auto-generated Javadoc -/** - * The Class ConstraintsObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(value=Include.NON_NULL) - -public class ConstraintsObj { - - /** The equal. */ - private Object equal; - - /** The greater than. */ - private int greater_than; - - /** The greater or equal. */ - private int greater_or_equal; - - /** The less than. */ - private int less_than; - - /** The less or equal. */ - private int less_or_equal; - - /** The valid values. */ - private Object[] valid_values; - - /** The length. */ - private int length; - - /** The min length. */ - private int min_length; - - /** The max length. */ - private int max_length; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java deleted file mode 100644 index cbe02dc..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java +++ /dev/null @@ -1,60 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new container. - */ -@NoArgsConstructor - -/** - * Instantiates a new container. - * - * @param bind the bind - * @param mode the mode - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class Container { - - /** The bind. */ - private String bind; - - /** The mode. */ - private String mode; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java deleted file mode 100644 index ef33aaf..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java +++ /dev/null @@ -1,82 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class EntrySchemaObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new entry schema obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new entry schema obj. - * - * @param name the name - * @param description the description - * @param type the type - * @param value the value - * @param entry_schema the entry schema - * @param required the required - */ - -@JsonInclude(value=Include.NON_NULL) -//called from policy schema obj -public class EntrySchemaObj { - - /** The name. */ - private String name; - - /** The description. */ - private String description; - - /** The type. */ - private String type; - - /** The value. */ - private String value; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The required. */ - private boolean required; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java deleted file mode 100644 index 76e1036..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java +++ /dev/null @@ -1,72 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new health check. - */ -@NoArgsConstructor - -/** - * Instantiates a new health check. - * - * @param interval the interval - * @param timeout the timeout - * @param script the script - * @param type the type - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in Auxillary Object -public class HealthCheck { - - /** The interval. */ - private String interval; - - /** The timeout. */ - private String timeout; - - /** The script. */ - private String script; - - /** The type. */ - private String type; - - private String endpoint; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java deleted file mode 100644 index f178c94..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java +++ /dev/null @@ -1,56 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/** - * Instantiates a new host. - */ -@NoArgsConstructor - -/** - * Instantiates a new host. - * - * @param path the path - * @param mode the mode - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class Host{ - - /** The path. */ - private String path; - - /** The mode. */ - private String mode; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java deleted file mode 100644 index eb95202..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java +++ /dev/null @@ -1,106 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class Parameters. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new parameters. - */ -@NoArgsConstructor - -/** - * Instantiates a new parameters. - * - * @param name the name - * @param value the value - * @param description the description - * @param sourced_at_deployment the sourced at deployment - * @param designer_editable the designer editable - * @param policy_editable the policy editable - * @param required the required - * @param type the type - * @param policy_group the policy group - * @param policy_schema the policy schema - * @param entry_schema the entry schema - * @param constraints the constraints - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in component Spec Object -public class Parameters { - - /** The name. */ - private String name; - - /** The value. */ - private Object value; - - /** The description. */ - private String description; - - /** The sourced at deployment. */ - private boolean sourced_at_deployment; - - /** The designer editable. */ - private boolean designer_editable; - - /** The policy editable. */ - private boolean policy_editable; - - /** The required. */ - private boolean required; - - /** The type. */ - private String type; - - /** The policy group. */ - private String policy_group; - - /** The policy schema. */ - private PolicySchemaObj[] policy_schema; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The constraints. */ - private ConstraintsObj[] constraints; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java deleted file mode 100644 index d295ca4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java +++ /dev/null @@ -1,62 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new policy. - */ -@NoArgsConstructor - -/** - * Instantiates a new policy. - * - * @param trigger_type the trigger type - * @param script_path the script path - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//called in auxilary -public class Policy { - - /** The trigger type. */ - private String trigger_type; - - /** The script path. */ - private String script_path; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java deleted file mode 100644 index aa38271..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java +++ /dev/null @@ -1,86 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class PolicySchemaObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new policy schema obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new policy schema obj. - * - * @param name the name - * @param description the description - * @param type the type - * @param value the value - * @param entry_schema the entry schema - * @param required the required - * @param constraints the constraints - */ -@JsonInclude(value=Include.NON_NULL) -//called from parameters obj -public class PolicySchemaObj { - - /** The name. */ - private String name; - - /** The description. */ - private String description; - - /** The type. */ - private String type; - - /** The value. */ - private String value; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The required. */ - private boolean required; - - /** The constraints. */ - private ConstraintsObj[] constraints; - } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java deleted file mode 100644 index 9ad24c3..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java +++ /dev/null @@ -1,63 +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.componentspec; - - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new provides obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new provides obj. - * - * @param route the route - * @param request the request - * @param response the response - */ -//called from service obj -public class ProvidesObj { - - /** The route. */ - private String route; - - /** The request. */ - private RequestResponseObj request; - - /** The response. */ - private RequestResponseObj response; - - private String verb; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java deleted file mode 100644 index 4f46313..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java +++ /dev/null @@ -1,73 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new publishes. - */ -@NoArgsConstructor - -/** - * Instantiates a new publishes. - * - * @param config_key the config key - * @param format the format - * @param type the type - * @param version the version - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Streams Object -public class Publishes { - - /** The config key. */ - private String config_key; - - /** The format. */ - private String format; - - /** The route. */ - private String route; - /** The type. */ - private String type; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java deleted file mode 100644 index 6d78805..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java +++ /dev/null @@ -1,60 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new reconfigs obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new reconfigs obj. - * - * @param dti the dti - * @param policy the policy - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class ReconfigsObj { - - /** The dti. */ - private String dti; - - /** The policy. */ - private String policy; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java deleted file mode 100644 index 7ca1830..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java +++ /dev/null @@ -1,43 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - - -// TODO: Auto-generated Javadoc -/** - * The Class RequestResponseObj. - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called in calls obj -public class RequestResponseObj { - - /** The format. */ - private String format; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java deleted file mode 100644 index 8b5f35e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java +++ /dev/null @@ -1,70 +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.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new self. - */ -@NoArgsConstructor - -/** - * Instantiates a new self. - * - * @param component_type the component type - * @param description the description - * @param name the name - * @param version the version - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//called in Component Spec object -public class Self { - - /** The component type. */ - private String component_type; - - /** The description. */ - private String description; - - /** The name. */ - private String name; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java deleted file mode 100644 index 772d859..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java +++ /dev/null @@ -1,61 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new services. - */ -@NoArgsConstructor - -/** - * Instantiates a new services. - * - * @param calls the calls - * @param provides the provides - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called in component spec object -public class Services { - - /** The calls. */ - private CallsObj[] calls; - - /** The provides. */ - private ProvidesObj[] provides; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java deleted file mode 100644 index 500f32d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java +++ /dev/null @@ -1,63 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new streams. - */ -@NoArgsConstructor - -/** - * Instantiates a new streams. - * - * @param publishes the publishes - * @param subscribes the subscribes - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Component Spec Object -public class Streams { - - /** The publishes. */ - private Publishes[] publishes; - - /** The subscribes. */ - private Subscribes[] subscribes; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java deleted file mode 100644 index ec4aa41..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java +++ /dev/null @@ -1,77 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new subscribes. - */ -@NoArgsConstructor - -/** - * Instantiates a new subscribes. - * - * @param config_key the config key - * @param format the format - * @param route the route - * @param type the type - * @param version the version - */ - -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Streams Object -public class Subscribes { - - /** The config key. */ - private String config_key; - - /** The format. */ - private String format; - - /** The route. */ - private String route; - - /** The type. */ - private String type; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java deleted file mode 100644 index 777bdeb..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java +++ /dev/null @@ -1,61 +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.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new volumes. - */ -@NoArgsConstructor - -/** - * Instantiates a new volumes. - * - * @param container the container - * @param host the host - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in Auxillary Object -public class Volumes { - - /** The container. */ - private Container container; - - /** The host. */ - private Host host; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java deleted file mode 100644 index da746a7..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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.componentspec.policy_info; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.List; - -@Getter @Setter -@NoArgsConstructor -public class PolicyInfo { - - @JsonProperty("policy") - private List<TypePolicy> typePolicyList; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java deleted file mode 100644 index 038c601..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java +++ /dev/null @@ -1,36 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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.componentspec.policy_info; - -import com.fasterxml.jackson.annotation.JsonCreator; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter @Setter -@NoArgsConstructor -public class TypePolicy { - - private String node_label; - private String policy_id; - private String policy_model_id; - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java deleted file mode 100644 index 0c8f8a9..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java +++ /dev/null @@ -1,126 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.dmaapbp; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.joinUnderscore; -import static org.onap.blueprintgenerator.models.blueprint.Imports.createDmaapImports; -import static org.onap.blueprintgenerator.models.blueprint.Imports.createImportsFromFile; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3; - -public class DmaapBlueprint extends Blueprint { - - private static final String TOPIC = "topic"; - private static final String FEED = "feed"; - - public Blueprint createDmaapBlueprint(ComponentSpec componentSpec, String importPath, String override) { - Blueprint blueprint = new Blueprint(); - - //set tosca definition - blueprint.setTosca_definitions_version(CLOUDIFY_DSL_1_3); - - //set the description - blueprint.setDescription(componentSpec.getSelf().getDescription()); - - //create the inpus object that will be added to over the creation of the blueprint - TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<>(); - - //set the imports - if (importPath.equals("")) { - blueprint.setImports(createDmaapImports()); - } else { - blueprint.setImports(createImportsFromFile(importPath)); - } - - //set and create the node templates - TreeMap<String, Node> nodeTemplate = new TreeMap(); - - //create and add the main dmaap node - DmaapNode dmaap = new DmaapNode(); - inps = dmaap.createDmaapNode(componentSpec, inps, override); - nodeTemplate.put(componentSpec.getSelf().getName(), dmaap); - - //create and add the topic/feed nodes - - //go through the streams publishes - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publisher : componentSpec.getStreams().getPublishes()) { - if (isMessageRouterType(publisher.getType())) { - String topic = joinUnderscore(publisher.getConfig_key(), TOPIC); - DmaapNode topicNode = new DmaapNode(); - inps = topicNode.createTopicNode(componentSpec, inps, topic); - nodeTemplate.put(topic, topicNode); - } else if (isDataRouterType(publisher.getType())) { - String feed = joinUnderscore(publisher.getConfig_key(), FEED); - DmaapNode feedNode = new DmaapNode(); - inps = feedNode.createFeedNode(componentSpec, inps, feed); - nodeTemplate.put(feed, feedNode); - } - } - } - //go through the stream subscribes - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscriber : componentSpec.getStreams().getSubscribes()) { - if (isMessageRouterType(subscriber.getType())) { - String topic = joinUnderscore(subscriber.getConfig_key(), TOPIC); - DmaapNode topicNode = new DmaapNode(); - inps = topicNode.createTopicNode(componentSpec, inps, topic); - nodeTemplate.put(topic, topicNode); - } else if (isDataRouterType(subscriber.getType())) { - String feed = joinUnderscore(subscriber.getConfig_key(), FEED); - DmaapNode feedNode = new DmaapNode(); - inps = feedNode.createFeedNode(componentSpec, inps, feed); - nodeTemplate.put(feed, feedNode); - } - } - } - - //if present in component spec, populate policyNodes information in the blueprint - if (componentSpec.getPolicyInfo() != null) { - PolicyNodeBuilder.addPolicyNodesAndInputs(componentSpec, nodeTemplate, inps); - } - - //if present in component spec, populate pgaasNodes information in the blueprint - if (componentSpec.getAuxilary().getDatabases() != null) { - PgaasNodeBuilder.addPgaasNodesAndInputs(componentSpec, nodeTemplate, inps); - } - - blueprint.setNode_templates(nodeTemplate); - - blueprint.setInputs(inps); - return blueprint; - } - -} 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 deleted file mode 100644 index 515099a..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java +++ /dev/null @@ -1,185 +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.models.dmaapbp; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.blueprint.Interfaces; -import org.onap.blueprintgenerator.models.blueprint.Node; -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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_FILES; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES; - -@JsonIgnoreProperties(ignoreUnknown = true) -@Getter -@Setter -@EqualsAndHashCode(callSuper = false) -@NoArgsConstructor -@JsonInclude(value = Include.NON_NULL) - -public class DmaapNode extends Node { - - public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec componentSpec, - TreeMap<String, LinkedHashMap<String, Object>> inps, String override) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - - //set the type - this.setType(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP); - - //create the interface - Interfaces inter = new Interfaces(); - retInputs = inter.createInterface(retInputs, componentSpec); - TreeMap<String, Interfaces> interfaces = new TreeMap<>(); - interfaces.put("cloudify.interfaces.lifecycle", inter); - this.setInterfaces(interfaces); - - //create and set the relationships - ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>(); - - //go through the streams publishes - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - relationships.add(createTypeAndTargetPubRelations(publishes)); - } - } - //go through the stream subscribes - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - relationships.add(createTypeAndTargetSubRelations(subscribes)); - } - } - - //add relationship for policy if exist - if (componentSpec.getPolicyInfo() != null) { - ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder - .getPolicyRelationships(componentSpec); - relationships.addAll(policyRelationshipsList); - } - - //add relationships and env_variables for pgaas dbs if exist - if (componentSpec.getAuxilary().getDatabases() != null) { - ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder - .getPgaasNodeRelationships(componentSpec); - relationships.addAll(pgaasRelationshipsList); - } - - this.setRelationships(relationships); - - //create and set the properties - Properties props = new Properties(); - retInputs = props.createDmaapProperties(retInputs, componentSpec, override); - this.setProperties(props); - - return retInputs; - } - - public TreeMap<String, LinkedHashMap<String, Object>> createFeedNode(ComponentSpec cs, - TreeMap<String, LinkedHashMap<String, Object>> inps, String name) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - LinkedHashMap<String, Object> stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the type - this.setType(FEED); - - //create and set the properties - Properties props = new Properties(); - GetInput topicInput = new GetInput(); - topicInput.setBpInputName(name + "_name"); - props.setFeed_name(topicInput); - props.setUseExisting(true); - retInputs.put(name + "_name", stringType); - this.setProperties(props); - - return retInputs; - } - - public TreeMap<String, LinkedHashMap<String, Object>> createTopicNode(ComponentSpec cs, - TreeMap<String, LinkedHashMap<String, Object>> inps, String name) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - LinkedHashMap<String, Object> stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the type - this.setType(TOPIC); - - //create and set the properties - Properties props = new Properties(); - GetInput topicInput = new GetInput(); - topicInput.setBpInputName(name + "_name"); - props.setTopic_name(topicInput); - //props.setUseExisting(true); - retInputs.put(name + "_name", stringType); - this.setProperties(props); - - return retInputs; - } - - private LinkedHashMap<String, String> createTypeAndTargetPubRelations(Publishes publishes) { - LinkedHashMap<String, String> pubRelations = new LinkedHashMap<>(); - if (isMessageRouterType(publishes.getType())) { - pubRelations.put("type", PUBLISH_EVENTS); - pubRelations.put("target", publishes.getConfig_key() + "_topic"); - } else if (isDataRouterType(publishes.getType())) { - pubRelations.put("type", PUBLISH_FILES); - pubRelations.put("target", publishes.getConfig_key() + "_feed"); - } - return pubRelations; - } - - private LinkedHashMap<String, String> createTypeAndTargetSubRelations(Subscribes subscribes) { - LinkedHashMap<String, String> subRelations = new LinkedHashMap<>(); - if (isMessageRouterType(subscribes.getType())) { - subRelations.put("type", SUBSCRIBE_TO_EVENTS); - subRelations.put("target", subscribes.getConfig_key() + "_topic"); - } else if (isDataRouterType(subscribes.getType())) { - subRelations.put("type", SUBSCRIBE_TO_FILES); - subRelations.put("target", subscribes.getConfig_key() + "_feed"); - } - return subRelations; - } -} 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 deleted file mode 100644 index 162337e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java +++ /dev/null @@ -1,123 +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.models.dmaapbp; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; -import lombok.Setter; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) -public class DmaapStreams { - - private String name; - private GetInput location; - private GetInput client_role; - private String type; - - private GetInput username; - private GetInput password; - //private GetInput delivery_url; - - private GetInput privileged; - private GetInput decompress; - - private String route; - private String scheme; - - public TreeMap<String, LinkedHashMap<String, Object>> createStreams( - TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key, - String route, char o) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - LinkedHashMap<String, Object> stringType = new LinkedHashMap(); - stringType.put("type", "string"); - - //set the name - this.setName(name); - - //set the type - this.setType(type); - - //set the location - GetInput location = new GetInput(); - location.setBpInputName(key + "_" + name + "_location"); - retInputs.put(key + "_" + name + "_location", stringType); - this.setLocation(location); - - //if its data router we need to add some more - if (isDataRouterType(type)) { - if ('s' == o) { - //set the username - GetInput username = new GetInput(); - username.setBpInputName(key + "_" + name + "_username"); - this.setUsername(username); - retInputs.put(key + "_" + name + "_username", stringType); - - //set the password - GetInput password = new GetInput(); - password.setBpInputName(key + "_" + name + "_password"); - this.setPassword(password); - retInputs.put(key + "_" + name + "_password", stringType); - - //set privileged - GetInput priviliged = new GetInput(); - priviliged.setBpInputName(key + "_" + name + "_priviliged"); - this.setPrivileged(priviliged); - retInputs.put(key + "_" + name + "_priviliged", stringType); - - //set decompress - GetInput decompress = new GetInput(); - decompress.setBpInputName(key + "_" + name + "_decompress"); - this.setDecompress(decompress); - retInputs.put(key + "_" + name + "_decompress", stringType); - - this.setRoute(route); - this.setScheme("https"); - } - -// //set the delivery url -// GetInput delivery = new GetInput(); -// delivery.setGet_input(name + "_delivery_url"); -// this.setDelivery_url(delivery); -// retInputs.put(name + "delivery_url", stringType); - - } else { - //set the client role - GetInput client = new GetInput(); - client.setBpInputName(key + "_" + name + "_client_role"); - this.setClient_role(client); - retInputs.put(key + "_" + name + "_client_role", stringType); - } - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java deleted file mode 100644 index c9e531f..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java +++ /dev/null @@ -1,28 +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.onapbp; - -import lombok.Getter; import lombok.Setter; - -@Getter @Setter -public class LogDirectory { - private Object log_directory; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java deleted file mode 100644 index d9f3c16..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java +++ /dev/null @@ -1,95 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.onapbp; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.Imports; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) - -public class OnapBlueprint extends Blueprint { - - public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) { - - //create the inputs that will be used - TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>(); - //set the tosca definition which is the same for everything - this.setTosca_definitions_version(CLOUDIFY_DSL_1_3); - - //set the imports - if (!"".equals(importPath)) { - Imports imps = new Imports(); - this.setImports(imps.createImportsFromFile(importPath)); - } else { - Imports imps = new Imports(); - this.setImports(imps.createOnapImports()); - } - - //create the node template - TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>(); - String nodeName = cs.getSelf().getName(); - - //create the onap node that will be used - OnapNode node = new OnapNode(); - inputs = node.createOnapNode(inputs, cs, override); - nodeTemplate.put(nodeName, node); - this.setNode_templates(nodeTemplate); - - //if present in component spec, populate policyNode information in the blueprint - if (cs.getPolicyInfo() != null) { - PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs); - } - - //if present in component spec, populate pgaasNodes information in the blueprint - if (cs.getAuxilary().getDatabases() != null) { - PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs); - } - - //set the inputs - this.setInputs(inputs); - - Blueprint bp = new Blueprint(); - bp.setImports(this.getImports()); - bp.setInputs(this.getInputs()); - bp.setNode_templates(this.getNode_templates()); - bp.setTosca_definitions_version(this.getTosca_definitions_version()); - - return bp; - - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java deleted file mode 100644 index 9daea56..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java +++ /dev/null @@ -1,94 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.onapbp; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Interfaces; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.Properties; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -@JsonIgnoreProperties(ignoreUnknown = true) -@Getter -@Setter -@EqualsAndHashCode(callSuper = false) -@NoArgsConstructor -@JsonInclude(value = Include.NON_NULL) - -public class OnapNode extends Node { - - public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode( - TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); - retInputs = inps; - - //create and set the interfaces - Interfaces inter = new Interfaces(); - retInputs = inter.createInterface(retInputs, cs); - TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>(); - interfaces.put("cloudify.interfaces.lifecycle", inter); - this.setInterfaces(interfaces); - - //set the type - this.setType(CONTENERIZED_SERVICE_COMPONENT); - - //create and set the relationships - ArrayList<LinkedHashMap<String, String>> rets = new ArrayList(); - - //add relationship for policy if exist - if (cs.getPolicyInfo() != null) { - ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder - .getPolicyRelationships(cs); - rets.addAll(policyRelationshipsList); - } - - //add relationships and env_variables for pgaas dbs if exist - if (cs.getAuxilary().getDatabases() != null) { - ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder - .getPgaasNodeRelationships(cs); - rets.addAll(pgaasRelationshipsList); - } - - this.setRelationships(rets); - - //set the properties - Properties props = new Properties(); - retInputs = props.createOnapProperties(retInputs, cs, override); - this.setProperties(props); - - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java deleted file mode 100644 index 81bc440..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java +++ /dev/null @@ -1,136 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.policymodel; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_SIMPLE_YAML; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; - -@Getter -@Setter -@JsonInclude(JsonInclude.Include.NON_NULL) - -public class PolicyModel { - - private String tosca_definition_version; - private TreeMap<String, PolicyModelNode> node_types; - private TreeMap<String, PolicyModelNode> data_types; - - public ArrayList<PolicyModel> createPolicyModels(ComponentSpec cs, String filePath) { - ArrayList<PolicyModel> models = new ArrayList(); - Parameters[] params = cs.getParameters(); - - ArrayList<String> groups = new ArrayList<String>(); - groups = getModelGroups(params); - - for (String s : groups) { - PolicyModel model = new PolicyModel(); - model = model.createPolicyModel(s, params); - //models.add(model); - policyModelToYaml(filePath, model, s); - } - -// for(PolicyModel p: models) { -// policyModelToYaml(filePath, p); -// } - - return models; - } - - public ArrayList<String> getModelGroups(Parameters[] params) { - ArrayList<String> groups = new ArrayList(); - - for (Parameters p : params) { - if (p.isPolicy_editable()) { - if (groups.isEmpty()) { - groups.add(p.getPolicy_group()); - } else { - if (!groups.contains(p.getPolicy_group())) { - groups.add(p.getPolicy_group()); - } - } - } - } - - return groups; - } - - public PolicyModel createPolicyModel(String s, Parameters[] params) { - PolicyModel model = new PolicyModel(); - model.setTosca_definition_version(TOSCA_SIMPLE_YAML); - - PolicyModelNode node = new PolicyModelNode(); - String hasEntryScheme = node.createNodeType(s, params); - String nodeTypeName = "onap.policy." + s; - TreeMap<String, PolicyModelNode> nodeType = new TreeMap(); - nodeType.put(nodeTypeName, node); - model.setNode_types(nodeType); - - if (!hasEntryScheme.equals("")) { - PolicyModelNode data = new PolicyModelNode(); - TreeMap<String, PolicyModelNode> dataType = data.createDataTypes(hasEntryScheme, params); - model.setData_types(dataType); - } - - return model; - } - - public void policyModelToYaml(String path, PolicyModel p, String name) { - File outputFile; - String filePath = path + "/" + name + ".yml"; - File policyFile = new File(filePath); - ObjectMapper policyMapper = new ObjectMapper( - new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - outputFile = new File(path, name + ".yml"); - outputFile.getParentFile().mkdirs(); - - try { - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true))); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - policyMapper.writeValue(outputFile, p); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println("model " + name + " created"); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java deleted file mode 100644 index 89321de..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java +++ /dev/null @@ -1,147 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications 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.policymodel; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_DATATYPES_ROOT; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_NODES_ROOT; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.componentspec.EntrySchemaObj; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.PolicySchemaObj; - -@Getter -@Setter -@JsonInclude(JsonInclude.Include.NON_NULL) -public class PolicyModelNode { - - private String derived_from; - private TreeMap<String, PolicyProperties> properties; - - public String createNodeType(String policyName, Parameters[] params) { - String hasEntrySchema = ""; - - TreeMap<String, PolicyProperties> props = new TreeMap(); - for (Parameters p : params) { - if (p.getPolicy_group() != null) { - if (p.getPolicy_group().equals(policyName)) { - String name = p.getName(); - String type = p.getType(); - PolicyProperties polProps = new PolicyProperties(); - if (p.getPolicy_schema() != null) { - polProps.setType("map"); - HashMap<String, String> entrySchema = new HashMap(); - entrySchema.put("type", "onap.datatypes." + name); - //ArrayList<String> entrySchema = new ArrayList<String>(); - //entrySchema.add("type: onap.data." + name); - polProps.setEntry_schema(entrySchema); - hasEntrySchema = name; - props.put(name, polProps); - } else { - polProps.setType(type); - props.put(name, polProps); - } - } - } - } - - this.setDerived_from(TOSCA_DATATYPES_ROOT); - this.setProperties(props); - return hasEntrySchema; - } - - public TreeMap<String, PolicyModelNode> createDataTypes(String param, Parameters[] parameters) { - TreeMap<String, PolicyModelNode> dataType = new TreeMap<String, PolicyModelNode>(); - - PolicyModelNode node = new PolicyModelNode(); - node.setDerived_from(TOSCA_DATATYPES_ROOT); - - TreeMap<String, PolicyProperties> properties = new TreeMap(); - - Parameters par = new Parameters(); - for (Parameters p : parameters) { - if (p.getName().equals(param)) { - par = p; - break; - } - } - - for (PolicySchemaObj pol : par.getPolicy_schema()) { - if (pol.getEntry_schema() != null) { - PolicyProperties prop = new PolicyProperties(); - prop.setType("map"); - HashMap<String, String> schema = new HashMap(); - schema.put("type", "onap.datatypes." + pol.getName()); -// prop.setType("list"); -// ArrayList<String> schema = new ArrayList(); -// schema.add("type: onap.data." + pol.getName()); - prop.setEntry_schema(schema); - properties.put(pol.getName(), prop); - dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName()); - } else { - PolicyProperties prop = new PolicyProperties(); - prop.setType(pol.getType()); - properties.put(pol.getName(), prop); - } - } - - node.setProperties(properties); - dataType.put("onap.datatypes." + param, node); - return dataType; - } - - private TreeMap<String, PolicyModelNode> translateEntrySchema(TreeMap<String, PolicyModelNode> dataType, - EntrySchemaObj[] entry, String name) { - TreeMap<String, PolicyModelNode> data = dataType; - PolicyModelNode node = new PolicyModelNode(); - node.setDerived_from(TOSCA_NODES_ROOT); - TreeMap<String, PolicyProperties> properties = new TreeMap<String, PolicyProperties>(); - - for (EntrySchemaObj e : entry) { - if (e.getEntry_schema() != null) { - PolicyProperties prop = new PolicyProperties(); - prop.setType("list"); - ArrayList<String> schema = new ArrayList<String>(); - schema.add("type: onap.datatypes." + e.getName()); - prop.setEntry_schema(schema); - properties.put(e.getName(), prop); - data = translateEntrySchema(data, e.getEntry_schema(), e.getName()); - node.setProperties(properties); - } else { - PolicyProperties prop = new PolicyProperties(); - prop.setType(e.getType()); - properties.put(e.getName(), prop); - node.setProperties(properties); - } - } - - dataType.put("onap.datatypes." + name, node); - return data; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java deleted file mode 100644 index 6faf78d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java +++ /dev/null @@ -1,41 +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.policymodel; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.blueprint.Node; - -import com.fasterxml.jackson.annotation.JsonInclude; - -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -@JsonInclude(JsonInclude.Include.NON_NULL) -public class PolicyProperties { - - private String type; - private Object entry_schema; - -} 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 deleted file mode 100644 index b978701..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java +++ /dev/null @@ -1,286 +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 static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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 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; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.dmaapbp.DmaapNode; -import org.onap.blueprintgenerator.models.onapbp.OnapNode; -import org.onap.blueprintgenerator.models.policymodel.PolicyModel; -import picocli.CommandLine; - -// TODO: Auto-generated Javadoc - -/** - * The Class BlueprintGeneratorTest. - */ -public class BlueprintGeneratorTest { - - /** - * Component spec test. - * - */ - @Test - public void componentSpecTest() { - ComponentSpec spec = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - spec.createComponentSpecFromString(test.getComponentSpecAsString()); - ComponentSpec expectedSpec = test.getComponentSpec(); - - assertEquals(expectedSpec.getSelf(), spec.getSelf()); - assertEquals(expectedSpec.getServices(), spec.getServices()); - assertEquals(expectedSpec.getStreams(), spec.getStreams()); - assertArrayEquals(expectedSpec.getParameters(), spec.getParameters()); - assertEquals(expectedSpec.getAuxilary(), spec.getAuxilary()); - assertArrayEquals(expectedSpec.getArtifacts(), spec.getArtifacts()); - } - - /** - * Tosca definition test. - */ - @Test - public void toscaDefinitionTest() { - ComponentSpec cs = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - cs.createComponentSpecFromString(test.getComponentSpecAsString()); - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - assertEquals("cloudify_dsl_1_3", bp.getTosca_definitions_version()); - } - - /** - * Imports test. - */ - @Test - public void importsTest() { - ComponentSpec cs = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - cs.createComponentSpecFromString(test.getComponentSpecAsString()); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - ArrayList<String> imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dcaepolicyplugin?version=2.4.0"); - assertEquals(imps, bp.getImports()); - } - - @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<>(); - - //mr inputs - LinkedHashMap<String, Object> stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //necessary inputs - LinkedHashMap<String, Object> tag = new LinkedHashMap<>(); - tag.put("type", "string"); - String tester = "test.tester"; - tag.put("default", '"' + tester + '"'); - inputs.put("tag_version", tag); - - inputs.put("log_directory", stringType); - - LinkedHashMap<String, Object> 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<String, Object> 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<>(); - 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<>(); - 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); - } - - @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<>(); - ports.add("concat: [\"80:\", {get_input: external_port }]"); - ports.add("concat: [\"99:\", {get_input: external_port }]"); - } - - @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("testParam1", par.getBpInputName()); - } - - @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"); - - assertFalse(node.getProperties().getApplication_config().getStreams_publishes().isEmpty()); - } - - @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 - assertNotNull(dmaap.getProperties().getStreams_publishes()); - assertNotNull(dmaap.getProperties().getStreams_subscribes()); - } - - @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"); - } -} 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 deleted file mode 100644 index 8adf03d..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java +++ /dev/null @@ -1,163 +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.core; - -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.Node; -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; -import java.util.LinkedHashMap; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -@RunWith(Parameterized.class) -public class TlsInfoTest { - - @Parameterized.Parameter - public char bpType; - - @Parameterized.Parameters(name = "Blueprint type: {0}") - public static List<Character> data() { - return Arrays.asList('o', 'd'); - } - - @Test - public void useTlsTrueAndUseExternalTlsTrueTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json"); - - assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true); - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); - } - - @Test - public void useTlsFalseAndUseExternalTlsFalseTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json"); - - assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false); - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false); - } - - @Test - public void useTlsTrueAndNoExternalTlsFlagTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json"); - - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); - assertBlueprintHasNoExternalTlsInfo(bp); - } - - @Test - public void noTlsInfo(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json"); - - assertBlueprintHasNoTlsInfo(bp); - assertBlueprintHasNoExternalTlsInfo(bp); - } - - private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) { - //should create proper inputs - assertContainsInputWithDefault(bp, "external_cert_use_external_tls", useFlagDefault); - assertContainsInputWithDefault(bp, "external_cert_ca_name", "\"RA\""); - assertContainsInputWithDefault(bp, "external_cert_cert_type", "\"P12\""); - assertContainsInputWithDefault(bp, "external_cert_common_name", "\"sample.onap.org\""); - assertContainsInputWithDefault(bp, "external_cert_sans", - "\"sample.onap.org:component.sample.onap.org\""); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should create proper externalTlsInfo object in node properties - ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); - assertNotNull(externalTlsInfo); - - 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()); - - ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters(); - assertNotNull(extCertParams); - - assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName()); - assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName()); - } - - private void assertBlueprintContainsTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) { - //shold create proper inputs - assertContainsInputWithDefault(bp, "use_tls", useFlagDefault); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should create proper tlsInfo object in node properties - TlsInfo tlsInfo = node.getProperties().getTls_info(); - assertEquals("use_tls", tlsInfo.getUseTls().getBpInputName()); - assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory()); - - } - - private void assertBlueprintHasNoExternalTlsInfo(Blueprint bp) { - //should not create inputs for external tls - assertFalse(bp.getInputs().containsKey("external_cert_use_external_tls")); - assertFalse(bp.getInputs().containsKey("external_cert_common_name")); - assertFalse(bp.getInputs().containsKey("external_cert_ca_name")); - assertFalse(bp.getInputs().containsKey("external_cert_sans")); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should not create externalTlsInfo object in node properties - ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); - assertNull(externalTlsInfo); - } - - - private void assertBlueprintHasNoTlsInfo(Blueprint bp) { - //should not create inputs for tls - assertFalse(bp.getInputs().containsKey("use_tls")); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should not create tlsInfo object in node properties - assertNull(node.getProperties().getTls_info()); - } - - 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 Blueprint createBlueprintFromFile(String path) { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile(path); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", this.bpType, "", ""); - return bp; - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java deleted file mode 100644 index 173d230..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java +++ /dev/null @@ -1,62 +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 static org.junit.Assert.assertEquals; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import java.util.stream.Collectors; -import org.junit.Test; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -public class AppconfigTest { - - @Test - public void createAppconfigShouldReturnExpectedResult() throws FileNotFoundException { - TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>(); - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - TreeMap<String, LinkedHashMap<String, Object>> result = new Appconfig().createAppconfig(inputs, cs, "", false); - - assertEquals(getExpectedStringFromFile(), result.toString()); - } - - private String getExpectedStringFromFile() throws FileNotFoundException { - File file = new File("TestCases/expects/createAppConfigResult.txt"); - InputStream inputStream = new FileInputStream(file); - return readFromInputStream(inputStream); - } - - private String readFromInputStream(InputStream inputStream) { - return new BufferedReader( - new InputStreamReader(inputStream, StandardCharsets.UTF_8)) - .lines() - .collect(Collectors.joining("")); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java deleted file mode 100644 index 1ce296a..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*============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; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; - -public class ImportsTest { - - private final List<String> expectedImports = Arrays.asList( - "https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml", - "plugin:k8splugin?version=3.4.1", - "plugin:pgaas?version=1.3.0", - "plugin:clamppolicyplugin?version=1.1.0", - "plugin:dmaap?version=1.5.0" - ); - - @Test - public void shouldReadImportsFromFile() { - ArrayList<String> importsFromFile = Imports.createImportsFromFile("TestCases/imports/imports.yaml"); - assertEquals(expectedImports, importsFromFile); - } - - @Test - public void shouldRemoveBlankImportsFromFile() { - ArrayList<String> importsFromFile = - Imports.createImportsFromFile("TestCases/imports/importsWithBlanks.yaml"); - assertEquals(expectedImports, importsFromFile); - } - -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java deleted file mode 100644 index cf12da1..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java +++ /dev/null @@ -1,38 +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 static org.junit.Assert.assertEquals; - -import java.util.LinkedHashMap; -import java.util.TreeMap; -import org.junit.Test; - -public class ResourceConfigTest { - - @Test - public void createResourceConfig() { - TreeMap<String, LinkedHashMap<String, Object>> result = new ResourceConfig() - .createResourceConfig(new TreeMap<>(), "demo"); - - String expectedResult = "{demo_cpu_limit={type=string, default=250m}, demo_cpu_request={type=string, default=250m}, demo_memory_limit={type=string, default=128Mi}, demo_memory_request={type=string, default=128Mi}}"; - assertEquals(expectedResult, result.toString()); - } -} 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 deleted file mode 100644 index 1cdb58b..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*============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.assertEquals; -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)); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java deleted file mode 100644 index 9e31002..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java +++ /dev/null @@ -1,245 +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.dmaapbp; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.componentspec.Artifacts; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Self; -import org.onap.blueprintgenerator.models.componentspec.Streams; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -public class DmaapBlueprintTest { - - private static final String MOCKED_NAME = "sample.name"; - private static final String MESSAGE_ROUTER_TYPE_1 = "message_router"; - private static final String MESSAGE_ROUTER_TYPE_2 = "message router"; - private static final String DATA_ROUTER_TYPE_1 = "data_router"; - private static final String DATA_ROUTER_TYPE_2 = "data router"; - private static final String CONFIG_KEY_1 = "Configkey1"; - private static final String CONFIG_KEY_2 = "Configkey2"; - - private static final String TOPIC_NODE_1 = CONFIG_KEY_1 + "_topic"; - private static final String TOPIC_NODE_2 = CONFIG_KEY_2 + "_topic"; - private static final String FEED_NODE_1 = CONFIG_KEY_1 + "_feed"; - private static final String FEED_NODE_2 = CONFIG_KEY_2 + "_feed"; - - private static final String SAMPLE_FORMAT = "Format"; - private static final String SAMPLE_VERSION = "1.0.0"; - private static final String SAMPLE_ROUTE = "SampleRoute"; - private static final String SAMPLE_DESCRIPTION = "sample description"; - private static final String SAMPLE_PORTS = "8080:8080"; - private static final String SAMPLE_ARTIFACT_TYPE = "test"; - private static final String SAMPLE_ARTIFACT_URI = "test_uri"; - - @Test - public void dmaapBlueprintShouldHaveNodeTemplateWithDmaapNode() { - - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertTrue(resultBlueprint.getNode_templates().get(MOCKED_NAME) instanceof DmaapNode); - } - - @Test - public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsPublishes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(getMessageRouterPublishes()); - streams.setSubscribes(new Subscribes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2)); - - } - - @Test - public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsSubscribes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(new Publishes[0]); - streams.setSubscribes(getMessageRouterSubscribes()); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2)); - - } - - @Test - public void nodeTemplateHasFeedNodeWhenAddDataRouterAsPublishes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(getDataRouterPublishes()); - streams.setSubscribes(new Subscribes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2)); - - } - - @Test - public void nodeTemplateHasFeedNodeWhenAddDataRouterAsSubscribes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(new Publishes[0]); - streams.setSubscribes(getDataRouterSubscribes()); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2)); - - } - - private Publishes[] getMessageRouterPublishes() { - List<Publishes> publishesList = new ArrayList<>(); - - publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1)); - publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2)); - return publishesList.toArray(new Publishes[0]); - } - - private Subscribes[] getMessageRouterSubscribes() { - List<Subscribes> subscribesList = new ArrayList<>(); - - subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1)); - subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2)); - return subscribesList.toArray(new Subscribes[0]); - } - - private Publishes[] getDataRouterPublishes() { - List<Publishes> publishesList = new ArrayList<>(); - - publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1)); - publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2)); - return publishesList.toArray(new Publishes[0]); - } - - private Subscribes[] getDataRouterSubscribes() { - List<Subscribes> subscribesList = new ArrayList<>(); - - subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1)); - subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2)); - return subscribesList.toArray(new Subscribes[0]); - } - - private Publishes createSamplePublishes(String type, String key) { - Publishes publishes = new Publishes(); - - publishes.setType(type); - publishes.setConfig_key(key); - publishes.setFormat(SAMPLE_FORMAT); - publishes.setVersion(SAMPLE_VERSION); - publishes.setRoute(SAMPLE_ROUTE); - - return publishes; - } - - private Subscribes createSampleSubscribes(String type, String key) { - Subscribes subscribes = new Subscribes(); - - subscribes.setType(type); - subscribes.setConfig_key(key); - subscribes.setFormat(SAMPLE_FORMAT); - subscribes.setVersion(SAMPLE_FORMAT); - subscribes.setRoute(SAMPLE_ROUTE); - - return subscribes; - } - - private ComponentSpec getMockedComponentSpec() { - Self self = mock(Self.class); - when(self.getDescription()).thenReturn(SAMPLE_DESCRIPTION); - when(self.getName()).thenReturn(MOCKED_NAME); - - Auxilary auxilary = mock(Auxilary.class); - ArrayList<Object> ports = new ArrayList<>(); - ports.add(SAMPLE_PORTS); - when(auxilary.getPorts()).thenReturn(ports); - - Streams streams = mock(Streams.class); - when(streams.getPublishes()).thenReturn(new Publishes[0]); - when(streams.getSubscribes()).thenReturn(new Subscribes[0]); - - Artifacts artifact = new Artifacts(); - artifact.setType(SAMPLE_ARTIFACT_TYPE); - artifact.setUri(SAMPLE_ARTIFACT_URI); - - Artifacts[] arrayArtifacts = new Artifacts[10]; - arrayArtifacts[0] = artifact; - - ComponentSpec componentSpec = mock(ComponentSpec.class); - when(componentSpec.getSelf()).thenReturn(self); - when(componentSpec.getAuxilary()).thenReturn(auxilary); - when(componentSpec.getStreams()).thenReturn(streams); - when(componentSpec.getArtifacts()).thenReturn(arrayArtifacts); - when(componentSpec.getParameters()).thenReturn(new Parameters[0]); - when(componentSpec.getSelfName()).thenReturn(MOCKED_NAME); - return componentSpec; - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java deleted file mode 100644 index 83419e5..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java +++ /dev/null @@ -1,224 +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.dmaapbp; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC; - -import java.util.Map; -import java.util.TreeMap; -import org.junit.Test; -import org.onap.blueprintgenerator.core.TestComponentSpec; -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.Streams; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -public class DmaapNodeTest { - - private static final String DATA_ROUTER_TYPE = "data_router"; - private static final String MESSAGE_ROUTER_TYPE = "message_router"; - - private static final String CONFIG_KEY = "Configkey"; - - private static final String SAMPLE_FORMAT = "Format"; - private static final String SAMPLE_VERSION = "1.0.0"; - private static final String SAMPLE_ROUTE = "SampleRoute"; - private static final String TYPE = "type"; - private static final String TARGET = "target"; - - - @Test - public void dmaapNodeShouldHaveExpectedNodeType() { - - ComponentSpec mockedComponentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(mockedComponentSpec, new TreeMap<>(), ""); - - assertEquals(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP, dmaapNode.getType()); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterPublishes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(createSamplePublishes(MESSAGE_ROUTER_TYPE)); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map<String, String> relationship = dmaapNode.getRelationships().get(0); - - assertNotNull(relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterPublishes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(createSamplePublishes(DATA_ROUTER_TYPE)); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map<String, String> relationship = dmaapNode.getRelationships().get(0); - - assertNotNull(relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterSubscribes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(createSampleSubscribes(MESSAGE_ROUTER_TYPE)); - streams.setPublishes(new Publishes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map<String, String> relationship = dmaapNode.getRelationships().get(0); - - assertEquals(SUBSCRIBE_TO_EVENTS, relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterSubscribes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(createSampleSubscribes(DATA_ROUTER_TYPE)); - streams.setPublishes(new Publishes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map<String, String> relationship = dmaapNode.getRelationships().get(0); - - assertEquals(SUBSCRIBE_TO_FILES, relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createFeedNodeShouldSetFeedNodeType() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createFeedNode(componentSpec, new TreeMap<>(), ""); - - assertEquals(FEED, dmaapNode.getType()); - } - - @Test - public void feedNodePropertiesShouldHaveUseExistingField() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createFeedNode(componentSpec, new TreeMap<>() ,""); - - assertTrue(dmaapNode.getProperties().getUseExisting()); - } - - @Test - public void createTopicNodeShouldSetTopicNodeType() { - - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createTopicNode(componentSpec, new TreeMap<>(), ""); - - assertEquals(TOPIC, dmaapNode.getType()); - } - - @Test - public void topicNodePropertiesShouldNotHaveUseExistingField() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createTopicNode(componentSpec, new TreeMap<>() ,""); - - assertNull(dmaapNode.getProperties().getUseExisting()); - } - - private Publishes[] createSamplePublishes(String type) { - Publishes publishes = new Publishes(); - - publishes.setType(type); - publishes.setConfig_key(CONFIG_KEY); - publishes.setFormat(SAMPLE_FORMAT); - publishes.setVersion(SAMPLE_VERSION); - publishes.setRoute(SAMPLE_ROUTE); - - return new Publishes[]{publishes}; - } - - private Subscribes[] createSampleSubscribes(String type) { - Subscribes subscribes = new Subscribes(); - - subscribes.setType(type); - subscribes.setConfig_key(CONFIG_KEY); - subscribes.setFormat(SAMPLE_FORMAT); - subscribes.setVersion(SAMPLE_VERSION); - subscribes.setRoute(SAMPLE_ROUTE); - - return new Subscribes[]{subscribes}; - } - - private ComponentSpec getSpiedComponentSpecWithoutRelationships() { - ComponentSpec baseComponentSpec = new ComponentSpec(); - baseComponentSpec.createComponentSpecFromString(new TestComponentSpec().getComponentSpecAsString()); - ComponentSpec componentSpec = spy(baseComponentSpec); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(new Publishes[0]); - when(componentSpec.getStreams()).thenReturn(streams); - - Auxilary auxilary = spy(baseComponentSpec.getAuxilary()); - when(auxilary.getDatabases()).thenReturn(null); - - when(componentSpec.getAuxilary()).thenReturn(auxilary); - when(componentSpec.getPolicyInfo()).thenReturn(null); - - return componentSpec; - } -} |