From: franciscovila Date: Tue, 18 Jan 2022 09:42:50 +0000 (+0000) Subject: Fix use of Optional in ModelOperation X-Git-Tag: 1.10.1~21 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=93f24e4b3ffc331befc5bcdcffd361d77f5ecadd;p=sdc.git Fix use of Optional in ModelOperation Checking the Optionals are present before getting their values in the ModelOperation class Issue-ID: SDC-3832 Signed-off-by: franciscovila Change-Id: I1bf55744a6bd31d1fe423fd0eabf09f0c04a2422 --- diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java index b73f40f8f1..8118eb3619 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java @@ -246,8 +246,11 @@ 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).isPresent() ? ModelTypeEnum.findByValue(modelTypeProperty).get() : ModelTypeEnum.NORMATIVE; + ModelTypeEnum modelType = ModelTypeEnum.NORMATIVE; + final Optional optionalModelTypeEnum = ModelTypeEnum.findByValue(modelTypeProperty); + if (optionalModelTypeEnum.isPresent()) { + modelType = optionalModelTypeEnum.get(); + } final Either, JanusGraphOperationStatus> parentNode = janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Model), UniqueIdBuilder.buildModelUid(modelName),