aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/test/java
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/test/java
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/test/java')
-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
3 files changed, 38 insertions, 9 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",