From c90edac236dffb7c495e266dd04991de7e8f04b7 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 25 Mar 2019 13:04:18 -0400 Subject: Migrate ccsdk/apps to ccsdk/cds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: CCSDK-1177 Issue-ID: CCSDK-1178 Change-Id: I0c02702fbec52211ca367abbba72aebecee8cbaa Signed-off-by: Alexis de Talhouët --- .../resource/dict/ResourceDefinitionTest.java | 60 ------------- .../factory/ResourceSourceMappingFactoryTest.java | 42 --------- .../ResourceAssignmentValidationServiceTest.kt | 66 --------------- .../utils/BulkResourceSequencingUtilsTest.java | 37 -------- .../dict/utils/ResourceDictionaryUtilsTest.java | 99 ---------------------- .../resource/dict/ResourceDefinitionTest.java | 60 +++++++++++++ .../factory/ResourceSourceMappingFactoryTest.java | 42 +++++++++ .../ResourceAssignmentValidationServiceTest.kt | 66 +++++++++++++++ .../utils/BulkResourceSequencingUtilsTest.java | 37 ++++++++ .../dict/utils/ResourceDictionaryUtilsTest.java | 99 ++++++++++++++++++++++ 10 files changed, 304 insertions(+), 304 deletions(-) delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java (limited to 'ms/controllerblueprints/modules/resource-dict/src/test/java') diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java deleted file mode 100644 index d059d1ba5..000000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - * 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.resource.dict; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceDefinitionTest { - private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); - private String basePath = "load/resource_dictionary"; - - @Test - public void testDictionaryDefinitionInputSource(){ - - String fileName = basePath + "/input-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDefaultSource(){ - - String fileName = basePath + "/default-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDBSource(){ - - String fileName = basePath + "/primary-db-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionMDSALSource(){ - String fileName = basePath + "/mdsal-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java deleted file mode 100644 index 3950ae367..000000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.resource.dict.factory; - -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; -import org.springframework.util.Assert; - -public class ResourceSourceMappingFactoryTest { - - @Test - public void testRegisterResourceMapping() { - - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-config-data", "source-rest"); - - String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); - Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); - - ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); - Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); - Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); - - } - -} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt deleted file mode 100644 index 8905dab60..000000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.resource.dict.service - -import com.att.eelf.configuration.EELFLogger -import org.junit.Assert -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager -import org.junit.Before -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils - -/** - * ResourceAssignmentValidationServiceTest. - * - * @author Brinda Santh - */ -class ResourceAssignmentValidationServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) - @Before - fun setUp() { - // Setup dummy Source Instance Mapping - ResourceDictionaryTestUtils.setUpResourceSourceMapping() - } - - @Test - fun testValidateSuccess() { - log.info("**************** testValidateSuccess *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - val result = resourceAssignmentValidator.validate(assignments!!) - Assert.assertTrue("Failed to Validate", result) - } - - @Test(expected = BluePrintException::class) - fun testValidateDuplicate() { - log.info(" **************** testValidateDuplicate *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - resourceAssignmentValidator.validate(assignments!!) - } - - @Test(expected = BluePrintException::class) - fun testValidateCyclic() { - log.info(" **************** testValidateCyclic *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - resourceAssignmentValidator.validate(assignments!!) - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java deleted file mode 100644 index c1b9f5007..000000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.resource.dict.utils; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import java.util.List; -/** - * BulkResourceSequencingUtils. - * - * @author Brinda Santh - */ -public class BulkResourceSequencingUtilsTest { - - @Test - public void testProcess(){ - List assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); - Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); - BulkResourceSequencingUtils.process(assignments); - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java deleted file mode 100644 index 45fc739d7..000000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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. - * 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.resource.dict.utils; - - -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.HashMap; -import java.util.Map; -/** - * ResourceDictionaryUtilsTest. - * - * @author Brinda Santh - */ -public class ResourceDictionaryUtilsTest { - private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); - - @Test - public void testPopulateSourceMapping() { - - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("sample-assignment"); - ResourceDefinition resourceDefinition = new ResourceDefinition(); - Map sources = new HashMap<>(); - resourceDefinition.setSources(sources); - // To Check Empty Source - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); - - // To Check First Source - resourceAssignment.setDictionarySource(null); - sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); - - // To Check Assigned Source - resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB); - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, resourceAssignment.getDictionarySource()); - - } - - @Test - public void testFindFirstSource() { - //To check if Empty Source - Map sources = new HashMap<>(); - String firstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertNull("Source populated, which is not expected.", firstSource); - - // TO check the first Source - sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate()); - String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); - - // TO check the multiple Source - sources.put(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, new NodeTemplate()); - String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); - - } - - @Test - public void testAssignInputs() { - JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); - Map context = new HashMap<>(); - ResourceDictionaryUtils.assignInputs(data, context); - String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); - log.info("populated context {}", context); - Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path)); - - } - - -} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java new file mode 100644 index 000000000..db949d45f --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -0,0 +1,60 @@ +/* + * 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. + * 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.cds.controllerblueprints.resource.dict; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class ResourceDefinitionTest { + private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); + private String basePath = "load/resource_dictionary"; + + @Test + public void testDictionaryDefinitionInputSource(){ + + String fileName = basePath + "/input-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDefaultSource(){ + + String fileName = basePath + "/default-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDBSource(){ + + String fileName = basePath + "/primary-db-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionMDSALSource(){ + String fileName = basePath + "/mdsal-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); + } +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java new file mode 100644 index 000000000..6c75f0bd8 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.cds.controllerblueprints.resource.dict.factory; + +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping; +import org.springframework.util.Assert; + +public class ResourceSourceMappingFactoryTest { + + @Test + public void testRegisterResourceMapping() { + + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-config-data", "source-rest"); + + String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); + Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); + + ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); + Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); + Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); + + } + +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt new file mode 100644 index 000000000..f21ff4093 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -0,0 +1,66 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.cds.controllerblueprints.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import org.junit.Assert +import org.junit.Test +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +import org.junit.Before +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils + +/** + * ResourceAssignmentValidationServiceTest. + * + * @author Brinda Santh + */ +class ResourceAssignmentValidationServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) + @Before + fun setUp() { + // Setup dummy Source Instance Mapping + ResourceDictionaryTestUtils.setUpResourceSourceMapping() + } + + @Test + fun testValidateSuccess() { + log.info("**************** testValidateSuccess *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + val result = resourceAssignmentValidator.validate(assignments!!) + Assert.assertTrue("Failed to Validate", result) + } + + @Test(expected = BluePrintException::class) + fun testValidateDuplicate() { + log.info(" **************** testValidateDuplicate *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + resourceAssignmentValidator.validate(assignments!!) + } + + @Test(expected = BluePrintException::class) + fun testValidateCyclic() { + log.info(" **************** testValidateCyclic *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + resourceAssignmentValidator.validate(assignments!!) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java new file mode 100644 index 000000000..3413868ee --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.cds.controllerblueprints.resource.dict.utils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment; +import java.util.List; +/** + * BulkResourceSequencingUtils. + * + * @author Brinda Santh + */ +public class BulkResourceSequencingUtilsTest { + + @Test + public void testProcess(){ + List assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); + Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); + BulkResourceSequencingUtils.process(assignments); + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java new file mode 100644 index 000000000..fccc4f5fa --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -0,0 +1,99 @@ +/* + * 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. + * 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.cds.controllerblueprints.resource.dict.utils; + + +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate; +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.HashMap; +import java.util.Map; +/** + * ResourceDictionaryUtilsTest. + * + * @author Brinda Santh + */ +public class ResourceDictionaryUtilsTest { + private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); + + @Test + public void testPopulateSourceMapping() { + + ResourceAssignment resourceAssignment = new ResourceAssignment(); + resourceAssignment.setName("sample-assignment"); + ResourceDefinition resourceDefinition = new ResourceDefinition(); + Map sources = new HashMap<>(); + resourceDefinition.setSources(sources); + // To Check Empty Source + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); + + // To Check First Source + resourceAssignment.setDictionarySource(null); + sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); + + // To Check Assigned Source + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, resourceAssignment.getDictionarySource()); + + } + + @Test + public void testFindFirstSource() { + //To check if Empty Source + Map sources = new HashMap<>(); + String firstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertNull("Source populated, which is not expected.", firstSource); + + // TO check the first Source + sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate()); + String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); + + // TO check the multiple Source + sources.put(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, new NodeTemplate()); + String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); + + } + + @Test + public void testAssignInputs() { + JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); + Map context = new HashMap<>(); + ResourceDictionaryUtils.assignInputs(data, context); + String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); + log.info("populated context {}", context); + Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path)); + + } + + +} -- cgit 1.2.3-korg