diff options
Diffstat (limited to 'ms/controllerblueprints/modules/service')
13 files changed, 191 insertions, 273 deletions
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 1875a8022..fa8e32b69 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 @@ -17,6 +17,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.common.base.Preconditions;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
@@ -31,8 +33,6 @@ import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConsta import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -48,25 +48,21 @@ import java.util.Optional; * @author Brinda Santh
* @version 1.0
*/
-
+@Deprecated
@Service
public class ConfigModelCreateService {
private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class);
private ConfigModelRepository configModelRepository;
- private ConfigModelValidatorService configModelValidatorService;
/**
* This is a ConfigModelCreateService
*
- * @param configModelRepository ConfigModelRepository
- * @param configModelValidatorService ConfigModelValidatorService
+ * @param configModelRepository ConfigModelRepository
*/
- public ConfigModelCreateService(ConfigModelRepository configModelRepository,
- ConfigModelValidatorService configModelValidatorService) {
+ public ConfigModelCreateService(ConfigModelRepository configModelRepository) {
this.configModelRepository = configModelRepository;
- this.configModelValidatorService = configModelValidatorService;
}
/**
@@ -127,7 +123,7 @@ public class ConfigModelCreateService { String artifactName = configModel.getArtifactName();
String artifactVersion = configModel.getArtifactVersion();
String author = configModel.getUpdatedBy();
-
+
if (StringUtils.isBlank(author)) {
throw new BluePrintException("Artifact Author is missing in the Service Template");
@@ -326,6 +322,7 @@ public class ConfigModelCreateService { * @throws BluePrintException BluePrintException
*/
public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- return this.configModelValidatorService.validateServiceTemplate(serviceTemplate);
+ // FIXME("Plug right Validator")
+ return serviceTemplate;
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java deleted file mode 100644 index 3abdc04d2..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java +++ /dev/null @@ -1,67 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ServiceTemplateValidator;
-import org.springframework.stereotype.Service;
-
-/**
- * ServiceTemplateValidatorService.java Purpose: Provide Service to Validate Service Model Template
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Deprecated
-@Service
-public class ConfigModelValidatorService {
-
- /**
- * This is a validateServiceTemplate
- *
- * @param serviceTemplateContent
- * @return ServiceTemplate
- * @throws BluePrintException
- */
- public ServiceTemplate validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateContent), "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
- ServiceTemplate serviceTemplate =
- JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
- return validateServiceTemplate(serviceTemplate);
- }
-
- /**
- * This is a enhanceServiceTemplate
- *
- * @param serviceTemplate
- * @return ServiceTemplate
- * @throws BluePrintException
- */
- @SuppressWarnings("squid:S00112")
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");
- ServiceTemplateValidator validator = new ServiceTemplateValidator();
- validator.validateServiceTemplate(serviceTemplate);
- return serviceTemplate;
- }
-
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceAssignmentValidationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceAssignmentValidationService.java deleted file mode 100644 index 1228e2eeb..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceAssignmentValidationService.java +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService;
-import org.springframework.stereotype.Service;
-/**
- * ResourceAssignmentValidationService.
- *
- * @author Brinda Santh
- */
-@Service
-public class ResourceAssignmentValidationService extends ResourceAssignmentValidationDefaultService {
-
-}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionValidationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionValidationService.java deleted file mode 100644 index 485896627..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionValidationService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service; - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionDefaultValidationService; -import org.springframework.stereotype.Service; - -@Service -public class ResourceDefinitionValidationService extends ResourceDefinitionDefaultValidationService { - - public ResourceDefinitionValidationService(BluePrintRepoService bluePrintRepoService) { - super(bluePrintRepoService); - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java index fd73db3b6..eacc90251 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java @@ -25,6 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;
@@ -104,7 +105,7 @@ public class ResourceDictionaryService { * @param resourceDictionary resourceDictionary
* @return DataDictionary
*/
- public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException {
Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");
@@ -157,7 +158,6 @@ public class ResourceDictionaryService { /**
* This is a getResourceSourceMapping service
- *
*/
public ResourceSourceMapping getResourceSourceMapping() {
return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
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 57096c7fd..60a83f9bd 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 @@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 932cdfac8..504420426 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -48,7 +48,7 @@ public class ResourceDictionaryRest { @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) {
+ ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {
return resourceDictionaryService.saveResourceDictionary(dataDictionary);
}
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 42adf1a3e..c5e9e86f4 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 @@ -29,7 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;
import java.util.HashMap;
@@ -114,7 +114,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { if (BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT.equals(derivedFrom)) {
List<ResourceAssignment> resourceAssignment = getResourceAssignments(nodeTemplate);
- ResourceAssignmentValidationService resourceAssignmentValidationService = new ResourceAssignmentValidationDefaultService();
+ ResourceAssignmentValidationService resourceAssignmentValidationService = new ResourceAssignmentValidationServiceImpl();
resourceAssignmentValidationService.validate(resourceAssignment);
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt new file mode 100644 index 000000000..9d4797ff9 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt @@ -0,0 +1,66 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.validator + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { + + @Autowired + private lateinit var context: ApplicationContext + + override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> { + return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> { + return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> { + return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> { + return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> { + return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> { + return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> { + return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } + } + + override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> { + return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } + } + + override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> { + return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } + } +} + diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt new file mode 100644 index 000000000..89f4d9e38 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt @@ -0,0 +1,103 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.validator + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.validation.* +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl +import org.springframework.stereotype.Service +import java.util.* + +@Service +class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(basePath: String): Boolean { + + log.info("validating blueprint($basePath)") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) + return validateBluePrints(bluePrintRuntimeService) + } + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") + } + return true + } +} + +// Core Validator Services + +@Service +class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) + +// Resource Dictionary Validation Services + +@Service +class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() + +@Service +class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) + : ResourceDefinitionValidationServiceImpl(bluePrintRepoService)
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java index abc3d56f3..7d9c2e1a2 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java @@ -22,6 +22,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService; +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService; import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext; import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService; import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService; @@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; + import java.nio.file.Paths; @RunWith(SpringRunner.class) @@ -45,6 +47,9 @@ public class BluePrintEnhancerServiceImplTest { @Autowired private BluePrintEnhancerService bluePrintEnhancerService; + @Autowired + private BluePrintValidatorService bluePrintValidatorService; + @Before public void init() { modelTypeLoadService.loadModelType("./../../../../components/model-catalog/definition-type/starter-type"); @@ -52,7 +57,7 @@ public class BluePrintEnhancerServiceImplTest { } @Test - public void testEnhancement() throws Exception { + public void testEnhancementAndValidation() throws Exception { String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"; @@ -61,6 +66,8 @@ public class BluePrintEnhancerServiceImplTest { BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath); Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext); + // Validate the Generated BluePrints + bluePrintValidatorService.validateBluePrints(targetPath); } }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java deleted file mode 100644 index b6e31318f..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.junit.Assert;
-import org.junit.Before;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;
-
-import java.util.List;
-
-/**
- * ResourceAssignmentEnhancerService.
- *
- * @author Brinda Santh
- */
-public class ResourceAssignmentEnhancerServiceTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class);
-
- @Before
- public void setUp() {
- // Setup dummy Source Instance Mapping
- ResourceDictionaryTestUtils.setUpResourceSourceMapping();
- }
-
- //@Test
- public void testEnhanceBluePrint() throws BluePrintException {
-
-
- List<ResourceAssignment> resourceAssignments = JacksonUtils.getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class);
- Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
-
-// ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../../../components/model-catalog");
-// ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = new ResourceAssignmentEnhancerServiceImpl(resourceDefinitionRepoService);
-// ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
-// Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
-// log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true));
-
- }
-}
-
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 deleted file mode 100644 index d5638ec27..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.validator;
-
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.apache.commons.io.FileUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.List;
-
-public class ServiceTemplateValidationTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);
-
- @Before
- public void setUp(){
- // Setup dummy Source Instance Mapping
- ResourceDictionaryTestUtils.setUpResourceSourceMapping();
- }
-
- @Test
- public void testBluePrintDirs() {
- List<String> dirs = ConfigModelUtils.getBlueprintNames("./../../../../components/model-catalog/blueprint-model/starter-blueprint");
- Assert.assertNotNull("Failed to get blueprint directories", dirs);
- //Assert.assertEquals("Failed to get actual directories", 1, dirs.size());
- }
-
- @Test
- public void validateServiceTemplate() throws Exception {
- validateServiceTemplate("load/blueprints/vrr-test/Definitions/vrr-test.json");
- }
-
- //@Test FIXME("Enable once Complete Enhancement Service Implemented")
- public void validateEnhancedServiceTemplate() throws Exception {
- ServiceTemplate serviceTemplate = JacksonUtils
- .readValueFromClassPathFile("enhance/enhanced-template.json", ServiceTemplate.class);
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();
- Boolean valid = serviceTemplateValidator.validateServiceTemplate(serviceTemplate);
- Assert.assertTrue("Failed to validate blueprints", valid);
- }
-
- private void validateServiceTemplate(String fileName) throws Exception {
- String serviceTemplateContent =
- FileUtils.readFileToString(new File(fileName), Charset.defaultCharset());
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();
- serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);
- Assert.assertNotNull("Failed to validate blueprints", serviceTemplateValidator);
- }
-}
|