fix null pointer
authorTufman, Shay <tufman@gmail.com>
Tue, 20 Nov 2018 12:48:55 +0000 (14:48 +0200)
committerTufman, Shay <st198j@intl.att.com>
Tue, 20 Nov 2018 14:15:10 +0000 (16:15 +0200)
Change-Id: If530734b96c32b25b2ed5df847c83dca2c633184
Issue-ID: SDC-1926
Signed-off-by: Tufman, Shay <st198j@intl.att.com>
pom.xml
src/main/java/org/onap/sdc/toscaparser/api/DataEntity.java
src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java
src/test/resources/csars/service-JennyVtsbcKarunaSvc-csar.csar [new file with mode: 0644]
version.properties

diff --git a/pom.xml b/pom.xml
index c25d8a7..20a4dc3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
 
        <groupId>org.onap.sdc.jtosca</groupId>
        <artifactId>jtosca</artifactId>
-       <version>1.4.6-SNAPSHOT</version>
+       <version>1.4.7-SNAPSHOT</version>
        <name>sdc-jtosca</name>
        <properties>
 
index 2a12a71..1559e66 100644 (file)
@@ -49,9 +49,11 @@ public class DataEntity {
         else {
             if(!(value instanceof LinkedHashMap)) {
                //ERROR under investigation
-                ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE001", String.format(
-                    "TypeMismatchError: \"%s\" is not a map. The type is \"%s\"",
-                    value.toString(),dataType.getType())));
+                               String checkedVal = value != null ? value.toString() : null;
+
+                               ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE001", String.format(
+                                               "TypeMismatchError: \"%s\" is not a map. The type is \"%s\"",
+                                               checkedVal, dataType.getType())));
                 
                                if (value instanceof List && ((List) value).size() > 0)  {
                                        value = ((List) value).get(0);
index 6fc8771..8e587a9 100644 (file)
@@ -111,6 +111,16 @@ public class JToscaImportTest {
         assertNull(nodeTemplate.getPropertyValueFromTemplatesByName("test"));
     }
 
+       @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);
+       }
+
     private void validateInputsAnnotations(List<Input> inputs) {
                List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
                                .collect(Collectors.toList());
diff --git a/src/test/resources/csars/service-JennyVtsbcKarunaSvc-csar.csar b/src/test/resources/csars/service-JennyVtsbcKarunaSvc-csar.csar
new file mode 100644 (file)
index 0000000..3f80621
Binary files /dev/null and b/src/test/resources/csars/service-JennyVtsbcKarunaSvc-csar.csar differ
index ed1cd82..442dce4 100644 (file)
@@ -5,7 +5,7 @@
 
 major=1
 minor=4
-patch=6
+patch=7
 
 base_version=${major}.${minor}.${patch}