aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authormichal.banka <michal.banka@nokia.com>2019-07-10 16:14:27 +0200
committerTomasz Golabek <tomasz.golabek@nokia.com>2019-07-25 10:11:05 +0000
commitd0d5690f13b9c794044bfe6bd7ac87557dd3dcea (patch)
tree651bf59514a2ec3603e753094e0edae54296dc5c /src/test/java/org
parentcad897335db0c7912782482fa71932cc2b4ce421 (diff)
Fix checkstyle violations in sdc/jtosca1.6.0
Number of checkstyle violations has decreased from about 8200 to 450. Change-Id: I31f763d7f51fa66958aab68d094280189c612417 Issue-ID: SDC-2434 Signed-off-by: michal.banka <michal.banka@nokia.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/GetValidationIssues.java13
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java478
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java26
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java4
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java72
-rw-r--r--src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java44
6 files changed, 319 insertions, 318 deletions
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/GetValidationIssues.java b/src/test/java/org/onap/sdc/toscaparser/api/GetValidationIssues.java
index 3902219..140a6e9 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/GetValidationIssues.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/GetValidationIssues.java
@@ -7,9 +7,9 @@
* 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.
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
+
//Generate excel file, include all validation issues errors in jtosca
//the error java code, the line number and file name for each error.
public class GetValidationIssues {
@@ -37,13 +38,13 @@ public class GetValidationIssues {
public static List<String[]> data = new ArrayList<>();
public static void main(String[] args) {
- System.out.println("GetAllValidationIssues - path to project files Directory is " + Arrays.toString(args));
- File jtoscaFiles = new File(args[0]+ "\\jtosca\\src\\main\\java\\org\\onap\\sdc\\toscaparser\\api");
+ System.out.println("GetAllValidationIssues - path to project files Directory is " + Arrays.toString(args));
+ File jtoscaFiles = new File(args[0] + "\\jtosca\\src\\main\\java\\org\\onap\\sdc\\toscaparser\\api");
try {
printFiles(jtoscaFiles);
- fileWriter = new CSVWriter(new FileWriter(args[1]+"\\JToscaValidationIssues_"+System.currentTimeMillis()+".csv"), '\t');
- fileWriter.writeNext(new String[] {"Error Message", "Class Name", "Line No."}, false);
+ fileWriter = new CSVWriter(new FileWriter(args[1] + "\\JToscaValidationIssues_" + System.currentTimeMillis() + ".csv"), '\t');
+ fileWriter.writeNext(new String[]{"Error Message", "Class Name", "Line No."}, false);
fileWriter.writeAll(data, false);
} catch (IOException e) {
e.printStackTrace();
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java b/src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java
index 13e17ce..5876ac7 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java
@@ -5,9 +5,9 @@
* 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.
@@ -39,81 +39,81 @@ import static org.junit.Assert.*;
public class JToscaImportTest {
- @Test
- public void testNoMissingTypeValidationError() throws JToscaException {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
- .getFile();
- File file = new File(fileStr);
- new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- List<String> missingTypeErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
- .filter(s -> s.contains("JE136")).collect(Collectors.toList());
- assertEquals(0, missingTypeErrors.size());
- }
-
- @Test
- public void testNoStackOverFlowError() {
- Exception jte = null;
- try {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
- .getFile();
- File file = new File(fileStr);
- new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- } catch (Exception e) {
- jte = e;
- }
- assertEquals(null, jte);
- }
-
- @Test
- public void testNoInvalidImports() throws JToscaException {
- List<String> fileNames = new ArrayList<>();
- fileNames.add("csars/tmpCSAR_Huawei_vSPGW_fixed.csar");
- fileNames.add("csars/sdc-onboarding_csar.csar");
- fileNames.add("csars/resource-Spgw-csar-ZTE.csar");
-
- for (String fileName : fileNames) {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource(fileName).getFile();
- File file = new File(fileStr);
- new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- List<String> invalidImportErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
- .filter(s -> s.contains("JE195")).collect(Collectors.toList());
- assertEquals(0, invalidImportErrors.size());
- }
- }
-
- @Test
- public void testParseAnnotations() throws JToscaException {
-
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
-
- List<Input> inputs = toscaTemplate.getInputs();
- assertNotNull(inputs);
- assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
-
- inputs.forEach(Input::parseAnnotations);
- assertTrue(!inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
- }
-
- @Test
- public void testGetInputsWithAndWithoutAnnotations() throws JToscaException {
-
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- List<Input> inputs = toscaTemplate.getInputs();
- assertNotNull(inputs);
- assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
-
- inputs = toscaTemplate.getInputs(true);
- assertNotNull(inputs);
- validateInputsAnnotations(inputs);
-
- inputs = toscaTemplate.getInputs(false);
- assertNotNull(inputs);
- assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
- }
+ @Test
+ public void testNoMissingTypeValidationError() throws JToscaException {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
+ .getFile();
+ File file = new File(fileStr);
+ new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ List<String> missingTypeErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
+ .filter(s -> s.contains("JE136")).collect(Collectors.toList());
+ assertEquals(0, missingTypeErrors.size());
+ }
+
+ @Test
+ public void testNoStackOverFlowError() {
+ Exception jte = null;
+ try {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
+ .getFile();
+ File file = new File(fileStr);
+ new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ } catch (Exception e) {
+ jte = e;
+ }
+ assertEquals(null, jte);
+ }
+
+ @Test
+ public void testNoInvalidImports() throws JToscaException {
+ List<String> fileNames = new ArrayList<>();
+ fileNames.add("csars/tmpCSAR_Huawei_vSPGW_fixed.csar");
+ fileNames.add("csars/sdc-onboarding_csar.csar");
+ fileNames.add("csars/resource-Spgw-csar-ZTE.csar");
+
+ for (String fileName : fileNames) {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource(fileName).getFile();
+ File file = new File(fileStr);
+ new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ List<String> invalidImportErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
+ .filter(s -> s.contains("JE195")).collect(Collectors.toList());
+ assertEquals(0, invalidImportErrors.size());
+ }
+ }
+
+ @Test
+ public void testParseAnnotations() throws JToscaException {
+
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+
+ List<Input> inputs = toscaTemplate.getInputs();
+ assertNotNull(inputs);
+ assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+
+ inputs.forEach(Input::parseAnnotations);
+ assertTrue(!inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+ }
+
+ @Test
+ public void testGetInputsWithAndWithoutAnnotations() throws JToscaException {
+
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ List<Input> inputs = toscaTemplate.getInputs();
+ assertNotNull(inputs);
+ assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+
+ inputs = toscaTemplate.getInputs(true);
+ assertNotNull(inputs);
+ validateInputsAnnotations(inputs);
+
+ inputs = toscaTemplate.getInputs(false);
+ assertNotNull(inputs);
+ assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+ }
@Test
public void testGetPropertyNameTest() throws JToscaException {
@@ -123,7 +123,7 @@ public class JToscaImportTest {
ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
NodeTemplate nodeTemplate = toscaTemplate.getNodeTemplates().get(0);
- ArrayList<String> valueList = (ArrayList<String>)nodeTemplate.getPropertyValueFromTemplatesByName("vmxvpfe_sriov41_0_port_vlanfilter");
+ ArrayList<String> valueList = (ArrayList<String>) nodeTemplate.getPropertyValueFromTemplatesByName("vmxvpfe_sriov41_0_port_vlanfilter");
assertEquals(4, valueList.size());
assertEquals("vPE", (String) nodeTemplate.getPropertyValueFromTemplatesByName("nf_role"));
@@ -131,24 +131,24 @@ public class JToscaImportTest {
assertNull(nodeTemplate.getPropertyValueFromTemplatesByName("test"));
}
- @Test
- public void testGetParentNodeTemplateTest() throws JToscaException {
-
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- NodeTemplate nodeTemplate = toscaTemplate.getNodeTemplates().get(0);
- //parent of this VF is service (null)
- assertNull(nodeTemplate.getParentNodeTemplate());
- List<NodeTemplate> children = nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates();
- assertFalse(children.isEmpty());
- NodeTemplate cVFC = children.get(4);
- //parent is the VF above
- assertEquals("2017-488_ADIOD-vPE 0", cVFC.getParentNodeTemplate().getName());
- List<NodeTemplate> children1 = cVFC.getSubMappingToscaTemplate().getNodeTemplates();
- assertFalse(children1.isEmpty());
- //parent is the CVFC above
- assertEquals(cVFC, children1.get(0).getParentNodeTemplate());
+ @Test
+ public void testGetParentNodeTemplateTest() throws JToscaException {
+
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ NodeTemplate nodeTemplate = toscaTemplate.getNodeTemplates().get(0);
+ //parent of this VF is service (null)
+ assertNull(nodeTemplate.getParentNodeTemplate());
+ List<NodeTemplate> children = nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates();
+ assertFalse(children.isEmpty());
+ NodeTemplate cVFC = children.get(4);
+ //parent is the VF above
+ assertEquals("2017-488_ADIOD-vPE 0", cVFC.getParentNodeTemplate().getName());
+ List<NodeTemplate> children1 = cVFC.getSubMappingToscaTemplate().getNodeTemplates();
+ assertFalse(children1.isEmpty());
+ //parent is the CVFC above
+ assertEquals(cVFC, children1.get(0).getParentNodeTemplate());
/*
@@ -161,149 +161,149 @@ public class JToscaImportTest {
policies = tt.getPolicies();
*/
- }
-
- @Test
- public void testNullValueHasNoNullPointerException() throws JToscaException {
-
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-JennyVtsbcKarunaSvc-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- List<Input> inputs = toscaTemplate.getInputs();
- assertNotNull(inputs);
- }
-
- @Test
- public void testGetPolicyMetadata() throws JToscaException {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- ArrayList<Policy> policies = toscaTemplate.getPolicies();
- assertNotNull(policies);
- assertEquals(1, policies.size());
- assertEquals("org.openecomp.policies.External", policies.get(0).getType());
- assertEquals("adf03496-bf87-43cf-b20a-450e47cb44bd", policies.get(0).getMetaData().getOrDefault("UUID", "").toString());
- assertTrue(policies.get(0).getMetaData().getOrDefault("UUID_test", "").toString().isEmpty());
- }
-
- @Test
- public void testGetPolicyMetadataObj() throws JToscaException {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar").getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- ArrayList<Policy> policies = toscaTemplate.getPolicies();
- assertNotNull(policies);
- assertEquals(1, policies.size());
- assertEquals("adf03496-bf87-43cf-b20a-450e47cb44bd", policies.get(0).getMetaDataObj().getAllProperties().getOrDefault("UUID", "").toString());
- assertTrue(policies.get(0).getMetaDataObj().getAllProperties().getOrDefault("name_test", "").toString().isEmpty());
- }
+ }
+
+ @Test
+ public void testNullValueHasNoNullPointerException() throws JToscaException {
+
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-JennyVtsbcKarunaSvc-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ List<Input> inputs = toscaTemplate.getInputs();
+ assertNotNull(inputs);
+ }
+
+ @Test
+ public void testGetPolicyMetadata() throws JToscaException {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ ArrayList<Policy> policies = toscaTemplate.getPolicies();
+ assertNotNull(policies);
+ assertEquals(1, policies.size());
+ assertEquals("org.openecomp.policies.External", policies.get(0).getType());
+ assertEquals("adf03496-bf87-43cf-b20a-450e47cb44bd", policies.get(0).getMetaData().getOrDefault("UUID", "").toString());
+ assertTrue(policies.get(0).getMetaData().getOrDefault("UUID_test", "").toString().isEmpty());
+ }
+
+ @Test
+ public void testGetPolicyMetadataObj() throws JToscaException {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ ArrayList<Policy> policies = toscaTemplate.getPolicies();
+ assertNotNull(policies);
+ assertEquals(1, policies.size());
+ assertEquals("adf03496-bf87-43cf-b20a-450e47cb44bd", policies.get(0).getMetaDataObj().getAllProperties().getOrDefault("UUID", "").toString());
+ assertTrue(policies.get(0).getMetaDataObj().getAllProperties().getOrDefault("name_test", "").toString().isEmpty());
+ }
private void validateInputsAnnotations(List<Input> inputs) {
- List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
- .collect(Collectors.toList());
- assertTrue(!inputs.isEmpty());
- inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i));
- }
-
- private void validateAnnotations(Input input) {
- assertNotNull(input.getAnnotations());
- assertEquals(input.getAnnotations().size(), 1);
- Annotation annotation = input.getAnnotations().get("source");
- assertEquals(annotation.getName(), "source");
- assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source");
- assertNotNull(annotation.getProperties());
- Optional<Property> source_type = annotation.getProperties().stream()
- .filter(p -> p.getName().equals("source_type")).findFirst();
- assertTrue(source_type.isPresent());
- assertEquals(source_type.get().getValue(), "HEAT");
- }
-
- private static final String TEST_DATATYPE_FILENAME ="csars/dataTypes-test-service.csar";
- private static final String TEST_DATATYPE_TEST1 = "TestType1";
- private static final String TEST_DATATYPE_TEST2 = "TestType2";
- private static final String TEST_DATATYPE_PROPERTY_STR = "strdata";
- private static final String TEST_DATATYPE_PROPERTY_INT = "intdata";
- private static final String TEST_DATATYPE_PROPERTY_LIST = "listdata";
- private static final String TEST_DATATYPE_PROPERTY_TYPE = "type";
- private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema";
- private static final String TEST_DATATYPE_TOSTRING = "data_types=";
-
- @Test
- public void testGetDataType() throws JToscaException {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource(TEST_DATATYPE_FILENAME).getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- HashSet<DataType> dataTypes = toscaTemplate.getDataTypes();
- assertThat(dataTypes,notNullValue());
- assertThat(dataTypes.size(),is(2));
-
- for(DataType dataType: dataTypes){
- LinkedHashMap<String, PropertyDef> properties;
- PropertyDef property;
- if(dataType.getType().equals(TEST_DATATYPE_TEST1)){
- properties = dataType.getAllProperties();
- property = properties.get(TEST_DATATYPE_PROPERTY_STR);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_STR));
- assertThat( property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.STRING));
- }
- if(dataType.getType().equals(TEST_DATATYPE_TEST2)){
- properties = dataType.getAllProperties();
- property = properties.get(TEST_DATATYPE_PROPERTY_INT);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_INT));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.INTEGER));
-
- property = properties.get(TEST_DATATYPE_PROPERTY_LIST);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_LIST));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.LIST));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA),is(TEST_DATATYPE_TEST1));
-
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),notNullValue());
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),notNullValue());
- assertThat(toscaTemplate.toString(),containsString(TEST_DATATYPE_TOSTRING));
- }
- }
-
- }
-
- @Test
- public void testGetInputValidate() throws JToscaException {
- String fileStr = JToscaImportTest.class.getClassLoader().getResource(TEST_DATATYPE_FILENAME).getFile();
- File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- HashSet<DataType> dataTypes = toscaTemplate.getDataTypes();
- assertThat(dataTypes,notNullValue());
- assertThat(dataTypes.size(),is(2));
-
- for(DataType dataType: dataTypes) {
- LinkedHashMap<String, PropertyDef> properties;
- PropertyDef property;
- if(dataType.getType().equals(TEST_DATATYPE_TEST1)) {
- properties = dataType.getAllProperties();
- property = properties.get(TEST_DATATYPE_PROPERTY_STR);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_STR));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.STRING));
- }
- if(dataType.getType().equals(TEST_DATATYPE_TEST2)) {
- properties = dataType.getAllProperties();
- property = properties.get(TEST_DATATYPE_PROPERTY_INT);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_INT));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.INTEGER));
-
- property = properties.get(TEST_DATATYPE_PROPERTY_LIST);
- assertThat(property,notNullValue());
- assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_LIST));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.LIST));
- assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA),is(TEST_DATATYPE_TEST1));
-
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),notNullValue());
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),notNullValue());
- assertThat(toscaTemplate.toString(),containsString(TEST_DATATYPE_TOSTRING));
- }
- }
- }
+ List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
+ .collect(Collectors.toList());
+ assertTrue(!inputs.isEmpty());
+ inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i));
+ }
+
+ private void validateAnnotations(Input input) {
+ assertNotNull(input.getAnnotations());
+ assertEquals(input.getAnnotations().size(), 1);
+ Annotation annotation = input.getAnnotations().get("source");
+ assertEquals(annotation.getName(), "source");
+ assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source");
+ assertNotNull(annotation.getProperties());
+ Optional<Property> source_type = annotation.getProperties().stream()
+ .filter(p -> p.getName().equals("source_type")).findFirst();
+ assertTrue(source_type.isPresent());
+ assertEquals(source_type.get().getValue(), "HEAT");
+ }
+
+ private static final String TEST_DATATYPE_FILENAME = "csars/dataTypes-test-service.csar";
+ private static final String TEST_DATATYPE_TEST1 = "TestType1";
+ private static final String TEST_DATATYPE_TEST2 = "TestType2";
+ private static final String TEST_DATATYPE_PROPERTY_STR = "strdata";
+ private static final String TEST_DATATYPE_PROPERTY_INT = "intdata";
+ private static final String TEST_DATATYPE_PROPERTY_LIST = "listdata";
+ private static final String TEST_DATATYPE_PROPERTY_TYPE = "type";
+ private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema";
+ private static final String TEST_DATATYPE_TOSTRING = "data_types=";
+
+ @Test
+ public void testGetDataType() throws JToscaException {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource(TEST_DATATYPE_FILENAME).getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ HashSet<DataType> dataTypes = toscaTemplate.getDataTypes();
+ assertThat(dataTypes, notNullValue());
+ assertThat(dataTypes.size(), is(2));
+
+ for (DataType dataType : dataTypes) {
+ LinkedHashMap<String, PropertyDef> properties;
+ PropertyDef property;
+ if (dataType.getType().equals(TEST_DATATYPE_TEST1)) {
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_STR);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_STR));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.STRING));
+ }
+ if (dataType.getType().equals(TEST_DATATYPE_TEST2)) {
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_INT);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_INT));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.INTEGER));
+
+ property = properties.get(TEST_DATATYPE_PROPERTY_LIST);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
+
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+ assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
+ }
+ }
+
+ }
+
+ @Test
+ public void testGetInputValidate() throws JToscaException {
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource(TEST_DATATYPE_FILENAME).getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ HashSet<DataType> dataTypes = toscaTemplate.getDataTypes();
+ assertThat(dataTypes, notNullValue());
+ assertThat(dataTypes.size(), is(2));
+
+ for (DataType dataType : dataTypes) {
+ LinkedHashMap<String, PropertyDef> properties;
+ PropertyDef property;
+ if (dataType.getType().equals(TEST_DATATYPE_TEST1)) {
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_STR);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_STR));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.STRING));
+ }
+ if (dataType.getType().equals(TEST_DATATYPE_TEST2)) {
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_INT);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_INT));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.INTEGER));
+
+ property = properties.get(TEST_DATATYPE_PROPERTY_LIST);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
+
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+ assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
+ }
+ }
+ }
}
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java b/src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java
index f8295d7..3f5290d 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java
@@ -7,9 +7,9 @@
* 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.
@@ -52,30 +52,30 @@ public class JToscaMetadataParse {
File file = new File(fileStr);
ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
int validationIssuesCaught = ThreadLocalsHolder.getCollector().validationIssuesCaught();
- assertTrue(validationIssuesCaught == 0 );
+ assertTrue(validationIssuesCaught == 0);
}
-
+
@Test
public void testEmptyCsar() throws JToscaException {
String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/emptyCsar.csar").getFile();
File file = new File(fileStr);
try {
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
} catch (JToscaException e) {
- assertTrue(e.getCode().equals(JToscaErrorCodes.INVALID_CSAR_FORMAT.getValue()));
- }
+ assertTrue(e.getCode().equals(JToscaErrorCodes.INVALID_CSAR_FORMAT.getValue()));
+ }
int validationIssuesCaught = ThreadLocalsHolder.getCollector().validationIssuesCaught();
- assertTrue(validationIssuesCaught == 0 );
+ assertTrue(validationIssuesCaught == 0);
}
-
+
@Test
public void testEmptyPath() throws JToscaException {
String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("").getFile();
File file = new File(fileStr);
try {
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
- }catch (JToscaException e) {
- assertTrue(e.getCode().equals(JToscaErrorCodes.PATH_NOT_VALID.getValue()));
- }
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ } catch (JToscaException e) {
+ assertTrue(e.getCode().equals(JToscaErrorCodes.PATH_NOT_VALID.getValue()));
+ }
}
}
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java b/src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java
index eaf182e..fd84d6e 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java b/src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java
index 271eb59..d65de28 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,45 +31,45 @@ import static org.junit.Assert.assertEquals;
public class EntityTypeTest {
- private static final Map<String, Object> origMap = EntityType.TOSCA_DEF;
+ private static final Map<String, Object> origMap = EntityType.TOSCA_DEF;
- @Test
- public void testUpdateDefinitions() throws Exception {
+ @Test
+ public void testUpdateDefinitions() throws Exception {
- Map<String, Object> testData = new HashMap<>();
- testData.put("tosca.nodes.nfv.VNF", "{derived_from=tosca.nodes.Root, properties={id={type=string, description=ID of this VNF}, vendor={type=string, description=name of the vendor who generate this VNF}, version={type=version, description=version of the software for this VNF}}, requirements=[{virtualLink={capability=tosca.capabilities.nfv.VirtualLinkable, relationship=tosca.relationships.nfv.VirtualLinksTo, node=tosca.nodes.nfv.VL}}]}");
- testData.put("tosca.nodes.nfv.VDU", "{derived_from=tosca.nodes.Compute, capabilities={high_availability={type=tosca.capabilities.nfv.HA}, virtualbinding={type=tosca.capabilities.nfv.VirtualBindable}, monitoring_parameter={type=tosca.capabilities.nfv.Metric}}, requirements=[{high_availability={capability=tosca.capabilities.nfv.HA, relationship=tosca.relationships.nfv.HA, node=tosca.nodes.nfv.VDU, occurrences=[0, 1]}}]}");
- testData.put("tosca.nodes.nfv.CP", "{derived_from=tosca.nodes.network.Port, properties={type={type=string, required=false}}, requirements=[{virtualLink={capability=tosca.capabilities.nfv.VirtualLinkable, relationship=tosca.relationships.nfv.VirtualLinksTo, node=tosca.nodes.nfv.VL}}, {virtualBinding={capability=tosca.capabilities.nfv.VirtualBindable, relationship=tosca.relationships.nfv.VirtualBindsTo, node=tosca.nodes.nfv.VDU}}], attributes={address={type=string}}}");
- testData.put("tosca.nodes.nfv.VL", "{derived_from=tosca.nodes.network.Network, properties={vendor={type=string, required=true, description=name of the vendor who generate this VL}}, capabilities={virtual_linkable={type=tosca.capabilities.nfv.VirtualLinkable}}}");
- testData.put("tosca.nodes.nfv.VL.ELine", "{derived_from=tosca.nodes.nfv.VL, capabilities={virtual_linkable={occurrences=2}}}");
- testData.put("tosca.nodes.nfv.VL.ELAN", "{derived_from=tosca.nodes.nfv.VL}");
- testData.put("tosca.nodes.nfv.VL.ETree", "{derived_from=tosca.nodes.nfv.VL}");
- testData.put("tosca.nodes.nfv.FP", "{derived_from=tosca.nodes.Root, properties={policy={type=string, required=false, description=name of the vendor who generate this VL}}, requirements=[{forwarder={capability=tosca.capabilities.nfv.Forwarder, relationship=tosca.relationships.nfv.ForwardsTo}}]}");
- testData.put("tosca.groups.nfv.VNFFG", "{derived_from=tosca.groups.Root, properties={vendor={type=string, required=true, description=name of the vendor who generate this VNFFG}, version={type=string, required=true, description=version of this VNFFG}, number_of_endpoints={type=integer, required=true, description=count of the external endpoints included in this VNFFG}, dependent_virtual_link={type=list, entry_schema={type=string}, required=true, description=Reference to a VLD used in this Forwarding Graph}, connection_point={type=list, entry_schema={type=string}, required=true, description=Reference to Connection Points forming the VNFFG}, constituent_vnfs={type=list, entry_schema={type=string}, required=true, description=Reference to a list of VNFD used in this VNF Forwarding Graph}}}");
- testData.put("tosca.relationships.nfv.VirtualLinksTo", "{derived_from=tosca.relationships.network.LinksTo, valid_target_types=[tosca.capabilities.nfv.VirtualLinkable]}");
- testData.put("tosca.relationships.nfv.VirtualBindsTo", "{derived_from=tosca.relationships.network.BindsTo, valid_target_types=[tosca.capabilities.nfv.VirtualBindable]}");
- testData.put("tosca.relationships.nfv.HA", "{derived_from=tosca.relationships.Root, valid_target_types=[tosca.capabilities.nfv.HA]}");
- testData.put("tosca.relationships.nfv.Monitor", "{derived_from=tosca.relationships.ConnectsTo, valid_target_types=[tosca.capabilities.nfv.Metric]}");
- testData.put("tosca.relationships.nfv.ForwardsTo", "{derived_from=tosca.relationships.root, valid_target_types=[tosca.capabilities.nfv.Forwarder]}");
- testData.put("tosca.capabilities.nfv.VirtualLinkable", "{derived_from=tosca.capabilities.network.Linkable}");
- testData.put("tosca.capabilities.nfv.VirtualBindable", "{derived_from=tosca.capabilities.network.Bindable}");
- testData.put("tosca.capabilities.nfv.HA", "{derived_from=tosca.capabilities.Root, valid_source_types=[tosca.nodes.nfv.VDU]}");
- testData.put("tosca.capabilities.nfv.HA.ActiveActive", "{derived_from=tosca.capabilities.nfv.HA}");
- testData.put("tosca.capabilities.nfv.HA.ActivePassive", "{derived_from=tosca.capabilities.nfv.HA}");
- testData.put("tosca.capabilities.nfv.Metric", "{derived_from=tosca.capabilities.Root}");
- testData.put("tosca.capabilities.nfv.Forwarder", "{derived_from=tosca.capabilities.Root}");
+ Map<String, Object> testData = new HashMap<>();
+ testData.put("tosca.nodes.nfv.VNF", "{derived_from=tosca.nodes.Root, properties={id={type=string, description=ID of this VNF}, vendor={type=string, description=name of the vendor who generate this VNF}, version={type=version, description=version of the software for this VNF}}, requirements=[{virtualLink={capability=tosca.capabilities.nfv.VirtualLinkable, relationship=tosca.relationships.nfv.VirtualLinksTo, node=tosca.nodes.nfv.VL}}]}");
+ testData.put("tosca.nodes.nfv.VDU", "{derived_from=tosca.nodes.Compute, capabilities={high_availability={type=tosca.capabilities.nfv.HA}, virtualbinding={type=tosca.capabilities.nfv.VirtualBindable}, monitoring_parameter={type=tosca.capabilities.nfv.Metric}}, requirements=[{high_availability={capability=tosca.capabilities.nfv.HA, relationship=tosca.relationships.nfv.HA, node=tosca.nodes.nfv.VDU, occurrences=[0, 1]}}]}");
+ testData.put("tosca.nodes.nfv.CP", "{derived_from=tosca.nodes.network.Port, properties={type={type=string, required=false}}, requirements=[{virtualLink={capability=tosca.capabilities.nfv.VirtualLinkable, relationship=tosca.relationships.nfv.VirtualLinksTo, node=tosca.nodes.nfv.VL}}, {virtualBinding={capability=tosca.capabilities.nfv.VirtualBindable, relationship=tosca.relationships.nfv.VirtualBindsTo, node=tosca.nodes.nfv.VDU}}], attributes={address={type=string}}}");
+ testData.put("tosca.nodes.nfv.VL", "{derived_from=tosca.nodes.network.Network, properties={vendor={type=string, required=true, description=name of the vendor who generate this VL}}, capabilities={virtual_linkable={type=tosca.capabilities.nfv.VirtualLinkable}}}");
+ testData.put("tosca.nodes.nfv.VL.ELine", "{derived_from=tosca.nodes.nfv.VL, capabilities={virtual_linkable={occurrences=2}}}");
+ testData.put("tosca.nodes.nfv.VL.ELAN", "{derived_from=tosca.nodes.nfv.VL}");
+ testData.put("tosca.nodes.nfv.VL.ETree", "{derived_from=tosca.nodes.nfv.VL}");
+ testData.put("tosca.nodes.nfv.FP", "{derived_from=tosca.nodes.Root, properties={policy={type=string, required=false, description=name of the vendor who generate this VL}}, requirements=[{forwarder={capability=tosca.capabilities.nfv.Forwarder, relationship=tosca.relationships.nfv.ForwardsTo}}]}");
+ testData.put("tosca.groups.nfv.VNFFG", "{derived_from=tosca.groups.Root, properties={vendor={type=string, required=true, description=name of the vendor who generate this VNFFG}, version={type=string, required=true, description=version of this VNFFG}, number_of_endpoints={type=integer, required=true, description=count of the external endpoints included in this VNFFG}, dependent_virtual_link={type=list, entry_schema={type=string}, required=true, description=Reference to a VLD used in this Forwarding Graph}, connection_point={type=list, entry_schema={type=string}, required=true, description=Reference to Connection Points forming the VNFFG}, constituent_vnfs={type=list, entry_schema={type=string}, required=true, description=Reference to a list of VNFD used in this VNF Forwarding Graph}}}");
+ testData.put("tosca.relationships.nfv.VirtualLinksTo", "{derived_from=tosca.relationships.network.LinksTo, valid_target_types=[tosca.capabilities.nfv.VirtualLinkable]}");
+ testData.put("tosca.relationships.nfv.VirtualBindsTo", "{derived_from=tosca.relationships.network.BindsTo, valid_target_types=[tosca.capabilities.nfv.VirtualBindable]}");
+ testData.put("tosca.relationships.nfv.HA", "{derived_from=tosca.relationships.Root, valid_target_types=[tosca.capabilities.nfv.HA]}");
+ testData.put("tosca.relationships.nfv.Monitor", "{derived_from=tosca.relationships.ConnectsTo, valid_target_types=[tosca.capabilities.nfv.Metric]}");
+ testData.put("tosca.relationships.nfv.ForwardsTo", "{derived_from=tosca.relationships.root, valid_target_types=[tosca.capabilities.nfv.Forwarder]}");
+ testData.put("tosca.capabilities.nfv.VirtualLinkable", "{derived_from=tosca.capabilities.network.Linkable}");
+ testData.put("tosca.capabilities.nfv.VirtualBindable", "{derived_from=tosca.capabilities.network.Bindable}");
+ testData.put("tosca.capabilities.nfv.HA", "{derived_from=tosca.capabilities.Root, valid_source_types=[tosca.nodes.nfv.VDU]}");
+ testData.put("tosca.capabilities.nfv.HA.ActiveActive", "{derived_from=tosca.capabilities.nfv.HA}");
+ testData.put("tosca.capabilities.nfv.HA.ActivePassive", "{derived_from=tosca.capabilities.nfv.HA}");
+ testData.put("tosca.capabilities.nfv.Metric", "{derived_from=tosca.capabilities.Root}");
+ testData.put("tosca.capabilities.nfv.Forwarder", "{derived_from=tosca.capabilities.Root}");
- Map<String, Object> expectedDefMap = origMap;
- expectedDefMap.putAll(testData);
- EntityType.updateDefinitions("tosca_simple_profile_for_nfv_1_0_0");
+ Map<String, Object> expectedDefMap = origMap;
+ expectedDefMap.putAll(testData);
+ EntityType.updateDefinitions("tosca_simple_profile_for_nfv_1_0_0");
- assertEquals(expectedDefMap, EntityType.TOSCA_DEF);
+ assertEquals(expectedDefMap, EntityType.TOSCA_DEF);
- }
+ }
- @After
- public void tearDown() throws Exception {
- EntityType.TOSCA_DEF = (LinkedHashMap<String, Object>) origMap;
- }
+ @After
+ public void tearDown() throws Exception {
+ EntityType.TOSCA_DEF = (LinkedHashMap<String, Object>) origMap;
+ }
}
diff --git a/src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java b/src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java
index 577fb17..98e5102 100644
--- a/src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java
+++ b/src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java
@@ -5,9 +5,9 @@
* 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.
@@ -41,10 +41,10 @@ public class GetInputTest {
private static final String TEST_PROPERTY_LONGITUDE = "longitude";
private static final String TEST_DEFAULT_VALUE = "dsvpn-hub";
private static final String TEST_DESCRIPTION_VALUE = "This is used for SDWAN only";
- private static final String TEST_INPUT_TYPE="type";
- private static final String TEST_INPUT_SCHEMA_TYPE="tosca.datatypes.siteresource.site";
+ private static final String TEST_INPUT_TYPE = "type";
+ private static final String TEST_INPUT_SCHEMA_TYPE = "tosca.datatypes.siteresource.site";
private static final String TEST_TOSTRING = "get_input:[sites, 1, longitude]";
- private static final String TEST_INPUT_SITES= "sites";
+ private static final String TEST_INPUT_SITES = "sites";
@Test
public void validate() throws JToscaException {
@@ -54,33 +54,33 @@ public class GetInputTest {
NodeTemplate nodeTemplate = toscaTemplate.getNodeTemplates().get(1).getSubMappingToscaTemplate().getNodeTemplates().get(0);
ArrayList<Input> inputs = toscaTemplate.getNodeTemplates().get(1).getSubMappingToscaTemplate().getInputs();
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
- assertThat(properties,notNullValue());
- assertThat(properties.size(),is(14));
+ assertThat(properties, notNullValue());
+ assertThat(properties.size(), is(14));
Property property = properties.get(TEST_PROPERTY_ROLE);
- assertThat(properties,notNullValue());
- assertThat(property.getName(),is(TEST_PROPERTY_ROLE));
- assertThat(property.getType(),is(Schema.STRING));
- assertThat(property.getDefault(),is(TEST_DEFAULT_VALUE));
- assertThat(property.getDescription(),is(TEST_DESCRIPTION_VALUE));
- GetInput getInput= (GetInput)property.getValue();
- assertThat(getInput.getEntrySchema().get(TEST_INPUT_TYPE).toString(),is(TEST_INPUT_SCHEMA_TYPE));
+ assertThat(properties, notNullValue());
+ assertThat(property.getName(), is(TEST_PROPERTY_ROLE));
+ assertThat(property.getType(), is(Schema.STRING));
+ assertThat(property.getDefault(), is(TEST_DEFAULT_VALUE));
+ assertThat(property.getDescription(), is(TEST_DESCRIPTION_VALUE));
+ GetInput getInput = (GetInput) property.getValue();
+ assertThat(getInput.getEntrySchema().get(TEST_INPUT_TYPE).toString(), is(TEST_INPUT_SCHEMA_TYPE));
property = properties.get(TEST_PROPERTY_LONGITUDE);
- assertThat(properties,notNullValue());
+ assertThat(properties, notNullValue());
assertThat(property.getName(), is(TEST_PROPERTY_LONGITUDE));
- assertThat(property.getValue().toString(),is(TEST_TOSTRING));
- getInput= (GetInput)property.getValue();
+ assertThat(property.getValue().toString(), is(TEST_TOSTRING));
+ getInput = (GetInput) property.getValue();
ArrayList<Object> getInputArguments = getInput.getArguments();
- assertThat(getInputArguments.size(),is(3));
+ assertThat(getInputArguments.size(), is(3));
assertThat(getInputArguments.get(0).toString(), is(TEST_INPUT_SITES));
assertThat(getInputArguments.get(1).toString(), is("1"));
assertThat(getInputArguments.get(2).toString(), is(TEST_PROPERTY_LONGITUDE));
Input in = inputs.get(10);
assertThat(in.getEntrySchema().get(TEST_INPUT_TYPE), is(TEST_INPUT_SCHEMA_TYPE));
- assertThat(in.getName(),is(TEST_INPUT_SITES));
- assertThat(in.getType(),is(Input.LIST));
+ assertThat(in.getName(), is(TEST_INPUT_SITES));
+ assertThat(in.getType(), is(Input.LIST));
}
@Test
@@ -88,9 +88,9 @@ public class GetInputTest {
//invalid file
String fileStr = JToscaImportTest.class.getClassLoader().getResource(TEST_FILENAME_NG).getFile();
File file = new File(fileStr);
- ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null,false);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null, false);
List<String> issues = ThreadLocalsHolder.getCollector().getValidationIssueReport();
assertTrue(issues.stream().anyMatch(x -> x.contains("JE282")));
}
- }
+}