From 254217ffff5edea9069f96b992a5939b3745d376 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 29 Aug 2018 19:53:08 +0000 Subject: Controller Blueprints Microservice Improve code quality for Performance, JavaDoc, Imports, Probably Bug etc Change-Id: Ib71b62f14e8e8bd212e671a135025258fd9927b4 Issue-ID: CCSDK-491 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/service/BluePrintRuntimeService.kt | 2 +- .../core/utils/JacksonUtils.kt | 2 +- .../BluePrintValidatorDefaultServiceTest.kt | 3 +- .../validator/ResourceAssignmentValidator.java | 13 +++--- .../service/ResourceAssignmentValidationService.kt | 5 ++- .../service/ApplicationRegistrationService.java | 1 + .../service/AutoResourceMappingService.java | 39 +++++++++--------- .../service/BluePrintEnhancerService.java | 24 ++++++----- .../service/ConfigModelCreateService.java | 48 +++++++++------------- .../service/DataBaseInitService.java | 8 ++-- .../service/ServiceTemplateService.java | 28 ++++++------- .../service/domain/ConfigModel.java | 17 +++----- .../service/domain/ConfigModelContent.java | 10 ++--- .../service/domain/ConfigModelSearch.java | 16 +++----- .../service/domain/ModelType.java | 23 ++++------- .../service/domain/ResourceDictionary.java | 25 ++++------- .../repository/ConfigModelContentRepository.java | 32 +++++++++------ .../service/repository/ConfigModelRepository.java | 27 +++++++----- .../service/rs/ModelTypeRest.java | 2 - .../service/utils/ConfigModelUtils.java | 7 +++- .../service/validator/ModelTypeValidator.java | 3 +- .../validator/ServiceTemplateValidator.java | 12 +++--- .../service/rs/ModelTypeRestTest.java | 5 +-- .../validator/ServiceTemplateValidationTest.java | 1 - 24 files changed, 159 insertions(+), 194 deletions(-) (limited to 'ms/controllerblueprints/modules') diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 5a8d5428a..9ba6313c9 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -20,13 +20,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.slf4j.Logger import org.slf4j.LoggerFactory /** diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 886c3d2aa..c41124ed3 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -27,13 +27,13 @@ import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.apache.commons.io.FileUtils import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.format import org.slf4j.LoggerFactory import java.io.File import java.nio.charset.Charset -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants /** * diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt index bccd946c4..50d2ce441 100644 --- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt +++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt @@ -18,10 +18,11 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import org.junit.Before import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory import org.slf4j.Logger import org.slf4j.LoggerFactory + /** * * diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java index c980a0c08..c9b37c269 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java @@ -29,15 +29,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; + /** - * * ResourceAssignmentValidator.java Purpose: + * * @author Brinda Santh */ public class ResourceAssignmentValidator { private static final Logger log = LoggerFactory.getLogger(ResourceAssignmentValidator.class); private List assignments; - private Map resourceAssignmentMap = new HashMap(); + private Map resourceAssignmentMap = new HashMap<>(); private StrBuilder validationMessage = new StrBuilder(); public ResourceAssignmentValidator(List assignments) { @@ -72,7 +73,7 @@ public class ResourceAssignmentValidator { * This is a validateResourceAssignment to validate the Topology Template * * @return boolean - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public boolean validateResourceAssignment() throws BluePrintException { if (assignments != null && !assignments.isEmpty()) { @@ -142,16 +143,14 @@ public class ResourceAssignmentValidator { neighbors.forEach((v, vs) -> { if (v == null) { s.append("\n * -> ["); - List links = vs; - for (ResourceAssignment resourceAssignment : links) { + for (ResourceAssignment resourceAssignment : vs) { s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName() + "),"); } s.append("]"); } else { s.append("\n (" + v.getDictionaryName() + ":" + v.getName() + ") -> ["); - List links = vs; - for (ResourceAssignment resourceAssignment : links) { + for (ResourceAssignment resourceAssignment : vs) { s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName() + "),"); } diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 6809831f9..6a78ac852 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -16,15 +16,16 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service +import org.apache.commons.collections.CollectionUtils +import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator import org.slf4j.LoggerFactory -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang3.StringUtils import java.io.Serializable + /** * ResourceAssignmentValidationService. * diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java index 6d0ec8899..5a4a2877e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java @@ -22,6 +22,7 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @Component +@SuppressWarnings("unused") public class ApplicationRegistrationService { @PostConstruct diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java index 2c443783e..5eba4fc7f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service; +import com.google.common.base.Preconditions; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; @@ -45,6 +46,7 @@ import java.util.Map; */ @Service +@SuppressWarnings("unused") public class AutoResourceMappingService { private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class); @@ -53,9 +55,8 @@ public class AutoResourceMappingService { /** * This is a AutoResourceMappingService constructor - * - * @param dataDictionaryRepository - * + * + * @param dataDictionaryRepository dataDictionaryRepository */ public AutoResourceMappingService(ResourceDictionaryRepository dataDictionaryRepository) { this.dataDictionaryRepository = dataDictionaryRepository; @@ -63,8 +64,8 @@ public class AutoResourceMappingService { /** * This is a autoMap service to map the template keys automatically to Dictionary fields. - * - * @param resourceAssignments + * + * @param resourceAssignments resourceAssignments * @return AutoMapResponse */ public AutoMapResponse autoMap(List resourceAssignments) throws BluePrintException { @@ -83,8 +84,6 @@ public class AutoResourceMappingService { log.info("Mapped Resource : {}", resourceAssignment); - } else { - // Do nothins } } } @@ -125,7 +124,7 @@ public class AutoResourceMappingService { if (CollectionUtils.isNotEmpty(names)) { List dictionaries = dataDictionaryRepository.findByNameIn(names); - if (CollectionUtils.isNotEmpty( dictionaries)) { + if (CollectionUtils.isNotEmpty(dictionaries)) { for (ResourceDictionary dataDictionary : dictionaries) { if (dataDictionary != null && StringUtils.isNotBlank(dataDictionary.getName())) { dictionaryMap.put(dataDictionary.getName(), dataDictionary); @@ -167,14 +166,13 @@ public class AutoResourceMappingService { private List getAllAutomapResourceAssignments(List resourceAssignments) { List dictionaries = null; List names = new ArrayList<>(); - List resourceAssignmentsWithDepencies = resourceAssignments; for (ResourceAssignment resourceAssignment : resourceAssignments) { if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) { if (resourceAssignment.getDependencies() != null && !resourceAssignment.getDependencies().isEmpty()) { List dependencieNames = resourceAssignment.getDependencies(); for (String dependencieName : dependencieNames) { if (StringUtils.isNotBlank(dependencieName) && !names.contains(dependencieName) - && !checkAssignmentsExists(resourceAssignmentsWithDepencies, dependencieName)) { + && !checkAssignmentsExists(resourceAssignments, dependencieName)) { names.add(dependencieName); } } @@ -188,24 +186,25 @@ public class AutoResourceMappingService { if (dictionaries != null) { for (ResourceDictionary resourcedictionary : dictionaries) { ResourceDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), ResourceDefinition.class); + Preconditions.checkNotNull(dictionaryDefinition, "failed to get Resource Definition from dictionary definition"); PropertyDefinition property = new PropertyDefinition(); - property.setRequired(true); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName(resourcedictionary.getName()); - resourceAssignment.setDictionaryName(resourcedictionary - .getName()); - resourceAssignment.setVersion(0); - resourceAssignment.setProperty(property); + property.setRequired(true); + ResourceAssignment resourceAssignment = new ResourceAssignment(); + resourceAssignment.setName(resourcedictionary.getName()); + resourceAssignment.setDictionaryName(resourcedictionary + .getName()); + resourceAssignment.setVersion(0); + resourceAssignment.setProperty(property); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition); - resourceAssignmentsWithDepencies.add(resourceAssignment); + resourceAssignments.add(resourceAssignment); } } - return resourceAssignmentsWithDepencies; + return resourceAssignments; } - public boolean checkAssignmentsExists(List resourceAssignmentsWithDepencies, String resourceName) { + private boolean checkAssignmentsExists(List resourceAssignmentsWithDepencies, String resourceName) { return resourceAssignmentsWithDepencies.stream().anyMatch(names -> names.getName().equalsIgnoreCase(resourceName)); } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index 0cf846c7a..28be75e66 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Preconditions; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; @@ -47,7 +48,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private static Logger log = LoggerFactory.getLogger(BluePrintEnhancerService.class); - private HashMap recipeDataTypes = new HashMap<>(); + private Map recipeDataTypes = new HashMap<>(); public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) { super(bluePrintEnhancerRepoDBService); @@ -119,7 +120,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { if (StringUtils.isNotBlank(recipeName)) { DataType recipeDataType = this.recipeDataTypes.get(recipeName); if (recipeDataType == null) { - log.info("DataType not present for the recipe({})" , recipeName); + log.info("DataType not present for the recipe({})", recipeName); recipeDataType = new DataType(); recipeDataType.setVersion("1.0.0"); recipeDataType.setDescription( @@ -129,7 +130,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { Map dataTypeProperties = new HashMap<>(); recipeDataType.setProperties(dataTypeProperties); } else { - log.info("DataType Already present for the recipe({})" , recipeName); + log.info("DataType Already present for the recipe({})", recipeName); } // Merge all the Recipe Properties @@ -145,7 +146,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { NodeTemplate nodeTemplate) { Map dataTypeProperties = null; - if (nodeTemplate != null) { + if (nodeTemplate != null && MapUtils.isNotEmpty(nodeTemplate.getCapabilities())) { CapabilityAssignment capability = nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING); @@ -182,17 +183,18 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private void mergeDataTypeProperties(DataType dataType, Map mergeProperties) { if (dataType != null && dataType.getProperties() != null && mergeProperties != null) { // Add the Other Template Properties - mergeProperties.forEach((mappingKey, propertyDefinition) -> { - dataType.getProperties().put(mappingKey, propertyDefinition); - }); + mergeProperties.forEach((mappingKey, propertyDefinition) -> dataType.getProperties().put(mappingKey, propertyDefinition)); } } private void populateRecipeInputs(ServiceTemplate serviceTemplate) { - if (this.recipeDataTypes != null && !this.recipeDataTypes.isEmpty()) { + if (serviceTemplate.getTopologyTemplate() != null + && MapUtils.isNotEmpty(serviceTemplate.getTopologyTemplate().getInputs()) + && MapUtils.isNotEmpty(this.recipeDataTypes) + && MapUtils.isNotEmpty(serviceTemplate.getDataTypes())) { this.recipeDataTypes.forEach((recipeName, recipeDataType) -> { - String dataTypePrifix = recipeName.replace("-action", "") + "-request"; - String dataTypeName = "dt-" + dataTypePrifix; + String dataTypePrefix = recipeName.replace("-action", "") + "-request"; + String dataTypeName = "dt-" + dataTypePrefix; serviceTemplate.getDataTypes().put(dataTypeName, recipeDataType); @@ -200,7 +202,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { customInputProperty.setDescription("This is Dynamic Data type for the receipe " + recipeName + "."); customInputProperty.setRequired(Boolean.FALSE); customInputProperty.setType(dataTypeName); - serviceTemplate.getTopologyTemplate().getInputs().put(dataTypePrifix, customInputProperty); + serviceTemplate.getTopologyTemplate().getInputs().put(dataTypePrefix, customInputProperty); }); } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java index e40c2cf42..f52137191 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java @@ -197,7 +197,7 @@ public class ConfigModelCreateService { private void deleteConfigModelContent(Long dbConfigModelId) { if (dbConfigModelId != null) { ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId); - if (dbConfigModel != null && CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) { + if (CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) { dbConfigModel.getConfigModelContents().clear(); log.debug("Configuration Model content deleting : {}", dbConfigModel.getConfigModelContents()); configModelRepository.saveAndFlush(dbConfigModel); @@ -210,18 +210,15 @@ public class ConfigModelCreateService { if (dbConfigModelId != null && configModel != null && CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) { ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId); - if (dbConfigModel != null) { - for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) { - if (configModelContent != null) { - configModelContent.setId(null); - configModelContent.setConfigModel(dbConfigModel); - dbConfigModel.getConfigModelContents().add(configModelContent); - log.debug("Configuration Model content adding : {}", configModelContent); - } + for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) { + if (configModelContent != null) { + configModelContent.setId(null); + configModelContent.setConfigModel(dbConfigModel); + dbConfigModel.getConfigModelContents().add(configModelContent); + log.debug("Configuration Model content adding : {}", configModelContent); } - configModelRepository.saveAndFlush(dbConfigModel); } - + configModelRepository.saveAndFlush(dbConfigModel); } } @@ -229,22 +226,19 @@ public class ConfigModelCreateService { String author) throws BluePrintException { ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId); - if (dbConfigModel != null) { - // Populate tags from metadata - String tags = getConfigModelTags(dbConfigModel); - if (StringUtils.isBlank(tags)) { - throw new BluePrintException("Failed to populate tags for the config model name " + artifactName); - } - dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL); - dbConfigModel.setArtifactName(artifactName); - dbConfigModel.setArtifactVersion(artifactVersion); - dbConfigModel.setUpdatedBy(author); - dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N); - dbConfigModel.setTags(tags); - configModelRepository.saveAndFlush(dbConfigModel); - - log.info("Config model ({}) saved successfully.", dbConfigModel.getId()); + // Populate tags from metadata + String tags = getConfigModelTags(dbConfigModel); + if (StringUtils.isBlank(tags)) { + throw new BluePrintException("Failed to populate tags for the config model name " + artifactName); } + dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL); + dbConfigModel.setArtifactName(artifactName); + dbConfigModel.setArtifactVersion(artifactVersion); + dbConfigModel.setUpdatedBy(author); + dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N); + dbConfigModel.setTags(tags); + configModelRepository.saveAndFlush(dbConfigModel); + log.info("Config model ({}) saved successfully.", dbConfigModel.getId()); return dbConfigModel; } @@ -282,8 +276,6 @@ public class ConfigModelCreateService { configModel.getArtifactName()); } tags = String.valueOf(serviceTemplate.getMetadata()); - } else { - // Do Nothing } } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java index 4b732cc30..89d482962 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java @@ -55,7 +55,7 @@ import java.util.List; */ @Component -@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true", matchIfMissing = false) +@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true") public class DataBaseInitService { private static Logger log = LoggerFactory.getLogger(DataBaseInitService.class); @@ -77,9 +77,9 @@ public class DataBaseInitService { /** * This is a DataBaseInitService, used to load the initial data * - * @param modelTypeService - * @param resourceDictionaryService - * @param configModelService + * @param modelTypeService modelTypeService + * @param resourceDictionaryService resourceDictionaryService + * @param configModelService configModelService */ public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService, ConfigModelService configModelService) { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java index 70b7917a4..70cee3c9e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java @@ -49,9 +49,9 @@ public class ServiceTemplateService { /** * This is a SchemaGeneratorService constructor * - * @param dataDictionaryRepository - * @param configModelCreateService - * @param bluePrintEnhancerService + * @param dataDictionaryRepository dataDictionaryRepository + * @param configModelCreateService configModelCreateService + * @param bluePrintEnhancerService bluePrintEnhancerService */ public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository, ConfigModelCreateService configModelCreateService, @@ -65,9 +65,9 @@ public class ServiceTemplateService { /** * This is a validateServiceTemplate method * - * @param serviceTemplate + * @param serviceTemplate serviceTemplate * @return ServiceTemplate - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { return this.configModelCreateService.validateServiceTemplate(serviceTemplate); @@ -76,11 +76,10 @@ public class ServiceTemplateService { /** * This is a enrichServiceTemplate method * - * @param serviceTemplate + * @param serviceTemplate serviceTemplate * @return ServiceTemplate - * @throws BluePrintException */ - public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { + public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) { this.bluePrintEnhancerService.enhance(serviceTemplate); return serviceTemplate; } @@ -88,22 +87,21 @@ public class ServiceTemplateService { /** * This is a autoMap method to map the template keys * - * @param resourceAssignments + * @param resourceAssignments resourceAssignments * @return AutoMapResponse - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public AutoMapResponse autoMap(List resourceAssignments) throws BluePrintException { AutoResourceMappingService autoMappingService = new AutoResourceMappingService(dataDictionaryRepository); - AutoMapResponse autoMapResponse = autoMappingService.autoMap(resourceAssignments); - return autoMapResponse; + return autoMappingService.autoMap(resourceAssignments); } /** * This is a validateResourceAssignments method * - * @param resourceAssignments + * @param resourceAssignments resourceAssignments * @return List - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public List validateResourceAssignments(List resourceAssignments) throws BluePrintException { @@ -120,7 +118,7 @@ public class ServiceTemplateService { /** * This is a generateResourceAssignments method * - * @param templateContent + * @param templateContent templateContent * @return List */ public List generateResourceAssignments(ConfigModelContent templateContent) { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java index 45382815c..51c9a7c6a 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java @@ -24,7 +24,6 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; @@ -81,8 +80,7 @@ public class ConfigModel implements Serializable { @Column(name = "artifact_type") private String artifactType; - @NotNull - @Column(name = "artifact_version") + @Column(name = "artifact_version", nullable = false) @ApiModelProperty(required=true) private String artifactVersion; @@ -99,30 +97,25 @@ public class ConfigModel implements Serializable { @Column(name = "creation_date") private Date createdDate = new Date(); - @NotNull - @Column(name = "artifact_name") + @Column(name = "artifact_name", nullable = false) @ApiModelProperty(required=true) private String artifactName; - @NotNull - @Column(name = "published") + @Column(name = "published", nullable = false) @ApiModelProperty(required=true) private String published; - @NotNull - @Column(name = "updated_by") + @Column(name = "updated_by", nullable = false) @ApiModelProperty(required=true) private String updatedBy; - @NotNull @Lob - @Column(name = "tags") + @Column(name = "tags", nullable = false) @ApiModelProperty(required=true) private String tags; @OneToMany(mappedBy = "configModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL) - @Column(nullable = true) @JsonManagedReference private List configModelContents = new ArrayList<>(); diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java index 0c05ef959..60b3ed6b0 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java @@ -23,7 +23,6 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; -import javax.validation.constraints.NotNull; import java.util.Date; import java.util.Objects; @@ -45,13 +44,11 @@ public class ConfigModelContent { @Column(name = "config_model_content_id") private Long id; - @NotNull - @Column(name = "name") + @Column(name = "name", nullable = false) @ApiModelProperty(required=true) private String name; - @NotNull - @Column(name = "content_type") + @Column(name = "content_type", nullable = false) @ApiModelProperty(required=true) private String contentType; @@ -65,9 +62,8 @@ public class ConfigModelContent { @Column(name = "description") private String description; - @NotNull @Lob - @Column(name = "content") + @Column(name = "content", nullable = false) @ApiModelProperty(required=true) private String content; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java index 2e9018837..6ec39ab55 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java @@ -20,7 +20,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.data.annotation.LastModifiedDate; import javax.persistence.*; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -40,8 +39,7 @@ public class ConfigModelSearch implements Serializable { @Column(name = "artifact_type") private String artifactType; - @NotNull - @Column(name = "artifact_version") + @Column(name = "artifact_version", nullable = false) private String artifactVersion; @Lob @@ -57,21 +55,17 @@ public class ConfigModelSearch implements Serializable { @Column(name = "creation_date") private Date createdDate = new Date(); - @NotNull - @Column(name = "artifact_name") + @Column(name = "artifact_name", nullable = false) private String artifactName; - @NotNull - @Column(name = "published") + @Column(name = "published", nullable = false) private String published; - @NotNull - @Column(name = "updated_by") + @Column(name = "updated_by", nullable = false) private String updatedBy; - @NotNull @Lob - @Column(name = "tags") + @Column(name = "tags", nullable = false) private String tags; public Long getId() { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java index 61e4d1189..eaa335b3e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java @@ -22,7 +22,6 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -40,41 +39,34 @@ public class ModelType implements Serializable { private static final long serialVersionUID = 1L; @Id - @NotNull @Column(name = "model_name", nullable = false) @ApiModelProperty(required=true) private String modelName; - @NotNull - @Column(name = "derived_from") + @Column(name = "derived_from", nullable = false) @ApiModelProperty(required=true) private String derivedFrom; - @NotNull - @Column(name = "definition_type") + @Column(name = "definition_type", nullable = false) @ApiModelProperty(required=true) private String definitionType; - @NotNull @Lob - @Column(name = "definition") + @Column(name = "definition", nullable = false) @ApiModelProperty(required=true) private String definition; - @NotNull @Lob - @Column(name = "description") + @Column(name = "description", nullable = false) @ApiModelProperty(required=true) private String description; - @NotNull - @Column(name = "version") + @Column(name = "version", nullable = false) @ApiModelProperty(required=true) private String version; - @NotNull @Lob - @Column(name = "tags") + @Column(name = "tags", nullable = false) @ApiModelProperty(required=true) private String tags; @@ -84,8 +76,7 @@ public class ModelType implements Serializable { @Column(name = "creation_date") private Date creationDate; - @NotNull - @Column(name = "updated_by") + @Column(name = "updated_by", nullable = false) @ApiModelProperty(required=true) private String updatedBy; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java index 0d5879db8..487586842 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java @@ -22,7 +22,6 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -39,23 +38,19 @@ public class ResourceDictionary implements Serializable { private static final long serialVersionUID = 1L; @Id - @NotNull - @Column(name = "name") + @Column(name = "name", nullable = false) @ApiModelProperty(required=true) private String name; - @NotNull - @Column(name = "resource_path") + @Column(name = "resource_path", nullable = false) @ApiModelProperty(required=true) private String resourcePath; - @NotNull - @Column(name = "resource_type") + @Column(name = "resource_type", nullable = false) @ApiModelProperty(required=true) private String resourceType; - @NotNull - @Column(name = "data_type") + @Column(name = "data_type", nullable = false) @ApiModelProperty(required=true) private String dataType; @@ -70,21 +65,18 @@ public class ResourceDictionary implements Serializable { @Column(name = "sample_value") private String sampleValue; - @NotNull @Lob - @Column(name = "definition") + @Column(name = "definition", nullable = false) @ApiModelProperty(required=true) private String definition; - @NotNull @Lob - @Column(name = "description") + @Column(name = "description", nullable = false) @ApiModelProperty(required=true) private String description; - @NotNull @Lob - @Column(name = "tags") + @Column(name = "tags", nullable = false) @ApiModelProperty(required=true) private String tags; @@ -94,8 +86,7 @@ public class ResourceDictionary implements Serializable { @Column(name = "creation_date") private Date creationDate; - @NotNull - @Column(name = "updated_by") + @Column(name = "updated_by", nullable = false) @ApiModelProperty(required=true) private String updatedBy; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java index ad2584a8e..733cbbdb3 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java @@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelConten import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import javax.validation.constraints.NotNull; import java.util.List; import java.util.Optional; @@ -36,60 +37,65 @@ public interface ConfigModelContentRepository extends JpaRepository */ - Optional findById(Long id); + @NotNull + Optional findById(@NotNull Long id); /** * This is a findTopByConfigModelAndContentType method * - * @param configModel - * @param contentType + * @param configModel configModel + * @param contentType contentType * @return Optional */ + @SuppressWarnings("unused") Optional findTopByConfigModelAndContentType(ConfigModel configModel, String contentType); /** * This is a findByConfigModelAndContentType method * - * @param configModel - * @param contentType + * @param configModel configModel + * @param contentType contentType * @return Optional */ + @SuppressWarnings("unused") List findByConfigModelAndContentType(ConfigModel configModel, String contentType); /** * This is a findByConfigModel method * - * @param configModel + * @param configModel configModel * @return Optional */ + @SuppressWarnings("unused") List findByConfigModel(ConfigModel configModel); /** * This is a findByConfigModelAndContentTypeAndName method * - * @param configModel - * @param contentType - * @param name + * @param configModel configModel + * @param contentType contentType + * @param name name * @return Optional */ + @SuppressWarnings("unused") Optional findByConfigModelAndContentTypeAndName(ConfigModel configModel, String contentType, String name); /** * This is a deleteByMdeleteByConfigModelodelName method * - * @param configModel + * @param configModel configModel */ void deleteByConfigModel(ConfigModel configModel); /** * This is a deleteById method * - * @param id + * @param id id */ - void deleteById(Long id); + void deleteById(@NotNull Long id); } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java index 4822ee971..0a60ab74d 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java @@ -20,6 +20,7 @@ import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import javax.validation.constraints.NotNull; import java.util.List; import java.util.Optional; @@ -34,16 +35,17 @@ public interface ConfigModelRepository extends JpaRepository /** * This is a findById method * - * @param id + * @param id id * @return Optional */ - Optional findById(Long id); + @NotNull + Optional findById(@NotNull Long id); /** * This is a findByArtifactNameAndArtifactVersion method * - * @param artifactName - * @param artifactVersion + * @param artifactName artifactName + * @param artifactVersion artifactVersion * @return Optional */ Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); @@ -51,7 +53,7 @@ public interface ConfigModelRepository extends JpaRepository /** * This is a findTopByArtifactNameOrderByArtifactIdDesc method * - * @param artifactName + * @param artifactName artifactName * @return Optional */ Optional findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName); @@ -59,15 +61,16 @@ public interface ConfigModelRepository extends JpaRepository /** * This is a findTopByArtifactName method * - * @param artifactName + * @param artifactName artifactName * @return Optional */ + @SuppressWarnings("unused") List findTopByArtifactName(String artifactName); /** * This is a findByTagsContainingIgnoreCase method * - * @param tags + * @param tags tags * @return Optional */ List findByTagsContainingIgnoreCase(String tags); @@ -75,16 +78,18 @@ public interface ConfigModelRepository extends JpaRepository /** * This is a deleteByArtifactNameAndArtifactVersion method * - * @param artifactName - * @param artifactVersion + * @param artifactName artifactName + * @param artifactVersion artifactVersion */ + @SuppressWarnings("unused") void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); /** * This is a deleteById method * - * @param id + * @param id id */ - void deleteById(Long id); + @SuppressWarnings("unused") + void deleteById(@NotNull Long id); } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index f6e5c274f..6bcbae963 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -20,8 +20,6 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.*; import java.util.List; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java index e31b04d16..bfc89b4ee 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java @@ -39,9 +39,10 @@ import java.util.List; public class ConfigModelUtils { - private ConfigModelUtils(){ + private ConfigModelUtils() { } + private static Logger log = LoggerFactory.getLogger(ConfigModelUtils.class); public static ConfigModel getConfigModel(String blueprintPath) throws Exception { @@ -119,6 +120,8 @@ public class ConfigModelUtils { public static List getBlueprintNames(String pathName) { File blueprintDir = new File(pathName); Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file"); - return Arrays.asList(blueprintDir.list(DirectoryFileFilter.INSTANCE)); + String[] dirs = blueprintDir.list(DirectoryFileFilter.INSTANCE); + Preconditions.checkNotNull(dirs, "failed to find the blueprint directories"); + return Arrays.asList(dirs); } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java index 1201f6b49..aaa445a44 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java @@ -63,7 +63,6 @@ public class ModelTypeValidator { */ public static boolean validateModelTypeDefinition(String definitionType, String definitionContent) throws BluePrintException { - boolean valid = true; if (StringUtils.isNotBlank(definitionContent)) { if (BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)) { DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class); @@ -93,7 +92,7 @@ public class ModelTypeValidator { } } - return valid; + return true; } /** diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java index 430401bc3..848a32f5b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java @@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator; import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; @@ -40,14 +39,14 @@ import java.util.Map; public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { StringBuilder message = new StringBuilder(); - private Map metaData = new HashMap(); + private Map metaData = new HashMap<>(); /** * This is a validateServiceTemplate * - * @param serviceTemplateContent + * @param serviceTemplateContent serviceTemplateContent * @return boolean - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException { if (StringUtils.isNotBlank(serviceTemplateContent)) { @@ -65,7 +64,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { * * @param serviceTemplate * @return boolean - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ @SuppressWarnings("squid:S00112") public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { @@ -77,8 +76,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { /** * This is a getMetaData to get the key information during the * - * @return Map + * @return Map */ public Map getMetaData() { return metaData; diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index d328b3eac..08bfeb10c 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -95,7 +95,7 @@ public class ModelTypeRestTest { List dbModelTypes = modelTypeRest.searchModelTypes(tags); Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes); - Assert.assertEquals("Failed to search ResourceMapping by tags count", true, dbModelTypes.size() > 0); + Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0); } @@ -109,8 +109,7 @@ public class ModelTypeRestTest { List dbDatatypeModelTypes = modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes); - Assert.assertEquals("Failed to find getModelTypeByDefinitionType by count", true, - dbDatatypeModelTypes.size() > 0); + Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0); } @Test diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java index 557c6dd8d..0ef544525 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java @@ -18,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.junit.Assert; import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; -- cgit 1.2.3-korg