Fix use of Optional in ModelOperation 69/126569/1
authorfranciscovila <javier.paradela.vila@est.tech>
Wed, 12 Jan 2022 12:57:15 +0000 (12:57 +0000)
committerFrancisco Javier Paradela Vila <javier.paradela.vila@est.tech>
Wed, 12 Jan 2022 13:02:38 +0000 (13:02 +0000)
Checking the Optionals are present before getting
their values in the ModelOperation class

Issue-ID: SDC-3832
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: Ia28c3ebbd32db83b54b4f8d5b5fa35dfa2c4af50

catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java

index b5cb9d9..b73f40f 100644 (file)
@@ -246,7 +246,8 @@ public class ModelOperation {
     private Model convertToModel(final GraphVertex modelGraphVertex) {
         final String modelName = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME);
         final String modelTypeProperty = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.MODEL_TYPE);
-        final ModelTypeEnum modelType = StringUtils.isEmpty(modelTypeProperty) ? ModelTypeEnum.NORMATIVE : ModelTypeEnum.findByValue(modelTypeProperty).get();
+        final ModelTypeEnum modelType = StringUtils.isEmpty(modelTypeProperty) ? ModelTypeEnum.NORMATIVE :
+                ModelTypeEnum.findByValue(modelTypeProperty).isPresent() ? ModelTypeEnum.findByValue(modelTypeProperty).get() : ModelTypeEnum.NORMATIVE;
         
         final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> parentNode =
             janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Model), UniqueIdBuilder.buildModelUid(modelName),