From 032ce4ec7c3d7ac138555dfe980ca53ebbf39f01 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 30 Jan 2020 11:23:57 -0500 Subject: Removing blueprints-processor Blueprints-Processor is deprecated, use CCSDK/CDS instead Change-Id: I0abc96061c3c5edc6c5d02bcd6f35e18e31882a7 Issue-ID: CCSDK-2051 Signed-off-by: Singal, Kapil (ks220y) --- .../model/ResourceDictionaryUtilsTest.java | 216 -------------------- .../features/model/utils/JsonParserUtilsTest.java | 43 ---- .../ccsdk/features/model/utils/JsonUtilsTest.java | 103 ---------- .../model/utils/ResourceAssignmentUtilsTest.java | 198 ------------------- .../model/utils/ServiceTemplateUtilsTest.java | 77 -------- .../model/utils/TransformationUtilsTest.java | 90 --------- .../validator/ServiceTemplateValidationTest.java | 47 ----- .../features/params/service/ComponentNodeTest.java | 140 ------------- .../params/service/ConfigModelServiceTest.java | 219 --------------------- .../params/service/ExpressionUtilsTest.java | 76 ------- .../features/params/service/MockComponentNode.java | 62 ------ .../params/service/ServiceTemplateCreateUtils.java | 193 ------------------ 12 files changed, 1464 deletions(-) delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java (limited to 'blueprints-processor/plugin/model-provider/src/test/java') diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java deleted file mode 100644 index 760c245fd..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model; - -import java.util.Arrays; -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesProperties; -import org.onap.ccsdk.features.model.utils.ResourceDictionaryUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceDictionaryUtilsTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); - - @Test - public void validateSingleInputSource() { - try { - logger.info(" **************** Validating validateSingleInputSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("input", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment input sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment input sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment input sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void validateSingleDbSource() { - try { - logger.info(" **************** Validating validateSingleDbSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-db-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("db", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertNotNull("Resource assignment db sourceName sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - - Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies()); - Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2, - resourceAssignment.getDependencies().size()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void validateMultiSource() { - try { - logger.info(" **************** Validating validateMultiSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-multi-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("input", sourceDef); - sources.put("mdsal", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - Assert.assertNull("Resource assignment multi sourceName sourceName definition is present ", - resourceAssignment.getDictionarySource()); - Assert.assertNull("Resource assignment multi sourceName dependecy is present ", - resourceAssignment.getDependencies()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testSourceDefault() { - logger.info(" **************** Validating testSourceDefault *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("default", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment default sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment default sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment default sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - } - - @Test - public void testSourceMdsal() { - logger.info(" **************** Validating testSourceMdsal *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("mdsal", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment mdsal sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment mdsal sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment mdsal sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java deleted file mode 100644 index 8ff1ff8de..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.utils; - -import org.junit.Assert; -import org.junit.Test; -import com.fasterxml.jackson.databind.JsonNode; - -public class JsonParserUtilsTest { - - @Test - public void testParse() { - final String jsonExample = "{\"key\":\"value\"}"; - - JsonNode rootJsonNode = JsonParserUtils.parse(jsonExample, "$"); - Assert.assertEquals(jsonExample, rootJsonNode.toString()); - - JsonNode keyJsonNode = JsonParserUtils.parse(rootJsonNode, "$['key']"); - Assert.assertEquals("value", keyJsonNode.asText()); - - Assert.assertEquals(jsonExample, - JsonParserUtils.parseNSet("{\"key\":\"NOT_VALUE\"}", "$['key']", keyJsonNode).toString()); - - rootJsonNode = JsonParserUtils.parse("{\"key\":\"NOT_VALUE\"}", "$"); - Assert.assertEquals(jsonExample, JsonParserUtils.parseNSet(rootJsonNode, "$['key']", keyJsonNode).toString()); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java deleted file mode 100644 index 96d5f89f5..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.onap.ccsdk.features.model.ValidTypes; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class JsonUtilsTest { - - @Test - public void testPopulatePrimitiveValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populatePrimitiveValues("key1", "value", "", objectNode); - JsonUtils.populatePrimitiveValues("key2", true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveValues("key3", 1, ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveValues("key4", 1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode); - JsonUtils.populatePrimitiveValues("key5", "13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - - assertTrue("value".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean()); - assertTrue(objectNode.get("key3").asInt() == 1); - assertTrue(objectNode.get("key4").floatValue() == 1.1f); - assertTrue("13213123131".equals(objectNode.get("key5").asText())); - } - - @Test - public void testPopulatePrimitiveValuesArrayNode() { - ArrayNode objectNode = JsonNodeFactory.instance.arrayNode(); - JsonUtils.populatePrimitiveValues("value", "", objectNode); - JsonUtils.populatePrimitiveValues(true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveValues(1, ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveValues(1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode); - JsonUtils.populatePrimitiveValues("13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - - assertTrue(objectNode.size() == 5); - } - - @Test - public void testPopulatePrimitiveDefaultValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populatePrimitiveDefaultValues("key1", "", objectNode); - JsonUtils.populatePrimitiveDefaultValues("key2", ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveDefaultValues("key3", ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveDefaultValues("key4", ValidTypes.DATA_TYPE_FLOAT, objectNode); - - assertTrue("".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean() == false); - assertTrue(objectNode.get("key3").asInt() == 0); - assertTrue(objectNode.get("key4").floatValue() == 0.0f); - } - - @Test - public void testPopulatePrimitiveDefaultValuesForArrayNode() { - ArrayNode objectNode = JsonNodeFactory.instance.arrayNode(); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode("", objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_FLOAT, objectNode); - - assertTrue(objectNode.size() == 4); - } - - @Test - public void testPopulateJsonNodeValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populateJsonNodeValues("key1", JsonNodeFactory.instance.textNode("value"), - ValidTypes.DATA_TYPE_STRING, objectNode); - JsonUtils.populateJsonNodeValues("key2", JsonNodeFactory.instance.booleanNode(true), - ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populateJsonNodeValues("key3", JsonNodeFactory.instance.numberNode(1), ValidTypes.DATA_TYPE_INTEGER, - objectNode); - JsonUtils.populateJsonNodeValues("key4", JsonNodeFactory.instance.numberNode(1.1f), ValidTypes.DATA_TYPE_FLOAT, - objectNode); - JsonUtils.populateJsonNodeValues("key5", JsonNodeFactory.instance.textNode("13213123131"), - ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - assertTrue(objectNode.get("key2").asBoolean()); - - assertTrue("value".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean()); - assertTrue(objectNode.get("key3").asInt() == 1); - assertTrue(objectNode.get("key4").floatValue() == 1.1f); - assertTrue("13213123131".equals(objectNode.get("key5").asText())); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java deleted file mode 100644 index 60ef24049..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertTrue; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Test; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ResourceAssignmentUtilsTest { - - @Test - public void testGetArtifactNodeContent() { - String nodeTemplateName = "nodeTemplateNmae"; - String templateContent = "content"; - Map context = new HashMap(); - context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content", templateContent); - - String retrievedContent = ResourceAssignmentUtils.getArtifactNodeContent(nodeTemplateName, context); - - assertTrue(templateContent.equals(retrievedContent)); - } - - @Test - public void testGetArtifactNodeMapping() { - String nodeTemplateName = "nodeTemplateNmae"; - String templateContent = "[]"; - Map context = new HashMap(); - context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping", templateContent); - - List map = ResourceAssignmentUtils.getArtifactNodeMapping(nodeTemplateName, context); - assertTrue(map.size() == 0); - } - - @Test - public void testCleanContextTemplateNDictionaryKeys() { - String recipeName = "recipe"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".", "value1"); - componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".", "value2"); - ResourceAssignmentUtils.cleanContextTemplateNDictionaryKeys(componentContext); - - assertTrue(componentContext.size() == 1); - } - - @Test - public void testGetDictionaryKeyValue() { - String recipeName = "recipe"; - String dictionaryName = "dictionaryKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName, - "value1"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setDictionaryName(dictionaryName); - - String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceAssignment); - assertTrue("value1".equals(value)); - } - - @Test - public void testGetDictionaryKeyValueWithDictionaryDefinition() { - String recipeName = "recipe"; - String dictionaryName = "dictionaryKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName, - "value1"); - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setName(dictionaryName); - - String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceDefinition); - assertTrue("value1".equals(value)); - } - - @Test - public void testGetTemplateKeyValue() { - String recipeName = "recipe"; - String templateKeyName = "templateKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName, - "value1"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName(templateKeyName); - - String value = (String) ResourceAssignmentUtils.getTemplateKeyValue(componentContext, resourceAssignment); - assertTrue("value1".equals(value)); - } - - @Test - public void testSetResourceDataValue() throws Exception { - String recipeName = "recipe"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, null); - Object value = "value"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue(value.equals(resourceAssignment.getProperty().getValue())); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_INTEGER, null); - value = "1"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((int) resourceAssignment.getProperty().getValue() == 1); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_BOOLEAN, null); - value = "true"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((boolean) resourceAssignment.getProperty().getValue()); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_FLOAT, null); - value = "1.1"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((float) resourceAssignment.getProperty().getValue() == 1.1f); - } - - @Test - public void testSetFailedResourceDataValue() throws Exception { - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value"); - String message = "message"; - ResourceAssignmentUtils.setFailedResourceDataValue(null, resourceAssignment, message); - - assertTrue(message.equals(resourceAssignment.getMessage())); - assertTrue(ConfigModelConstant.STATUS_FAILURE.equals(resourceAssignment.getStatus())); - } - - @Test(expected = ConfigModelException.class) - public void testAssertTemplateKeyValueNotNull() throws Exception { - Map componentContext = null; - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value"); - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } - - @Test - public void testGenerateResourceDataForAssignments() throws Exception { - List assignments = new ArrayList(); - assignments.add(createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "string")); - assignments.add(createResourceAssignment("name2", ValidTypes.DATA_TYPE_BOOLEAN, true)); - assignments.add(createResourceAssignment("name3", ValidTypes.DATA_TYPE_INTEGER, 1)); - assignments.add(createResourceAssignment("name4", ValidTypes.DATA_TYPE_FLOAT, 1.1f)); - assignments.add(createResourceAssignment("name5", ValidTypes.DATA_TYPE_TIMESTAMP, "1523908097735")); - assignments.add(createResourceAssignment("name6", "", new HashMap())); - ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - } - - public void testResourceAssignmentForNullEmptyValues() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - JsonNode raContent = - mapper.readTree(new File("src/test/resources/service_templates/ra-content-with-mising-value.json")); - - List assignments = - mapper.readValue(raContent.toString(), new TypeReference>() {}); - - ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - } - - private ResourceAssignment createResourceAssignment(String name, String dataType, Object value) { - PropertyDefinition property = new PropertyDefinition(); - property.setType(dataType); - property.setValue(value); - property.setRequired(true); - ResourceAssignment ra = new ResourceAssignment(); - ra.setName(name); - ra.setProperty(property); - return ra; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java deleted file mode 100644 index 525dda4e1..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.model.data.ArtifactDefinition; -import org.onap.ccsdk.features.model.data.CapabilityAssignment; -import org.onap.ccsdk.features.model.data.NodeTemplate; - -public class ServiceTemplateUtilsTest { - - ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils(); - - @Test - public void testPopulateVnfNodeProperties() { - NodeTemplate nodeTemplate = createNodeTemplate(); - - String nodeTemplateKey = "nodeTemplateKey"; - Map context = new HashMap(); - - Map result = - serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null); - - Assert.assertTrue(result.size() > 0); - } - - @Test - public void testPopulateNodeTemplateArtifacts() { - String nodeTemplateKey = "nodeTemplateKey"; - NodeTemplate nodeTemplate = createNodeTemplate(); - Map context = new HashMap(); - - Map result = - serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context); - - Assert.assertTrue(result.size() > 0); - } - - private NodeTemplate createNodeTemplate() { - NodeTemplate nodeTemplate = new NodeTemplate(); - Map properties = new HashMap(); - properties.put("prop1", "value"); - CapabilityAssignment capabilityAssignment = new CapabilityAssignment(); - capabilityAssignment.setProperties(properties); - Map capabilities = new HashMap(); - capabilities.put("key", capabilityAssignment); - nodeTemplate.setCapabilities(capabilities); - - ArtifactDefinition artifactDefinition = new ArtifactDefinition(); - artifactDefinition.setFile("file"); - artifactDefinition.setDeployPath("deployPath"); - artifactDefinition.setContent("content"); - Map artifacts = new HashMap(); - artifacts.put("artifactName1", artifactDefinition); - nodeTemplate.setArtifacts(artifacts); - - return nodeTemplate; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java deleted file mode 100644 index f73bc1af2..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import com.fasterxml.jackson.databind.JsonNode; - -public class TransformationUtilsTest { - - @Test - public void testGetJson() { - Map configparameters = new HashMap(); - configparameters.put("key", "value"); - String json = TransformationUtils.getJson(configparameters); - assertTrue("{\"key\":\"value\"}".equals(json)); - } - - @Test - public void testGetJsonNodeForString() { - String content = "{\"key\":\"value\"}"; - JsonNode jsonNodeForString = TransformationUtils.getJsonNodeForString(content); - assertNotNull(jsonNodeForString); - } - - @Test - public void testGetMapfromJson() { - String content = "{\"key\":\"value\"}"; - Map mapfromJson = TransformationUtils.getMapfromJson(content); - assertTrue(mapfromJson.size() == 1); - assertTrue("value".equals(mapfromJson.get("key"))); - } - - @Test - public void testGetMapfromJsonString() { - String content = "{\"key\":\"value\"}"; - Map mapfromJson = TransformationUtils.getMapfromJsonString(content); - assertTrue(mapfromJson.size() == 1); - assertTrue("value".equals(mapfromJson.get("key"))); - } - - @Test - public void testConvertJson2RootProperties() throws Exception { - Map context = new HashMap(); - String jsonContent = "{\"key\":\"value\"}"; - Map convertJson2RootProperties = - TransformationUtils.convertJson2RootProperties(context, jsonContent); - assertTrue(convertJson2RootProperties.size() == 1); - assertTrue("value".equals(convertJson2RootProperties.get("key"))); - } - - @SuppressWarnings("unchecked") - @Test - public void testGetJsonNodeAndTreeToValueAndConvertJson2Properties() throws Exception { - Map configparameters = new HashMap(); - configparameters.put("key", "value"); - JsonNode jsonNode = TransformationUtils.getJsonNode(configparameters); - assertNotNull(jsonNode); - - Map result = TransformationUtils.treeToValue(jsonNode, HashMap.class); - assertTrue("value".equals(result.get("key"))); - - result = TransformationUtils.convertJson2Properties(null, jsonNode, null); - assertTrue("value".equals(result.get("key"))); - } - - @Test - public void testGetJsonSchema() { - String jsonSchema = TransformationUtils.getJsonSchema(String.class); - assertNotNull(jsonSchema); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java deleted file mode 100644 index 72a49ebc7..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.nio.charset.Charset; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ServiceTemplateValidationTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class); - - @Test - public void validateServiceTemplate() { - try { - logger.info(" **************** Validating Default *****************"); - String serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader() - .getResourceAsStream("service_templates/default.json"), Charset.defaultCharset()); - ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator(); - serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent); - logger.info(" **************** Reqource Assignment *****************"); - serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader() - .getResourceAsStream("service_templates/resource_assignment.json"), Charset.defaultCharset()); - serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent); - } catch (Exception e) { - e.printStackTrace(); - } - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java deleted file mode 100644 index 9c048f48e..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.params.service; - -import static org.mockito.Matchers.any; -import java.io.File; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.testing.mock.osgi.MockOsgi; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNodeDelegate; -import org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.osgi.framework.BundleContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ComponentNodeTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeTest.class); - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - BundleContext bundleContext = MockOsgi.newBundleContext(); - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - MockComponentNode mockSvcLogicPlugin = new MockComponentNode(); - bundleContext.registerService(MockComponentNode.class, mockSvcLogicPlugin, null); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - } catch (SvcLogicException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @After - public void after() { - - } - - @Test - public void testProcess() { - - try { - String serviceTemplateContent = FileUtils.readFileToString( - new File("src/test/resources/componentnode/default.json"), Charset.defaultCharset()); - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - Map map = new HashMap<>(); - configModelService.convertServiceTemplate2Properties(serviceTemplateContent, map); - - SvcLogicContext ctx = new SvcLogicContext(); - map.forEach((name, value) -> { - if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) { - ctx.setAttribute(name, value); - } - }); - ctx.setAttribute("vnf-id", "1234"); - - ComponentNodeServiceImpl componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - - ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService); - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - - componentNodeDelegate.process(inParams, ctx); - TransformationUtils.printMap(inParams); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @Test(expected = SvcLogicException.class) - public void testFailure() throws Exception { - ComponentNodeServiceImpl componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - SvcLogicContext ctx = new SvcLogicContext(); - componentNodeDelegate.process(inParams, ctx); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java deleted file mode 100644 index 3e62fafd0..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.params.service; - -import static org.junit.Assert.fail; -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.domain.ConfigModel; -import org.onap.ccsdk.features.model.domain.ConfigModelContent; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigModelServiceTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceTest.class); - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - @Test - public void testConfigAssignmentInputOutputParams() throws Exception { - - String fileContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - context = configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context); - - Assert.assertNotNull("Failed to Prepare Context : ", context); - - context.put("request-id", "12345"); - context.put("vnf-id", "vnf12345"); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment"); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - // TransformationUtils.printProperty(inputContext.toProperties()); - - configModelServiceImpl.assignInParamsFromModel(inputContext, inparams); - Assert.assertNotNull("In Param is Null : ", inparams); - Assert.assertNotNull("Failed to get entity-id in Inparms : ", inparams.get("resource-id")); - Assert.assertEquals("Failed to get entity-id vlaue in Inparms ", String.valueOf("vnf12345"), - inparams.get("resource-id")); - Assert.assertNotNull("Failed to get request-id in Inparms : ", inparams.get("request-id")); - Assert.assertEquals("Failed to get request-id vlaue in Inparms ", String.valueOf("12345"), - inparams.get("request-id")); - - configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams); - logger.info("*************** Output Params *************"); - // TransformationUtils.printProperty(inputContext.toProperties()); - - } - - @Test - public void testConvertServiceTemplate2PropertiesComplex() throws Exception { - String fileContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - context.put("host-password", "1234"); - context.put("host-ip-address", "[123.23.34.45, 123.23.34.45]"); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context); - - // TransformationUtils.printMap(context); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment"); - logger.info("Before Input Result: " + inparams); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - configModelServiceImpl.assignInParamsFromModel(inputContext, inparams); - logger.info("----------Input Result: " + inparams); - - inputContext.setAttribute("assignment-params", "default-assigned"); - configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams); - - // TransformationUtils.printProperty(inputContext.toProperties()); - - } - - @Test - public void testGetNodeTemplateContent() throws Exception { - String templateContent = "{\"id\":\"id\"}"; - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent + ".content", - templateContent); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - String content = configModelServiceImpl.getNodeTemplateContent(context, templateContent); - - Assert.assertEquals(content, templateContent); - } - - @Test - public void testGetNodeTemplateMapping() throws Exception { - String templateContent = "{\"capabilities\":{\"mapping\":{\"properties\":{\"mapping\":[\"test\"]}}}}"; - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent, templateContent); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - configModelServiceImpl.getNodeTemplateMapping(context, templateContent); - // Assert.assertEquals(content, templateContent); - } - - @Test - public void testValidateServiceTemplate() throws Exception { - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - ServiceTemplate serviceTemplate = new ServiceTemplate(); - - try { - configModelServiceImpl.validateServiceTemplate(null); - fail("Should have thrown exception"); - } catch (SvcLogicException e) { - } - - try { - configModelServiceImpl.validateServiceTemplate(serviceTemplate); - fail("Should have thrown exception"); - } catch (SvcLogicException e) { - } - - Map metadata = new HashMap(); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR, "author"); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "name"); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "version"); - serviceTemplate.setMetadata(metadata); - - Assert.assertTrue(configModelServiceImpl.validateServiceTemplate(serviceTemplate)); - } - - @Test - public void testPrepareContext() throws Exception { - Mockito.when(configRestAdaptorService.getResource(Matchers.anyString(), Matchers.anyString(), Matchers.any())) - .thenReturn(createConfigModel()); - - String input = "{\"action-name\": \"resource-assignment-action\"}"; - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - Map ctx = - configModelService.prepareContext(null, input, "serviceTemplateName", "serviceTemplateVersion"); - Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME)); - - ctx = configModelService.prepareContext(null, input, "{}"); - Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME)); - } - - @Test - public void testConvertServiceTemplate2Properties() throws Exception { - Map metadata = new HashMap(); - metadata.put("key", "value"); - ServiceTemplate serviceTemplate = new ServiceTemplate(); - serviceTemplate.setMetadata(metadata); - Map context = new HashMap(); - - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - Map ctx = configModelService.convertServiceTemplate2Properties(serviceTemplate, context); - - Assert.assertEquals("value", ctx.get("key")); - } - - private ConfigModel createConfigModel() { - ConfigModel configModel = new ConfigModel(); - List configModelContents = new ArrayList(); - ConfigModelContent configModelContent = new ConfigModelContent(); - configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON); - configModelContent.setContent("{\"description\": \"description\"}"); - configModelContents.add(configModelContent); - configModel.setConfigModelContents(configModelContents); - configModel.setPublished("Y"); - return configModel; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java deleted file mode 100644 index a1e273a84..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.params.service; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Test; -import org.onap.ccsdk.features.model.utils.ExpressionUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ExpressionUtilsTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtilsTest.class); - - @Test - public void testProcessJsonExpression() throws Exception { - String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/default.json"), - Charset.defaultCharset()); - - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute("host-password", "1234"); - context.setAttribute("host-ip-address", "[\"123.23.34.45\", \"123.23.34.45\"]"); - context.setAttribute("loopback-default", "[\"Sample\", \"Brinda\"]"); - - Map inparams = new HashMap(); - ExpressionUtils jsonExpressionUtils = new ExpressionUtils(context, inparams); - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootArray = mapper.readTree(fileContent); - jsonExpressionUtils.processJsonExpression(rootArray); - - } - - @Test - public void testJson2Property() throws Exception { - String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/convert.json"), - Charset.defaultCharset()); - - List blockKeys = new ArrayList(); - blockKeys.add( - "interfaces.ResourceAssignmentService.operations.getResourceAssignment.inputs.assignment-mappings"); - blockKeys.add("interfaces.ResourceAssignmentService.operations.getResourceAssignment.outputs"); - blockKeys.add("type"); - - Map workflowMap = new HashMap<>(); - Map propertyMap = - TransformationUtils.convertJson2Properties(workflowMap, fileContent, blockKeys); - - TransformationUtils.printMap(propertyMap); - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java deleted file mode 100644 index e779a361a..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.params.service; - -import java.util.Map; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class MockComponentNode implements ComponentNode { - private static EELFLogger logger = EELFManager.getInstance().getLogger(MockComponentNode.class); - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received preCondition "); - componentContext.put("test-key", "test"); - return true; - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - - } - - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received Request " + componentContext); - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received preProcess "); - - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received postProcess "); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java deleted file mode 100644 index 5c89d45ae..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - */ - -package org.onap.ccsdk.features.params.service; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.data.TopologyTemplate; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; - -public class ServiceTemplateCreateUtils { - - public void createNodeTypes(String serviceTemplateFileName) throws IOException { - if (StringUtils.isNotBlank(serviceTemplateFileName)) { - String fileContent = - FileUtils.readFileToString(new File(serviceTemplateFileName), Charset.defaultCharset()); - if (StringUtils.isNotBlank(fileContent)) { - // System.out.println("NodeTypeCreateUtils.createNodeTypes()" +fileContent ); - ServiceTemplate serviceTemplate = TransformationUtils.readValue(fileContent, ServiceTemplate.class); - - String formattedServiceTemplateContent = TransformationUtils.getJson(serviceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/default.json"), - formattedServiceTemplateContent, Charset.defaultCharset()); - - createVrrNodeTemplate(serviceTemplate); - createDictionarySchema(); - - } - } - } - - public void createNodeTypes(ServiceTemplate serviceTemplate) throws IOException { - - if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) { - serviceTemplate.getNodeTypes().forEach((nodeTypeKey, node_types) -> { - - if (node_types != null && StringUtils.isNotBlank(node_types.getDerivedFrom())) { - - try { - String fileName = "src/test/resources/node_types/"; - if (ConfigModelConstant.MODEL_TYPE_NODE_VNF.equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "vnf/" + nodeTypeKey + ".json"; - } - if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "dg/" + nodeTypeKey + ".json"; - } - if (ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT - .equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "component/" + nodeTypeKey + ".json"; - } - String content = TransformationUtils.getJson(node_types, true); - FileUtils.write(new File(fileName), content, Charset.defaultCharset()); - } catch (IOException e) { - e.printStackTrace(); - } - - } - System.out.println("NodeTypeCreateUtils.createNodeTypes()" + nodeTypeKey); - }); - } - - } - - public void createResourceAssignmentNodeTemplate(ServiceTemplate serviceTemplate) throws IOException { - if (serviceTemplate != null) { - ServiceTemplate workingServiceTemplate = new ServiceTemplate(); - workingServiceTemplate.setMetadata(serviceTemplate.getMetadata()); - - Map data_types = new HashMap(); - data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property")); - data_types.put("datatype-resource-assignment", - serviceTemplate.getDataTypes().get("datatype-resource-assignment")); - - workingServiceTemplate.setDataTypes(data_types); - - TopologyTemplate topology_template = new TopologyTemplate(); - Map node_templates = new HashMap(); - - Map node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates(); - - node_templates.put("base-config-template", node_Templates.get("base-config-template")); - node_templates.put("licence-template", node_Templates.get("licence-template")); - - node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action")); - node_templates.put("resource-assignment", node_Templates.get("resource-assignment")); - - topology_template.setNodeTemplates(node_templates); - topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs()); - - Map node_types = new HashMap(); - node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template")); - node_types.put("dg-resource-assignment", serviceTemplate.getNodeTypes().get("dg-resource-assignment")); - node_types.put("component-resource-assignment", - serviceTemplate.getNodeTypes().get("component-resource-assignment")); - - workingServiceTemplate.setNodeTypes(node_types); - workingServiceTemplate.setTopologyTemplate(topology_template); - - String workingServiceTemplateConmtent = TransformationUtils.getJson(workingServiceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/resource_assignment.json"), - workingServiceTemplateConmtent, Charset.defaultCharset()); - - File lcmFile = new File( - "../../../northbound/selfservice-api/provider/src/test/resources/service_templates/resource_assignment.json"); - FileUtils.writeStringToFile(lcmFile, workingServiceTemplateConmtent, Charset.defaultCharset()); - - File resourceAssignmetFile = new File( - "../../../plugin/assignment/provider/src/test/resources/service_templates/resource_assignment.json"); - FileUtils.writeStringToFile(resourceAssignmetFile, workingServiceTemplateConmtent, - Charset.defaultCharset()); - - System.out.println("NodeTypeCreateUtils.createNodeTemplate() :" + workingServiceTemplateConmtent); - } - - } - - public void createVrrNodeTemplate(ServiceTemplate serviceTemplate) throws IOException { - if (serviceTemplate != null) { - ServiceTemplate workingServiceTemplate = new ServiceTemplate(); - workingServiceTemplate.setMetadata(serviceTemplate.getMetadata()); - - TopologyTemplate topology_template = new TopologyTemplate(); - Map node_templates = new HashMap(); - - Map node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates(); - - node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action")); - node_templates.put("resource-assignment", node_Templates.get("resource-assignment")); - - node_templates.put("activate-action", node_Templates.get("activate-action")); - node_templates.put("base-config-template", node_Templates.get("base-config-template")); - node_templates.put("licence-template", node_Templates.get("licence-template")); - node_templates.put("vrr-netconf-device", node_Templates.get("vrr-netconf-device")); - node_templates.put("get-netconf-config", node_Templates.get("get-netconf-config")); - node_templates.put("edit-netconf-config", node_Templates.get("edit-netconf-config")); - node_templates.put("transaction-netconf-baseconfig", node_Templates.get("transaction-netconf-baseconfig")); - - topology_template.setNodeTemplates(node_templates); - topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs()); - - workingServiceTemplate.setTopologyTemplate(topology_template); - - String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/vrr_config.json"), - workingServiceTemplateContent, Charset.defaultCharset()); - - } - } - - public void createDictionarySchema() throws IOException { - String schema = TransformationUtils.getJsonSchema(ResourceDefinition.class); - FileUtils.writeStringToFile(new File("src/test/resources/dictionary/dictionary_schema.json"), schema, - Charset.defaultCharset()); - } - - public static void main(String[] args) { - try { - ServiceTemplateCreateUtils utils = new ServiceTemplateCreateUtils(); - utils.createNodeTypes("src/test/resources/service_templates/default.json"); - } catch (Exception e) { - // TODO: handle exception - } - } - -} -- cgit 1.2.3-korg