aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-09-05 23:18:19 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-09-05 23:18:19 -0400
commitb1843e450c2d799caa69f14f1e123dfb3fa35890 (patch)
tree5ea7c1be2517cad759418c44d19434886ea9ad89 /ms/controllerblueprints/modules/service/src
parent7c677c425c1a389a6413a519a2ab12924516cb71 (diff)
Controller Blueprints Microservice
Add configuration property to load model types and Remove duplicate model type test case files Change-Id: I6a34539cae7377bd133727fde77ff8fefaadf023 Issue-ID: CCSDK-484 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java14
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt5
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java27
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java15
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java5
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/application.properties9
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json27
7 files changed, 82 insertions, 20 deletions
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 88680929..c6d80cfb 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
@@ -60,16 +60,19 @@ import java.util.List;
public class DataBaseInitService {
private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class);
- @Value("${blueprints.load.path}")
- private String modelLoadPath;
private ModelTypeService modelTypeService;
private ResourceDictionaryService resourceDictionaryService;
private ConfigModelService configModelService;
+ @Value("${load.dataTypePath}")
private String dataTypePath;
+ @Value("${load.nodeTypePath}")
private String nodeTypePath;
+ @Value("${load.artifactTypePath}")
private String artifactTypePath;
+ @Value("${load.resourceDictionaryPath}")
private String resourceDictionaryPath;
+ @Value("${load.blueprintsPath}")
private String bluePrintsPath;
@Autowired
@@ -94,13 +97,6 @@ public class DataBaseInitService {
@PostConstruct
@SuppressWarnings("unused")
private void initDatabase() {
- log.info("loading Blueprints from DIR : {}", modelLoadPath);
- dataTypePath = modelLoadPath + "/model_type/data_type";
- nodeTypePath = modelLoadPath + "/model_type/node_type";
- artifactTypePath = modelLoadPath + "/model_type/artifact_type";
- resourceDictionaryPath = modelLoadPath + "/resource_dictionary";
- bluePrintsPath = modelLoadPath + "/blueprints";
-
log.info("loading dataTypePath from DIR : {}", dataTypePath);
log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt
index 92172a2e..064b5c38 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.core.scheduler.Schedulers
+
/**
* ResourceDictionaryReactRepository.
*
@@ -30,6 +31,10 @@ import reactor.core.scheduler.Schedulers
@Service
open class ResourceDictionaryReactRepository(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
+ fun save(resourceDictionary: ResourceDictionary): Mono<ResourceDictionary> {
+ return Mono.justOrEmpty(resourceDictionaryRepository.save(resourceDictionary))
+ }
+
fun findByName(name: String): Mono<ResourceDictionary> {
return Mono.justOrEmpty(resourceDictionaryRepository.findByName(name))
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
index db111885..1e740ec3 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
@@ -17,11 +17,14 @@
package org.onap.ccsdk.apps.controllerblueprints.service.repository;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
@@ -30,6 +33,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.Arrays;
import java.util.List;
+
/**
* ResourceDictionaryReactRepositoryTest.
*
@@ -45,6 +49,16 @@ public class ResourceDictionaryReactRepositoryTest {
@Autowired
protected ResourceDictionaryReactRepository resourceDictionaryReactRepository;
+ @Before
+ public void init() {
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("load/resource_dictionary/db-source" +
+ ".json", ResourceDefinition.class);
+
+ ResourceDictionary resourceDictionary = transformResourceDictionary(resourceDefinition);
+ ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.save(resourceDictionary).block();
+ Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary);
+ }
+
@Test
public void test01FindByNameReact() throws Exception {
ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.findByName("db-source").block();
@@ -64,4 +78,17 @@ public class ResourceDictionaryReactRepositoryTest {
resourceDictionaryReactRepository.findByTagsContainingIgnoreCase("db-source").collectList().block();
Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries);
}
+
+ private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) {
+ ResourceDictionary resourceDictionary = new ResourceDictionary();
+ resourceDictionary.setName(resourceDefinition.getName());
+ resourceDictionary.setDataType(resourceDefinition.getProperty().getType());
+ resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription());
+ resourceDictionary.setResourcePath(resourceDefinition.getResourcePath());
+ resourceDictionary.setResourceType(resourceDefinition.getResourceType());
+ resourceDictionary.setTags(resourceDefinition.getTags());
+ resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy());
+ resourceDictionary.setDefinition(resourceDefinition);
+ return resourceDictionary;
+ }
}
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 c28abe2d..c7147490 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
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -54,13 +55,14 @@ public class ModelTypeRestTest {
@After
- public void tearDown() {}
+ public void tearDown() {
+ }
@Test
public void test01SaveModelType() throws Exception {
- log.info( "**************** test01SaveModelType ********************");
+ log.info("**************** test01SaveModelType ********************");
- String content = FileUtils.readFileToString(new File("load/model_type/data_type/datatype-property.json"), Charset.defaultCharset());
+ String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
@@ -72,7 +74,7 @@ public class ModelTypeRestTest {
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setUpdatedBy("xxxxxx@xxx.com");
modelType = modelTypeRest.saveModelType(modelType);
- log.info( "Saved Mode {}", modelType.toString());
+ log.info("Saved Mode {}", modelType.toString());
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
@@ -90,7 +92,7 @@ public class ModelTypeRestTest {
@Test
public void test02SearchModelTypes() throws Exception {
- log.info( "*********************** test02SearchModelTypes ***************************");
+ log.info("*********************** test02SearchModelTypes ***************************");
String tags = "test-datatype";
@@ -102,7 +104,7 @@ public class ModelTypeRestTest {
@Test
public void test03GetModelType() throws Exception {
- log.info( "************************* test03GetModelType *********************************");
+ log.info("************************* test03GetModelType *********************************");
ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName);
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
@@ -125,5 +127,4 @@ public class ModelTypeRestTest {
}
-
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
index 217eb8f0..faa10825 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -127,10 +128,10 @@ public class ServiceTemplateRestTest {
public void test05AutoMap() throws Exception {
log.info("*********** test05AutoMap *******************************************");
- String resourceassignmentContent = FileUtils.readFileToString(
+ String resourceAssignmentContent = FileUtils.readFileToString(
new File("src/test/resources/resourcedictionary/automap.json"), Charset.defaultCharset());
List<ResourceAssignment> batchResourceAssignment =
- JacksonUtils.getListFromJson(resourceassignmentContent, ResourceAssignment.class);
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
AutoMapResponse autoMapResponse = serviceTemplateRest.autoMap(batchResourceAssignment);
Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null",
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index a13e1684..b17663e9 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -1,5 +1,6 @@
#
-# Copyright © 2017-2018 AT&T Intellectual Property.
+# Copyright © 2017-2018 AT&T Intellectual Property.
+# Modifications 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.
@@ -64,4 +65,8 @@ logging.level.org.hibernate.type.descriptor.sql=debug
blueprints.load.initial-data=true
-blueprints.load.path=load \ No newline at end of file
+load.dataTypePath=./../../application/load/model_type/data_type
+load.nodeTypePath=./../../application/load/model_type/node_type
+load.artifactTypePath=./../../application/load/model_type/artifact_type
+load.resourceDictionaryPath=load/resource_dictionary
+load.blueprintsPath=./../../application/load/blueprints \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json
new file mode 100644
index 00000000..5584b10e
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json
@@ -0,0 +1,27 @@
+{
+ "version": "1.0.0",
+ "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string"
+ },
+ "description": {
+ "required": false,
+ "type": "string"
+ },
+ "required": {
+ "required": false,
+ "type": "boolean"
+ },
+ "default": {
+ "required": false,
+ "type": "string"
+ },
+ "entry_schema": {
+ "required": false,
+ "type": "string"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+} \ No newline at end of file