From 341db21b2ac0a14a1ed2b8bf7930914dda054bfe Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 22 Nov 2019 18:06:08 -0500 Subject: 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) Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331 --- .../BluePrintWorkflowExecutionServiceImplTest.kt | 59 ++++++++++++++-------- .../services/workflow/BlueprintServiceLogicTest.kt | 39 +++++++------- .../workflow/DGWorkflowExecutionServiceTest.kt | 24 +++++---- .../ImperativeWorkflowExecutionServiceTest.kt | 48 +++++++++++++----- .../workflow/NodeTemplateExecutionServiceTest.kt | 23 ++++++--- .../workflow/mock/MockComponentFunction.kt | 14 +++-- 6 files changed, 129 insertions(+), 78 deletions(-) (limited to 'ms/blueprintsprocessor/modules/services/workflow-service/src/test') diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt index 436de1b56..330056221 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt @@ -40,7 +40,6 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull - @RunWith(SpringRunner::class) @ContextConfiguration(classes = [WorkflowServiceConfiguration::class]) class BluePrintWorkflowExecutionServiceImplTest { @@ -62,36 +61,48 @@ class BluePrintWorkflowExecutionServiceImplTest { @Test fun testBluePrintWorkflowExecutionService() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", - ExecutionServiceInput::class.java)!! + val executionServiceInput = JacksonUtils.readValueFromClassPathFile( + "execution-input/resource-assignment-input.json", + ExecutionServiceInput::class.java + )!! val executionServiceOutput = bluePrintWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } } @Test fun testImperativeBluePrintWorkflowExecutionService() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/imperative-test-input.json", - ExecutionServiceInput::class.java)!! + val executionServiceInput = JacksonUtils.readValueFromClassPathFile( + "execution-input/imperative-test-input.json", + ExecutionServiceInput::class.java + )!! val executionServiceOutput = bluePrintWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } } @@ -99,16 +110,20 @@ class BluePrintWorkflowExecutionServiceImplTest { fun `Blueprint fails on missing workflowName-parameters with a useful message`() { assertFailsWith(exceptionClass = BluePrintProcessorException::class) { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - //service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input-missing-resource_assignment_request.json", - ExecutionServiceInput::class.java)!! + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) + // service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message + val executionServiceInput = + JacksonUtils.readValueFromClassPathFile( + "execution-input/resource-assignment-input-missing-resource_assignment_request.json", + ExecutionServiceInput::class.java + )!! val executionServiceOutput = bluePrintWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) } } } - } diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt index 12fd9c7c4..3d44894ee 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt @@ -54,47 +54,51 @@ class BlueprintServiceLogicTest { @Test fun testExecuteGraphWithSingleComponent() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) val executionServiceInput = JacksonReactorUtils - .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!! // Assign Workflow inputs Mock val input = executionServiceInput.payload.get("resource-assignment-request") bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input) val executionServiceOutput = dgWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf()) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } - - } @Test fun testExecuteGraphWithMultipleComponents() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) val executionServiceInput = JacksonReactorUtils - .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!! // Assign Workflow inputs Mock val input = executionServiceInput.payload.get("assign-activate-request") bluePrintRuntimeService.assignWorkflowInputs("assign-activate", input) - val executionServiceOutput = dgWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf()) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } - } @Test @@ -118,5 +122,4 @@ class BlueprintServiceLogicTest { assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name") assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name") } - -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt index 3ac5cd864..86d3be26b 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt @@ -44,7 +44,6 @@ class DGWorkflowExecutionServiceTest { @Autowired lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService - @Before fun init() { BluePrintDependencyService.inject(applicationContext) @@ -54,25 +53,28 @@ class DGWorkflowExecutionServiceTest { fun testExecuteDirectedGraph() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) val executionServiceInput = JacksonReactorUtils - .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!! // Assign Workflow inputs Mock val input = executionServiceInput.payload.get("resource-assignment-request") bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input) - val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, - executionServiceInput, mutableMapOf()) + val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow( + bluePrintRuntimeService, + executionServiceInput, mutableMapOf() + ) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } - } - - } diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt index b7fcae1d1..415f11d58 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt @@ -56,18 +56,36 @@ class ImperativeWorkflowExecutionServiceTest { } fun mockServiceTemplate(): ServiceTemplate { - return serviceTemplate("imperative-test", "1.0.0", - "brindasanth@onap.com", "tosca") { + return serviceTemplate( + "imperative-test", "1.0.0", + "brindasanth@onap.com", "tosca" + ) { topologyTemplate { - nodeTemplate(mockNodeTemplateComponentScriptExecutor("resolve-config", - "cba.wt.imperative.test.ResolveConfig")) - nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config", - "cba.wt.imperative.test.ActivateConfig")) - nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config-rollback", - "cba.wt.imperative.test.ActivateConfigRollback")) - nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-licence", - "cba.wt.imperative.test.ActivateLicence")) + nodeTemplate( + mockNodeTemplateComponentScriptExecutor( + "resolve-config", + "cba.wt.imperative.test.ResolveConfig" + ) + ) + nodeTemplate( + mockNodeTemplateComponentScriptExecutor( + "activate-config", + "cba.wt.imperative.test.ActivateConfig" + ) + ) + nodeTemplate( + mockNodeTemplateComponentScriptExecutor( + "activate-config-rollback", + "cba.wt.imperative.test.ActivateConfigRollback" + ) + ) + nodeTemplate( + mockNodeTemplateComponentScriptExecutor( + "activate-licence", + "cba.wt.imperative.test.ActivateLicence" + ) + ) workflow("imperative-test-wf", "Test Imperative flow") { step("resolve-config", "resolve-config", "") { @@ -95,17 +113,19 @@ class ImperativeWorkflowExecutionServiceTest { val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("12345", bluePrintContext) val executionServiceInput = JacksonUtils - .readValueFromClassPathFile("execution-input/imperative-test-input.json", - ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile( + "execution-input/imperative-test-input.json", + ExecutionServiceInput::class.java + )!! val bluePrintWorkFlowService = ImperativeBluePrintWorkflowService(NodeTemplateExecutionService()) val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(bluePrintWorkFlowService) val output = imperativeWorkflowExecutionService - .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) assertNotNull(output, "failed to get imperative workflow output") assertNotNull(output.status, "failed to get imperative workflow output status") assertEquals(output.status.message, BluePrintConstants.STATUS_SUCCESS) assertEquals(output.status.eventType, EventType.EVENT_COMPONENT_EXECUTED.name) } } -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt index 24d96629e..1f51a6aae 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt @@ -38,6 +38,7 @@ import kotlin.test.assertNotNull @ContextConfiguration(classes = [WorkflowServiceConfiguration::class]) class NodeTemplateExecutionServiceTest { + @Before fun init() { mockkObject(BluePrintDependencyService) @@ -52,11 +53,15 @@ class NodeTemplateExecutionServiceTest { @Test fun testExecuteNodeTemplate() { runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", - ExecutionServiceInput::class.java)!! + val executionServiceInput = JacksonUtils.readValueFromClassPathFile( + "execution-input/resource-assignment-input.json", + ExecutionServiceInput::class.java + )!! // Assign Workflow inputs Mock val input = executionServiceInput.payload.get("resource-assignment-request") @@ -65,11 +70,13 @@ class NodeTemplateExecutionServiceTest { val nodeTemplate = "resource-assignment" val nodeTemplateExecutionService = NodeTemplateExecutionService() val executionServiceOutput = nodeTemplateExecutionService - .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput) + .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput) assertNotNull(executionServiceOutput, "failed to get response") - assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) } } -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt index 44751b5b5..9c3727288 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt @@ -29,8 +29,10 @@ import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Scope import org.springframework.stereotype.Component -fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor(id, - "mock($id) component function") { +fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor( + id, + "mock($id) component function" +) { definedOperation("") { inputs { type("kotlin") @@ -55,8 +57,10 @@ class MockComponentFunction : AbstractComponentFunction() { override suspend fun processNB(executionRequest: ExecutionServiceInput) { log.info("Processing component : $operationInputs") - bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName, - "assignment-params", "params".asJsonPrimitive()) + bluePrintRuntimeService.setNodeTemplateAttributeValue( + nodeTemplateName, + "assignment-params", "params".asJsonPrimitive() + ) } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { @@ -92,4 +96,4 @@ class PrototypeComponentFunction : AbstractComponentFunction() { override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { log.info("Recovering component..") } -} \ No newline at end of file +} -- cgit 1.2.3-korg