From afee4df36caa1a979586c8badf160c3ff49b97a0 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 28 Aug 2018 23:58:12 +0000 Subject: Controller Blueprints Microservice Add Resource Assignment Validation Service and their Test cases. Change-Id: I106be2bfc03115867041ca341947a4662cf126c4 Issue-ID: CCSDK-487 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../service/BluePrintRepoDBService.java | 22 ++++++++++--------- .../service/repository/ModelTypeRepository.java | 25 +++++++++++++++------- 2 files changed, 29 insertions(+), 18 deletions(-) (limited to 'ms/controllerblueprints/modules/service/src/main') diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java index ae4fed9f4..c4aebe52c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service; import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.*; import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService; @@ -36,36 +37,37 @@ import java.util.Optional; * @author Brinda Santh */ @Service +@SuppressWarnings("unused") public class BluePrintRepoDBService implements BluePrintRepoService { private ModelTypeRepository modelTypeRepository; - + @SuppressWarnings("unused") public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) { this.modelTypeRepository = modelTypeRepository; } @Override - public Mono getNodeType(String nodeTypeName) throws BluePrintException { + public Mono getNodeType(@NotNull String nodeTypeName) throws BluePrintException { return getModelType(nodeTypeName, NodeType.class); } @Override - public Mono getDataType(String dataTypeName) throws BluePrintException { + public Mono getDataType(@NotNull String dataTypeName) throws BluePrintException { return getModelType(dataTypeName, DataType.class); } @Override - public Mono getArtifactType(String artifactTypeName) throws BluePrintException { + public Mono getArtifactType(@NotNull String artifactTypeName) throws BluePrintException { return getModelType(artifactTypeName, ArtifactType.class); } @Override - public Mono getRelationshipType(String relationshipTypeName) throws BluePrintException { + public Mono getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException { return getModelType(relationshipTypeName, RelationshipType.class); } @Override - public Mono getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException { + public Mono getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException { return getModelType(capabilityDefinitionName, CapabilityDefinition.class); } @@ -73,15 +75,15 @@ public class BluePrintRepoDBService implements BluePrintRepoService { Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Failed to get model from repo, model name is missing"); - return getModelDefinitions(modelName).map(content -> { - Preconditions.checkArgument(StringUtils.isNotBlank(content), - String.format("Failed to get model content for model name (%s)", modelName)); + return getModelDefinition(modelName).map(content -> { + Preconditions.checkArgument(StringUtils.isNotBlank(content), + String.format("Failed to get model content for model name (%s)", modelName)); return JacksonUtils.readValue(content, valueClass); } ); } - private Mono getModelDefinitions(String modelName) throws BluePrintException { + private Mono getModelDefinition(String modelName) throws BluePrintException { String modelDefinition; Optional modelTypeDb = modelTypeRepository.findByModelName(modelName); if (modelTypeDb.isPresent()) { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java index 51ae752f9..27823ef33 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java @@ -37,15 +37,23 @@ public interface ModelTypeRepository extends JpaRepository { /** * This is a findByModelName method * - * @param modelName + * @param modelName Model Name * @return Optional */ Optional findByModelName(String modelName); + /** + * This is a findByModelNameIn method + * + * @param modelNames Model Names + * @return List + */ + List findByModelNameIn(List modelNames); + /** * This is a findByDerivedFrom method * - * @param derivedFrom + * @param derivedFrom Derived From * @return List */ List findByDerivedFrom(String derivedFrom); @@ -54,15 +62,16 @@ public interface ModelTypeRepository extends JpaRepository { /** * This is a findByDerivedFromIn method * - * @param derivedFroms + * @param derivedFroms Derived Froms * @return List */ + @SuppressWarnings("unused") List findByDerivedFromIn(List derivedFroms); /** * This is a findByDefinitionType method * - * @param definitionType + * @param definitionType Definition Type * @return List */ List findByDefinitionType(String definitionType); @@ -70,16 +79,17 @@ public interface ModelTypeRepository extends JpaRepository { /** * This is a findByDefinitionTypeIn method * - * @param definitionTypes + * @param definitionTypes Definition Types * @return List */ + @SuppressWarnings("unused") List findByDefinitionTypeIn(List definitionTypes); /** * This is a findByTagsContainingIgnoreCase method * - * @param tags + * @param tags Tags * @return Optional */ List findByTagsContainingIgnoreCase(String tags); @@ -88,8 +98,7 @@ public interface ModelTypeRepository extends JpaRepository { /** * This is a deleteByModelName method * - * @param modelName - * @return Optional + * @param modelName ModelName */ void deleteByModelName(String modelName); -- cgit 1.2.3-korg