Fix sonar issues in Aggregate 79/109179/1
authorRodrigo Lima <rodrigo.lima@yoppworks.com>
Mon, 15 Jun 2020 21:21:00 +0000 (17:21 -0400)
committerRodrigo Lima <rodrigo.lima@yoppworks.com>
Mon, 15 Jun 2020 21:21:00 +0000 (17:21 -0400)
- check obj.isPresent() in method processInput
- return Optional.empty instead of null in method createPropertiesObject

Issue-ID: AAI-2934
Signed-off-by: Rodrigo Lima <rodrigo.lima@yoppworks.com>
Change-Id: Iebe0184ce39f244dd56e6861617cbf4e5dafb06c

aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java

index b762726..9ce343f 100644 (file)
@@ -129,7 +129,7 @@ public class Aggregate extends MultiFormatMapper {
                         json.addProperty(prop.key(), gson.toJson(prop.value()));
                     } else {
                         // throw exception?
-                        return null;
+                        return Optional.empty();
                     }
                 }
             } else {
@@ -214,7 +214,7 @@ public class Aggregate extends MultiFormatMapper {
                 json.add(inner);
             } else {
                 Optional<JsonObject> obj = this.getJsonFromVertex((Vertex)l, properties);
-                json.add(obj.get());
+                if(obj.isPresent()) json.add(obj.get());
             }
         }
         return Optional.of(json);