+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * {@inheritDoc}\r
- */\r
-@Deprecated\r
-@RestController\r
-@RequestMapping(value = "/api/v1/dictionary")\r
-public class ResourceDictionaryRest {\r
-\r
-\r
- private ResourceDictionaryHandler resourceDictionaryHandler;\r
-\r
- /**\r
- * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database\r
- *\r
- * @param resourceDictionaryHandler Data Dictionary Handler\r
- */\r
- public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) {\r
- this.resourceDictionaryHandler = resourceDictionaryHandler;\r
- }\r
-\r
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {\r
- return resourceDictionaryHandler.saveResourceDictionary(dataDictionary);\r
- }\r
-\r
- @DeleteMapping(path = "/{name}")\r
- public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {\r
- resourceDictionaryHandler.deleteResourceDictionary(name);\r
- }\r
-\r
- @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
- return resourceDictionaryHandler.getResourceDictionaryByName(name);\r
- }\r
-\r
- @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {\r
- return resourceDictionaryHandler.searchResourceDictionaryByNames(names);\r
- }\r
-\r
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {\r
- return resourceDictionaryHandler.searchResourceDictionaryByTags(tags);\r
-\r
- }\r
-\r
- @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ResourceSourceMapping getResourceSourceMapping() {\r
- return resourceDictionaryHandler.getResourceSourceMapping();\r
- }\r
-\r
-}\r
/*
* Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import reactor.core.publisher.Mono
/**
- * BlueprintModelRest Purpose: Handle controllerBlueprint API request
+ * BlueprintModelController Purpose: Handle controllerBlueprint API request
*
* @author Vinal Patel
* @version 1.0
*/
@RestController
@RequestMapping("/api/v1/blueprint-model")
-open class BlueprintModelRest(private val bluePrintModelHandler: BluePrintModelHandler) {
+open class BlueprintModelController(private val bluePrintModelHandler: BluePrintModelHandler) {
@PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@ResponseBody
--- /dev/null
+/*
+ * Copyright © 2019 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.controller
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = ["/api/v1/dictionary"])
+open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
+
+ @GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary {
+ return resourceDictionaryHandler.getResourceDictionaryByName(name)
+ }
+
+ @PostMapping(path = [""], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary {
+ return resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
+ }
+
+ @DeleteMapping(path = ["/{name}"])
+ fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) {
+ resourceDictionaryHandler.deleteResourceDictionary(name)
+ }
+
+ @PostMapping(path = ["/by-names"], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByNames(@RequestBody names: List<String>): List<ResourceDictionary> {
+ return resourceDictionaryHandler.searchResourceDictionaryByNames(names)
+ }
+
+ @GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> {
+ return resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
+
+ }
+
+ @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun getResourceSourceMapping(): ResourceSourceMapping {
+ return resourceDictionaryHandler.getResourceSourceMapping()
+ }
+
+}
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
-import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.annotation.Commit;
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeServiceTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeServiceTest.class);
@Autowired
private ModelTypeHandler modelTypeHandler;
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.junit.Assert;\r
-import org.junit.FixMethodOrder;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;\r
-import org.springframework.test.annotation.Commit;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-\r
-import java.util.List;\r
-\r
-@RunWith(SpringRunner.class)\r
-@DataJpaTest\r
-@ContextConfiguration(classes = {TestApplication.class})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ModelTypeRestTest {\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);\r
- @Autowired\r
- ModelTypeController modelTypeController;\r
-\r
- String modelName = "test-datatype";\r
-\r
- @Test\r
- @Commit\r
- public void test01SaveModelType() throws Exception {\r
- log.info("**************** test01SaveModelType ********************");\r
-\r
- String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");\r
- ModelType modelType = new ModelType();\r
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
- modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);\r
- modelType.setDescription("Definition for Sample Datatype ");\r
- modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));\r
- modelType.setModelName(modelName);\r
- modelType.setVersion("1.0.0");\r
- modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","\r
- + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
- modelType.setUpdatedBy("xxxxxx@xxx.com");\r
- modelType = modelTypeController.saveModelType(modelType);\r
- log.info("Saved Mode {}", modelType.toString());\r
- Assert.assertNotNull("Failed to get Saved ModelType", modelType);\r
- Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());\r
-\r
- ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());\r
- Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",\r
- dbModelType);\r
-\r
- // Model Update\r
- modelType.setUpdatedBy("bs2796@xxx.com");\r
- modelType = modelTypeController.saveModelType(modelType);\r
- Assert.assertNotNull("Failed to get Saved ModelType", modelType);\r
- Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());\r
-\r
- }\r
-\r
- @Test\r
- public void test02SearchModelTypes() throws Exception {\r
- log.info("*********************** test02SearchModelTypes ***************************");\r
-\r
- String tags = "test-datatype";\r
-\r
- List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);\r
- Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);\r
- Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);\r
-\r
- }\r
-\r
- @Test\r
- public void test03GetModelType() throws Exception {\r
- log.info("************************* test03GetModelType *********************************");\r
- ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);\r
- Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);\r
- Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());\r
-\r
- List<ModelType> dbDatatypeModelTypes =\r
- modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
- Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);\r
- Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);\r
- }\r
-\r
- @Test\r
- @Commit\r
- public void test04DeleteModelType() throws Exception {\r
- log.info(\r
- "************************ test03DeleteModelType ***********************");\r
- ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName);\r
- Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);\r
- Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName());\r
-\r
- modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());\r
- }\r
-\r
-\r
-}\r
/*
* Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.nio.file.Paths
/**
- * BlueprintModelRestTest Purpose: Integration test at API level
+ * BlueprintModelControllerTest Purpose: Integration test at API level
*
* @author Vinal Patel
* @version 1.0
@ComponentScan(basePackages = ["org.onap.ccsdk.apps.controllerblueprints"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@EnableAutoConfiguration
-class BlueprintModelRestTest {
+class BlueprintModelControllerTest {
companion object {
--- /dev/null
+/*
+ * Copyright © 2019 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.controller
+
+import com.att.eelf.configuration.EELFManager
+import org.junit.Assert
+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.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@DataJpaTest
+@ContextConfiguration(classes = [TestApplication::class])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeControllerTest {
+
+ private val log = EELFManager.getInstance().getLogger(ModelTypeControllerTest::class.java)!!
+
+ @Autowired
+ internal var modelTypeController: ModelTypeController? = null
+
+ private var modelName = "test-datatype"
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test01SaveModelType() {
+ log.info("**************** test01SaveModelType ********************")
+
+ val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json")
+ var modelType = ModelType()
+ modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
+ modelType.description = "Definition for Sample Datatype "
+ modelType.definition = JacksonUtils.jsonNode(content)
+ modelType.modelName = modelName
+ modelType.version = "1.0.0"
+ modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ modelType.updatedBy = "xxxxxx@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ log.info("Saved Mode {}", modelType.toString())
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
+
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName)
+ Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType)
+
+ // Model Update
+ modelType.updatedBy = "bs2796@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test02SearchModelTypes() {
+ log.info("*********************** test02SearchModelTypes ***************************")
+
+ val tags = "test-datatype"
+
+ val dbModelTypes = modelTypeController!!.searchModelTypes(tags)
+ Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
+ Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty())
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test03GetModelType() {
+ log.info("************************* test03GetModelType *********************************")
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName $modelName", dbModelType)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName)
+
+ val dbDatatypeModelTypes = modelTypeController!!.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes)
+ Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.isNotEmpty())
+ }
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test04DeleteModelType() {
+ log.info(
+ "************************ test03DeleteModelType ***********************")
+ val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
+
+ modelTypeController!!.deleteModelTypeByName(dbResourceMapping.modelName)
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2019 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.controller
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [TestApplication::class])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.controllerblueprints"])
+class ResourceDictionaryControllerTest {
+
+ @Autowired
+ lateinit var resourceDictionaryController: ResourceDictionaryController
+
+ @Test
+ fun testResourceDictionaryControllerPresence() {
+ assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController")
+ }
+
+}
\ No newline at end of file