aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/test')
-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
5 files changed, 72 insertions, 11 deletions
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