From 2c91cf47dcfc3014dd669627e214b2e8ec34ce4a Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 5 Sep 2018 23:18:19 -0400 Subject: 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 --- .../ResourceDictionaryReactRepositoryTest.java | 27 ++++++++++++++++++++++ .../service/rs/ModelTypeRestTest.java | 15 ++++++------ .../service/rs/ServiceTemplateRestTest.java | 5 ++-- .../src/test/resources/application.properties | 9 ++++++-- .../model_type/data_type/datatype-property.json | 27 ++++++++++++++++++++++ 5 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json (limited to 'ms/controllerblueprints/modules/service/src/test') 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 db111885a..1e740ec33 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 c28abe2d3..c7147490d 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 217eb8f06..faa10825f 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 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 a13e16841..b17663e9a 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 000000000..5584b10ea --- /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 -- cgit 1.2.3-korg