summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/lib/openecomp-tosca-lib/src/test/java/org
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test/java/org')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java26
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java24
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java47
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java32
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java28
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java28
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java160
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java64
8 files changed, 308 insertions, 101 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java
index da3ae76f27..773b902182 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java
@@ -1,10 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.nio.file.NotDirectoryException;
import java.util.HashMap;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java
index 470dd9784a..820d79184e 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java
@@ -1,8 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.datatypes;
-import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
public class PropertyTypeTest {
@Test
@@ -17,4 +37,4 @@ public class PropertyTypeTest {
Assert
.assertEquals(PropertyType.getPropertyTypeByDisplayName(s), PropertyType.SCALAR_UNIT_SIZE);
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
index 13b05543fb..c7b0659c21 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
@@ -1,5 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.datatypes;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.core.utilities.yaml.YamlUtil;
import org.openecomp.sdc.tosca.datatypes.model.ArtifactType;
import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityAssignment;
@@ -7,7 +30,6 @@ import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.tosca.datatypes.model.Constraint;
import org.openecomp.sdc.tosca.datatypes.model.Directive;
import org.openecomp.sdc.tosca.datatypes.model.Import;
-import org.openecomp.sdc.tosca.datatypes.model.Metadata;
import org.openecomp.sdc.tosca.datatypes.model.NodeFilter;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
@@ -23,10 +45,6 @@ import org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
-import org.openecomp.core.utilities.yaml.YamlUtil;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.io.InputStream;
import java.util.ArrayList;
@@ -41,21 +59,24 @@ public class ToscaModelTest {
public void testServiceTemplateJavaToYaml() {
ServiceTemplate serviceTemplate = new ServiceTemplate();
- Metadata metadata = new Metadata();
- metadata.setTemplate_author("OPENECOMP");
- metadata.setTemplate_name("Test");
- metadata.setTemplate_version("1.0.0");
+ Map<String, String> metadata = new HashMap<>();
+ metadata.put("Template_author", "OPENECOMP");
+ metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "Test");
+ metadata.put("Template_version", "1.0.0");
serviceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
serviceTemplate.setDescription("testing desc tosca service template");
- serviceTemplate.setMetadata(metadata);
Import fileImport1 = new Import();
fileImport1.setFile("path1/path2/file1.yaml");
Import fileImport2 = new Import();
fileImport2.setFile("path1/path2/file2.yaml");
- Map<String, Import> imports = new HashMap<>();
- imports.put("myfile1", fileImport1);
- imports.put("myfile2", fileImport2);
+ List<Map<String, Import>> imports = new ArrayList<>();
+ Map<String, Import> importsMap = new HashMap<>();
+ importsMap.put("myfile1", fileImport1);
+ imports.add(importsMap);
+ importsMap = new HashMap<>();
+ importsMap.put("myfile2", fileImport2);
+ imports.add(importsMap);
serviceTemplate.setImports(imports);
ArtifactType artifact = new ArtifactType();
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java
index 2b0f88fdea..4cd76ce6ec 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java
@@ -1,15 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.datatypes.model;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.core.utilities.yaml.YamlUtil;
import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.core.utilities.yaml.YamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+/**
+ * @author shiria
+ * @since September 06, 2016.
+ */
public class CapabilityDefinitionTest {
@Test
@@ -64,7 +88,7 @@ public class CapabilityDefinitionTest {
private ArtifactDefinition getMockArtifactDefinition() {
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
artifactDefinition.setType("type1");
- artifactDefinition.setDescription("description of OPENECOMP def");
+ artifactDefinition.setDescription("description of openecomp def");
artifactDefinition.setDeploy_path("my deployment path");
artifactDefinition.setFile("my file");
artifactDefinition.setRepository("my repository");
@@ -98,4 +122,4 @@ public class CapabilityDefinitionTest {
return constraints;
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java
index 3109a8abff..38d8aba3ec 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java
@@ -1,14 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.datatypes.model;
-import org.openecomp.core.utilities.yaml.YamlUtil;
import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.core.utilities.yaml.YamlUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+/**
+ * @author shiria
+ * @since September 07, 2016.
+ */
public class RequirementDefinitionTest {
@Test
@@ -37,4 +61,4 @@ public class RequirementDefinitionTest {
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java
index 893f7a1a5e..e15f59dac4 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java
@@ -1,11 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.services;
-import org.openecomp.sdc.common.errors.CoreException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
@@ -16,6 +36,10 @@ import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
import java.util.ArrayList;
+/**
+ * @author shiria
+ * @since September 15, 2016.
+ */
@RunWith(MockitoJUnitRunner.class)
public class DataModelUtilTest {
@@ -101,4 +125,4 @@ public class DataModelUtilTest {
"Invalid action, can't add 'Group Definition' to 'Service Template', 'Service Template' entity is NULL.");
DataModelUtil.addGroupDefinitionToTopologyTemplate(null, "123", new GroupDefinition());
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index 47f0bd9aef..2afe6033b5 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -1,12 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.services.impl;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.tosca.TestUtil;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -16,6 +35,10 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.tosca.TestUtil;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.Import;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
@@ -23,17 +46,23 @@ import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate;
+import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
+/**
+ * @author Avrahamg
+ * @since July 14, 2016
+ */
@RunWith(MockitoJUnitRunner.class)
public class ToscaAnalyzerServiceImplTest {
/*
@@ -70,7 +99,8 @@ public class ToscaAnalyzerServiceImplTest {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
InputStream yamlFile = toscaExtensionYamlUtil
.loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml");
- ServiceTemplate serviceTemplateFromYaml =
+ ServiceTemplate
+ serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
NodeTemplate port_0 =
@@ -112,35 +142,44 @@ public class ToscaAnalyzerServiceImplTest {
thrown.expectMessage(
"Invalid Substitute Node Template invalid2, mandatory map property service_template_filter with mandatory key substitute_service_template must be defined.");
+ Optional<String> substituteServiceTemplateName;
+
ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates()
.get(toscaServiceModel.getEntryDefinitionServiceTemplate());
Optional<NodeTemplate> notSubstitutableNodeTemplate =
toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_net");
- Optional<String> substituteServiceTemplateName = toscaAnalyzerService
- .getSubstituteServiceTemplateName("test_net", notSubstitutableNodeTemplate.get());
- assertEquals(false, substituteServiceTemplateName.isPresent());
+ assertEquals(true, notSubstitutableNodeTemplate.isPresent());
+
+ if (notSubstitutableNodeTemplate.isPresent()) {
+ substituteServiceTemplateName = toscaAnalyzerService
+ .getSubstituteServiceTemplateName("test_net", notSubstitutableNodeTemplate.get());
+ assertEquals(false, substituteServiceTemplateName.isPresent());
+ }
Optional<NodeTemplate> substitutableNodeTemplate =
toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_nested");
- substituteServiceTemplateName = toscaAnalyzerService
- .getSubstituteServiceTemplateName("test_nested", substitutableNodeTemplate.get());
- assertEquals(true, substituteServiceTemplateName.isPresent());
- assertEquals("nestedServiceTemplate.yaml", substituteServiceTemplateName.get());
+ assertEquals(true, substitutableNodeTemplate.isPresent());
+ if (substitutableNodeTemplate.isPresent()) {
+ substituteServiceTemplateName = toscaAnalyzerService
+ .getSubstituteServiceTemplateName("test_nested", substitutableNodeTemplate.get());
+ assertEquals(true, substituteServiceTemplateName.isPresent());
+ assertEquals("nestedServiceTemplate.yaml", substituteServiceTemplateName.get());
+ }
NodeTemplate invalidSubstitutableNodeTemplate1 = new NodeTemplate();
substituteServiceTemplateName = toscaAnalyzerService
.getSubstituteServiceTemplateName("invalid1", invalidSubstitutableNodeTemplate1);
assertEquals(false, substituteServiceTemplateName.isPresent());
+ if (substitutableNodeTemplate.isPresent()) {
+ NodeTemplate invalidSubstitutableNodeTemplate2 = substitutableNodeTemplate.get();
+ Object serviceTemplateFilter = invalidSubstitutableNodeTemplate2.getProperties()
+ .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+ ((Map) serviceTemplateFilter).clear();
+ toscaAnalyzerService
+ .getSubstituteServiceTemplateName("invalid2", invalidSubstitutableNodeTemplate2);
- NodeTemplate invalidSubstitutableNodeTemplate2 = substitutableNodeTemplate.get();
- Object serviceTemplateFilter = invalidSubstitutableNodeTemplate2.getProperties()
- .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
- ((Map) serviceTemplateFilter).clear();
- toscaAnalyzerService
- .getSubstituteServiceTemplateName("invalid2", invalidSubstitutableNodeTemplate2);
-
-
+ }
}
@@ -186,14 +225,20 @@ public class ToscaAnalyzerServiceImplTest {
Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
.getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
nestedServiceTemplateFromYaml, "local_storage_server_cmaui");
- assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
- assertNotNull(mappedNodeTemplate.get().getValue());
+ assertEquals(true, mappedNodeTemplate.isPresent());
+ if (mappedNodeTemplate.isPresent()) {
+ assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
+ assertNotNull(mappedNodeTemplate.get().getValue());
+ }
mappedNodeTemplate = toscaAnalyzerService
.getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
nestedServiceTemplateFromYaml, "link_cmaui_port_invalid");
- assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
- assertNotNull(mappedNodeTemplate.get().getValue());
+ assertEquals(true, mappedNodeTemplate.isPresent());
+ if (mappedNodeTemplate.isPresent()) {
+ assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
+ assertNotNull(mappedNodeTemplate.get().getValue());
+ }
ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates()
.get(toscaServiceModel.getEntryDefinitionServiceTemplate());
@@ -310,33 +355,33 @@ public class ToscaAnalyzerServiceImplTest {
@Test
public void shouldReturnFalseIfNdTmpIsNull() {
assertFalse(toscaAnalyzerService
- .isTypeOf(null, ToscaNodeType.NETWORK.getDisplayName(), new ServiceTemplate(),
+ .isTypeOf(null, ToscaNodeType.NATIVE_NETWORK, new ServiceTemplate(),
toscaServiceModelMock));
}
@Test
public void shouldReturnTrueIfNdTmpTypeIsOfRequestedType() {
NodeTemplate nodeTemplate = new NodeTemplate();
- ToscaNodeType nodeTypeToSearch = ToscaNodeType.BLOCK_STORAGE;
- nodeTemplate.setType(nodeTypeToSearch.getDisplayName());
+ String nodeTypeToSearch = ToscaNodeType.NATIVE_BLOCK_STORAGE;
+ nodeTemplate.setType(nodeTypeToSearch);
assertTrue(toscaAnalyzerService
- .isTypeOf(nodeTemplate, nodeTypeToSearch.getDisplayName(), new ServiceTemplate(),
+ .isTypeOf(nodeTemplate, nodeTypeToSearch, new ServiceTemplate(),
toscaServiceModelMock));
}
@Test
public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyAndNdTyDerivedFromRequestedType() {
- String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName();
+ String typeToMatch = ToscaNodeType.CINDER_VOLUME;
when(nodeTemplateMock.getType()).thenReturn(typeToMatch);
Map<String, NodeType> stNodeTypes = new HashMap<>();
- addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType());
- NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName());
+ addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType());
+ NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE);
addNodeType(stNodeTypes, typeToMatch, nodeType);
ServiceTemplate serviceTemplate = new ServiceTemplate();
serviceTemplate.setNode_types(stNodeTypes);
assertTrue(toscaAnalyzerService
- .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), serviceTemplate,
- toscaServiceModelMock));
+ .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE,
+ serviceTemplate, toscaServiceModelMock));
}
@@ -351,7 +396,7 @@ public class ToscaAnalyzerServiceImplTest {
ServiceTemplate serviceTemplate = new ServiceTemplate();
serviceTemplate.setNode_types(stNodeTypes);
toscaAnalyzerService
- .isTypeOf(nodeTemplateMock, ToscaNodeType.COMPUTE.getDisplayName(), serviceTemplate,
+ .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_COMPUTE, serviceTemplate,
toscaServiceModelMock);
}
@@ -398,19 +443,21 @@ public class ToscaAnalyzerServiceImplTest {
@Test
public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyButRequestedTypeNotMatchButFoundIn1stLevelImports() {
- String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName();
+ String typeToMatch = ToscaNodeType.CINDER_VOLUME;
when(nodeTemplateMock.getType()).thenReturn(typeToMatch);
ServiceTemplate mainST = new ServiceTemplate();
- Map<String, Import> imports = new HashMap<>();
+ List<Map<String, Import>> imports = new ArrayList<>();
+ Map<String, Import> importMap = new HashMap<>();
Import anImport = new Import();
anImport.setFile("mainImport");
- imports.put("bla bla", anImport);
+ importMap.put("bla bla", anImport);
+ imports.add(importMap);
mainST.setImports(imports);
//create searchable service template
Map<String, NodeType> stNodeTypes = new HashMap<>();
- addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType());
- NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName());
+ addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType());
+ NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE);
addNodeType(stNodeTypes, typeToMatch, nodeType);
ServiceTemplate serviceTemplate = new ServiceTemplate();
serviceTemplate.setNode_types(stNodeTypes);
@@ -422,36 +469,39 @@ public class ToscaAnalyzerServiceImplTest {
when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates);
assertTrue(toscaAnalyzerService
- .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), mainST,
+ .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST,
toscaServiceModelMock));
}
@Test
public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyButRequestedTypeNotMatchButFoundIn2ndLevelImports() {
- String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName();
+ String typeToMatch = ToscaNodeType.CINDER_VOLUME;
when(nodeTemplateMock.getType()).thenReturn(typeToMatch);
ServiceTemplate mainST = new ServiceTemplate();
- Map<String, Import> imports = new HashMap<>();
+ List<Map<String, Import>> imports = new ArrayList<>();
+ Map<String, Import> importMap = new HashMap<>();
Import anImport = new Import();
anImport.setFile("refToMainImport");
- imports.put("bla bla", anImport);
+ importMap.put("bla bla", anImport);
+ imports.add(importMap);
mainST.setImports(imports);
//create searchable service template
Map<String, NodeType> stNodeTypes = new HashMap<>();
- addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType());
- NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName());
+ addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType());
+ NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE);
addNodeType(stNodeTypes, typeToMatch, nodeType);
ServiceTemplate serviceTemplate = new ServiceTemplate();
serviceTemplate.setNode_types(stNodeTypes);
// create 1st level service template with import only
ServiceTemplate firstLevelST = new ServiceTemplate();
- Map<String, Import> firstLevelImports = new HashMap<>();
+ List<Map<String, Import>> firstLevelImports = new ArrayList<>();
+ Map<String, Import> firstLevelImportsMap = new HashMap<>();
Import firstLevelImport = new Import();
firstLevelImport.setFile("mainImport");
- firstLevelImports.put("bla bla 2", firstLevelImport);
-
+ firstLevelImportsMap.put("bla bla 2", firstLevelImport);
+ firstLevelImports.add(firstLevelImportsMap);
firstLevelST.setImports(firstLevelImports);
// add service templates to tosca service model
@@ -462,11 +512,11 @@ public class ToscaAnalyzerServiceImplTest {
when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates);
assertTrue(toscaAnalyzerService
- .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), mainST,
+ .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST,
toscaServiceModelMock));
}
// not found at all should throw core exception
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
index 963b8a6f57..4d025e1540 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
@@ -1,12 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.tosca.services.impl;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.Metadata;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.junit.Assert;
-import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
@@ -21,12 +41,12 @@ import java.util.zip.ZipFile;
public class ToscaFileOutputServiceCsarImplTest {
- private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCsarImpl =
+ private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl =
new ToscaFileOutputServiceCsarImpl();
@Test
public void testCreationMetaFile() {
- String createdMeta = toscaFileOutputServiceCsarImpl.createMetaFile("entryFile.yaml");
+ String createdMeta = toscaFileOutputServiceCSARImpl.createMetaFile("entryFile.yaml");
String expectedMeta =
"TOSCA-Meta-File-Version: 1.0\n" +
"CSAR-Version: 1.1\n" +
@@ -38,19 +58,19 @@ public class ToscaFileOutputServiceCsarImplTest {
@Test
public void testCSARFileCreationWithExternalArtifacts() throws IOException {
ServiceTemplate mainServiceTemplate = new ServiceTemplate();
- Metadata metadata1 = new Metadata();
- metadata1.setTemplate_author("OPENECOMP");
- metadata1.setTemplate_name("ST1");
- metadata1.setTemplate_version("1.0.0");
+ Map<String, String> metadata1 = new HashMap<>();
+ metadata1.put("Template_author", "OPENECOMP");
+ metadata1.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME,"ST1");
+ metadata1.put("Template_version", "1.0.0");
+ mainServiceTemplate.setMetadata(metadata1);
mainServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
mainServiceTemplate.setDescription("testing desc tosca service template");
- mainServiceTemplate.setMetadata(metadata1);
ServiceTemplate additionalServiceTemplate = new ServiceTemplate();
- Metadata metadata2 = new Metadata();
- metadata2.setTemplate_author("OPENECOMP");
- metadata2.setTemplate_name("ST2");
- metadata2.setTemplate_version("1.0.0");
+ Map<String, String> metadata2 = new HashMap<>();
+ metadata2.put("Template_author", "OPENECOMP");
+ metadata2.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "ST2");
+ metadata2.put("Template_version", "1.0.0");
additionalServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
additionalServiceTemplate.setDescription("testing desc tosca service template");
additionalServiceTemplate.setMetadata(metadata2);
@@ -86,7 +106,7 @@ public class ToscaFileOutputServiceCsarImplTest {
licenseArtifactsFiles.putAll(licenseArtifacts);
- byte[] csarFile = toscaFileOutputServiceCsarImpl.createOutputFile(
+ byte[] csarFile = toscaFileOutputServiceCSARImpl.createOutputFile(
new ToscaServiceModel(heatFiles, definitionsInput,
ToscaUtil.getServiceTemplateFileName(mainServiceTemplate)), licenseArtifactsFiles);
@@ -113,17 +133,17 @@ public class ToscaFileOutputServiceCsarImplTest {
@Test
public void testCSARFileCreation_noArtifacts() throws IOException {
ServiceTemplate serviceTemplate = new ServiceTemplate();
- Metadata metadata = new Metadata();
- metadata.setTemplate_author("OPENECOMP");
- metadata.setTemplate_name("Test");
- metadata.setTemplate_version("1.0.0");
+ Map<String, String> metadata = new HashMap<>();
+ metadata.put("Template_author", "OPENECOMP");
+ metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "Test");
+ metadata.put("Template_version", "1.0.0");
serviceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
serviceTemplate.setDescription("testing desc tosca service template");
serviceTemplate.setMetadata(metadata);
Map<String, ServiceTemplate> definitionsInput = new HashMap<>();
String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
definitionsInput.put(serviceTemplateFileName, serviceTemplate);
- byte[] csarFile = toscaFileOutputServiceCsarImpl
+ byte[] csarFile = toscaFileOutputServiceCSARImpl
.createOutputFile(new ToscaServiceModel(null, definitionsInput, serviceTemplateFileName),
null);
@@ -147,4 +167,4 @@ public class ToscaFileOutputServiceCsarImplTest {
zipFile.close();
Files.delete(Paths.get(file.getPath()));
}
-} \ No newline at end of file
+}