diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-11-22 18:06:08 -0500 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2019-11-26 21:32:38 +0000 |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/controllerblueprints/modules/resource-dict | |
parent | d274e5fc552cf9ae25500f504f0434981cf3accf (diff) |
Formatting Code base with ktlint
No Business logic change, just the code format.
Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3
To format run: mvn process-sources -P format
Issue-ID: CCSDK-1947
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict')
10 files changed, 53 insertions, 43 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt index f1e0d2c86..10930ffab 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import java.io.Serializable -import java.util.* +import java.util.Date open class ResourceDefinition { @@ -103,7 +103,6 @@ open class ResourceAssignment { */ interface ResourceSource : Serializable - open class ResourceSourceMapping { lateinit var resourceSourceMappings: MutableMap<String, String> } diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index 25b161e47..366a4dcd4 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -22,6 +22,7 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict * @author Brinda Santh */ object ResourceDictionaryConstants { + const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" const val PROCESSOR_DB = "processor-db" diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt index 6f2b9bae7..f8dea9871 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt @@ -35,7 +35,7 @@ object ResourceSourceMappingFactory { fun getRegisterSourceMapping(sourceInstance: String): String { return resourceSourceMappings[sourceInstance] - ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance)) + ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance)) } fun getRegisterSourceMapping(): ResourceSourceMapping { @@ -44,4 +44,3 @@ object ResourceSourceMappingFactory { return resourceSourceMapping } } - diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 08b9d0560..a5171d25c 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -17,13 +17,13 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service -import org.slf4j.LoggerFactory import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory import java.io.Serializable /** @@ -43,7 +43,8 @@ interface ResourceAssignmentValidationService : Serializable { * @author Brinda Santh */ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService { - private val log= LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java) + + private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java) open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf() open val validationMessage = StrBuilder() @@ -61,15 +62,14 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio return true } - open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) { resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() // Check the Resource Assignment has Duplicate Key Names val duplicateKeyNames = resourceAssignments.groupBy { it.name } - .filter { it.value.size > 1 } - .map { it.key } + .filter { it.value.size > 1 } + .map { it.key } if (duplicateKeyNames.isNotEmpty()) { validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) @@ -120,21 +120,23 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio if (v.name == "*") { s.append("\n * -> [") for (resourceAssignment in vs) { - s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name - + "),") + s.append( + "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + ")," + ) } s.append("]") } else { s.append("\n (" + v.dictionaryName + ":" + v.name + ") -> [") for (resourceAssignment in vs) { - s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name - + "),") + s.append( + "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + ")," + ) } s.append("]") } } return s.toString() } - - -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt index cd887bf54..9a5523113 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -21,7 +21,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asListOfString import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.slf4j.LoggerFactory -import java.util.* +import java.util.ArrayList /** * BulkResourceSequencingUtils. @@ -29,6 +29,7 @@ import java.util.* * @author Brinda Santh */ object BulkResourceSequencingUtils { + private val log = LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java) @JvmStatic @@ -83,12 +84,15 @@ object BulkResourceSequencingUtils { dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies) } - log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name, - batchAssignmentName, resourceAssignment.dependencies, dependencyPresence) + log.trace( + "({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name, + batchAssignmentName, resourceAssignment.dependencies, dependencyPresence + ) - if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null - && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) - && !dependencyPresence) { + if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null && + resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) && + !dependencyPresence + ) { batchResourceAssignment!!.add(resourceAssignment) batchAssignmentName!!.add(resourceAssignment.name) } else { @@ -112,5 +116,4 @@ object BulkResourceSequencingUtils { return sequenceBatchResourceAssignment } - -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index cd5470953..f26c5098f 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils -import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils @@ -29,15 +28,17 @@ 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 org.slf4j.LoggerFactory import java.io.File - object ResourceDictionaryUtils { - private val log= LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) + private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) @JvmStatic - fun populateSourceMapping(resourceAssignment: ResourceAssignment, - resourceDefinition: ResourceDefinition) { + fun populateSourceMapping( + resourceAssignment: ResourceAssignment, + resourceDefinition: ResourceDefinition + ) { if (StringUtils.isBlank(resourceAssignment.dictionarySource)) { @@ -81,19 +82,18 @@ object ResourceDictionaryUtils { fun getResourceAssignmentFromFile(filePath: String): List<ResourceAssignment> { return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) - ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") } fun writeResourceDefinitionTypes(basePath: String, resourceDefinitions: List<ResourceDefinition>) { val resourceDefinitionMap = resourceDefinitions.map { it.name to it }.toMap() writeResourceDefinitionTypes(basePath, resourceDefinitionMap) - } fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map<String, ResourceDefinition>) { val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) - .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") + .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true) BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent) } -}
\ No newline at end of file +} 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 index fd38db0bf..111476b5e 100644 --- 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 @@ -28,7 +28,7 @@ public class ResourceDefinitionTest { private String basePath = "./../../../../components/model-catalog/resource-dictionary/starter-dictionary"; @Test - public void testDictionaryDefinitionInputSource(){ + public void testDictionaryDefinitionInputSource() { String fileName = basePath + "/input-source.json"; ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); @@ -36,7 +36,7 @@ public class ResourceDefinitionTest { } @Test - public void testDictionaryDefinitionDefaultSource(){ + public void testDictionaryDefinitionDefaultSource() { String fileName = basePath + "/default-source.json"; ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); @@ -44,7 +44,7 @@ public class ResourceDefinitionTest { } @Test - public void testDictionaryDefinitionDBSource(){ + public void testDictionaryDefinitionDBSource() { String fileName = basePath + "/db-source.json"; ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); @@ -52,9 +52,10 @@ public class ResourceDefinitionTest { } @Test - public void testDictionaryDefinitionMDSALSource(){ + 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/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index b891f9ec6..77af5dbe0 100644 --- 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 @@ -17,11 +17,11 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service import org.junit.Assert +import org.junit.Before 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 org.junit.Before import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils import org.slf4j.LoggerFactory @@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory * @author Brinda Santh */ class ResourceAssignmentValidationServiceTest { + private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java) @Before fun setUp() { @@ -62,4 +63,4 @@ class ResourceAssignmentValidationServiceTest { 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 index 3413868ee..30b4d4544 100644 --- 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 @@ -20,7 +20,9 @@ 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. * @@ -29,9 +31,10 @@ import java.util.List; public class BulkResourceSequencingUtilsTest { @Test - public void testProcess(){ + public void testProcess() { List<ResourceAssignment> 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 index 16b02d86c..8004d2ca2 100644 --- 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 @@ -56,7 +56,9 @@ public class ResourceDictionaryUtilsTest { 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()); + Assert.assertEquals("Expected First source Default, but.", + ResourceDictionaryConstants.SOURCE_DEFAULT, + resourceAssignment.getDictionarySource()); // To Check Assigned Source resourceAssignment.setDictionarySource(ResourceDictionaryConstants.PROCESSOR_DB); @@ -91,9 +93,8 @@ public class ResourceDictionaryUtilsTest { 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)); + Assert.assertTrue(String.format("failed to get variable : %s", path), context.containsKey(path)); } - } |