diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api')
14 files changed, 201 insertions, 139 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt index b25acd148..305437923 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt @@ -31,16 +31,20 @@ import java.util.concurrent.Phaser import javax.annotation.PreDestroy @Service -open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration, - private val executionServiceHandler: ExecutionServiceHandler) - : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { +open class BluePrintProcessingGRPCHandler( + private val bluePrintCoreConfiguration: BluePrintCoreConfiguration, + private val executionServiceHandler: ExecutionServiceHandler +) : + BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { + private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java) private val ph = Phaser(1) @PreAuthorize("hasRole('USER')") override fun process( - responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> { + responseObserver: StreamObserver<ExecutionServiceOutput> + ): StreamObserver<ExecutionServiceInput> { return object : StreamObserver<ExecutionServiceInput> { override fun onNext(executionServiceInput: ExecutionServiceInput) { @@ -51,17 +55,18 @@ open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration } } catch (e: Exception) { onError(e) - } - finally { + } finally { ph.arriveAndDeregister() } } override fun onError(error: Throwable) { log.debug("Fail to process message", error) - responseObserver.onError(io.grpc.Status.INTERNAL + responseObserver.onError( + io.grpc.Status.INTERNAL .withDescription(error.message) - .asException()) + .asException() + ) } override fun onCompleted() { @@ -77,4 +82,4 @@ open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration ph.arriveAndAwaitAdvance() log.info("Done waiting in $name") } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt index a9dda7e0c..6293f48f4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt @@ -32,12 +32,15 @@ import org.springframework.stereotype.Service import java.util.concurrent.Phaser import javax.annotation.PreDestroy -@ConditionalOnProperty(name = ["blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable"], - havingValue = "true") +@ConditionalOnProperty( + name = ["blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable"], + havingValue = "true" +) @Service open class BluePrintProcessingKafkaConsumer( - private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService, - private val executionServiceHandler: ExecutionServiceHandler) { + private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService, + private val executionServiceHandler: ExecutionServiceHandler +) { val log = logger(BluePrintProcessingKafkaConsumer::class) @@ -53,13 +56,15 @@ open class BluePrintProcessingKafkaConsumer( @EventListener(ApplicationReadyEvent::class) fun setupMessageListener() = runBlocking { try { - log.info("Setting up message consumer($CONSUMER_SELECTOR) and " + - "message producer($PRODUCER_SELECTOR)...") + log.info( + "Setting up message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR)..." + ) /** Get the Message Consumer Service **/ blueprintMessageConsumerService = try { bluePrintMessageLibPropertyService - .blueprintMessageConsumerService(CONSUMER_SELECTOR) + .blueprintMessageConsumerService(CONSUMER_SELECTOR) } catch (e: Exception) { throw BluePrintProcessorException("failed to create consumer service ${e.message}") } @@ -67,7 +72,7 @@ open class BluePrintProcessingKafkaConsumer( /** Get the Message Producer Service **/ val blueprintMessageProducerService = try { bluePrintMessageLibPropertyService - .blueprintMessageProducerService(PRODUCER_SELECTOR) + .blueprintMessageProducerService(PRODUCER_SELECTOR) } catch (e: Exception) { throw BluePrintProcessorException("failed to create producer service ${e.message}") } @@ -83,34 +88,36 @@ open class BluePrintProcessingKafkaConsumer( log.trace("Consumed Message : $message") val executionServiceInput = message.jsonAsType<ExecutionServiceInput>() val executionServiceOutput = executionServiceHandler.doProcess(executionServiceInput) - //TODO("In future, Message publisher configuration vary with respect to request") + // TODO("In future, Message publisher configuration vary with respect to request") /** Send the response message */ blueprintMessageProducerService.sendMessage(executionServiceOutput) } catch (e: Exception) { log.error("failed in processing the consumed message : $message", e) - } - finally { + } finally { ph.arriveAndDeregister() } } } } } catch (e: Exception) { - log.error("failed to start message consumer($CONSUMER_SELECTOR) and " + - "message producer($PRODUCER_SELECTOR) ", e) + log.error( + "failed to start message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR) ", e + ) } } @PreDestroy fun shutdownMessageListener() = runBlocking { try { - log.info("Shutting down message consumer($CONSUMER_SELECTOR) and " + - "message producer($PRODUCER_SELECTOR)...") + log.info( + "Shutting down message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR)..." + ) blueprintMessageConsumerService.shutDown() ph.arriveAndAwaitAdvance() } catch (e: Exception) { log.error("failed to shutdown message listener($CONSUMER_SELECTOR)", e) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index 130e23ecc..02d3f2026 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -32,16 +32,23 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.security.access.prepost.PreAuthorize -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.ResponseBody +import org.springframework.web.bind.annotation.RestController import reactor.core.publisher.Mono import java.util.concurrent.Phaser import javax.annotation.PreDestroy @RestController @RequestMapping("/api/v1/execution-service") -@Api(value = "/api/v1/execution-service", - description = "Interaction with CBA.") +@Api( + value = "/api/v1/execution-service", + description = "Interaction with CBA." +) open class ExecutionServiceController { + val log = logger(ExecutionServiceController::class) private val ph = Phaser(1) @@ -49,9 +56,11 @@ open class ExecutionServiceController { @Autowired lateinit var executionServiceHandler: ExecutionServiceHandler - @RequestMapping(path = ["/health-check"], - method = [RequestMethod.GET], - produces = [MediaType.APPLICATION_JSON_VALUE]) + @RequestMapping( + path = ["/health-check"], + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE] + ) @ResponseBody @ApiOperation(value = "Health Check", hidden = true) fun executionServiceControllerHealthCheck() = monoMdc(Dispatchers.IO) { @@ -59,15 +68,19 @@ open class ExecutionServiceController { } @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE]) - @ApiOperation(value = "Execute a CBA workflow (action)", - notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", - produces = MediaType.APPLICATION_JSON_VALUE, - response = ExecutionServiceOutput::class) + @ApiOperation( + value = "Execute a CBA workflow (action)", + notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", + produces = MediaType.APPLICATION_JSON_VALUE, + response = ExecutionServiceOutput::class + ) @ResponseBody @PreAuthorize("hasRole('USER')") - fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true) - @RequestBody executionServiceInput: ExecutionServiceInput) - : Mono<ResponseEntity<ExecutionServiceOutput>> = monoMdc(Dispatchers.IO) { + fun process( + @ApiParam(value = "ExecutionServiceInput payload.", required = true) + @RequestBody executionServiceInput: ExecutionServiceInput + ): + Mono<ResponseEntity<ExecutionServiceOutput>> = monoMdc(Dispatchers.IO) { if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.") @@ -87,4 +100,3 @@ open class ExecutionServiceController { log.info("Done waiting in $name") } } - diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index 356f0f7ee..9524e375e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt @@ -21,7 +21,11 @@ import io.grpc.stub.StreamObserver import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.* +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toProto import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType @@ -36,15 +40,19 @@ import org.springframework.stereotype.Service import java.util.stream.Collectors @Service -class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, - private val blueprintsProcessorCatalogService: BluePrintCatalogService, - private val bluePrintWorkflowExecutionService - : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>) { +class ExecutionServiceHandler( + private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val blueprintsProcessorCatalogService: BluePrintCatalogService, + private val bluePrintWorkflowExecutionService: + BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> +) { private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString()) - suspend fun process(executionServiceInput: ExecutionServiceInput, - responseObserver: StreamObserver<org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput>) { + suspend fun process( + executionServiceInput: ExecutionServiceInput, + responseObserver: StreamObserver<org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput> + ) { when { executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> { GlobalScope.launch(Dispatchers.Default) { @@ -59,9 +67,13 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL responseObserver.onNext(executionServiceOutput.toProto()) responseObserver.onCompleted() } - else -> responseObserver.onNext(response(executionServiceInput, + else -> responseObserver.onNext( + response( + executionServiceInput, "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", - true).toProto()); + true + ).toProto() + ) } } @@ -81,8 +93,10 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString()) - val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService, - executionServiceInput, hashMapOf()) + val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow( + blueprintRuntimeService, + executionServiceInput, hashMapOf() + ) val errors = blueprintRuntimeService.getBluePrintError().errors if (errors.isNotEmpty()) { @@ -118,8 +132,11 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL status.message = BluePrintConstants.STATUS_FAILURE } - private fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "", - failure: Boolean = false): ExecutionServiceOutput { + private fun response( + executionServiceInput: ExecutionServiceInput, + errorMessage: String = "", + failure: Boolean = false + ): ExecutionServiceOutput { val executionServiceOutput = ExecutionServiceOutput() executionServiceOutput.commonHeader = executionServiceInput.commonHeader executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers @@ -138,5 +155,4 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL return executionServiceOutput } - } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt index 16fe36cfe..66cdbef3e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt @@ -22,7 +22,7 @@ import org.springframework.util.StringUtils import java.io.File import java.io.IOException import java.nio.file.Path -import java.util.* +import java.util.UUID const val INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE = 500 @@ -55,8 +55,8 @@ fun determineHttpStatusCode(statusCode: Int): HttpStatus { try { return HttpStatus.valueOf(statusCode) } catch (exception: Exception) { - //if statusCode cannot be converted to a proper HttpStatus, the resource still needs to assign a HTTP status + // if statusCode cannot be converted to a proper HttpStatus, the resource still needs to assign a HTTP status // code to the response. In this case, a 500 Internal Server Error will be returned as default. return HttpStatus.valueOf(INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt index ab0d4256c..ff615536b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt @@ -22,6 +22,8 @@ import org.onap.ccsdk.cds.controllerblueprints.validation.extension.ResourceDefi import org.springframework.stereotype.Service @Service("bluePrintRuntimeValidatorService") -open class BluePrintRuntimeValidatorService(bluePrintTypeValidatorService: BluePrintTypeValidatorService, - resourceDefinitionValidator: ResourceDefinitionValidator) - : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService, resourceDefinitionValidator) +open class BluePrintRuntimeValidatorService( + bluePrintTypeValidatorService: BluePrintTypeValidatorService, + resourceDefinitionValidator: ResourceDefinitionValidator +) : + BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService, resourceDefinitionValidator) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt index 8bedc9628..e990c90d8 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt @@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api - import com.google.protobuf.util.JsonFormat import io.grpc.stub.StreamObserver import io.grpc.testing.GrpcServerRule @@ -44,10 +43,13 @@ import kotlin.test.BeforeTest @RunWith(SpringRunner::class) @DirtiesContext @EnableAutoConfiguration -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", - "org.onap.ccsdk.cds.controllerblueprints"]) +@ComponentScan( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintProcessingGRPCHandlerTest { + private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java) @get:Rule @@ -68,7 +70,10 @@ class BluePrintProcessingGRPCHandlerTest { override fun onNext(executionServiceOuput: ExecutionServiceOutput) { log.debug("onNext {}", executionServiceOuput) if ("1234".equals(executionServiceOuput.commonHeader.requestId)) { - Assert.assertEquals("Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.", executionServiceOuput.status.errorMessage) + Assert.assertEquals( + "Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.", + executionServiceOuput.status.errorMessage + ) } } @@ -86,39 +91,38 @@ class BluePrintProcessingGRPCHandlerTest { @Test fun testSelfServiceGRPCHandler() { val commonHeader = CommonHeader.newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId("1234") - .setSubRequestId("1234-56").build() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId("1234") + .setSubRequestId("1234-56").build() val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json") val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder JsonFormat.parser().merge(jsonContent, payloadBuilder) val input = ExecutionServiceInput.newBuilder() - .setCommonHeader(commonHeader) - .setPayload(payloadBuilder.build()) - .build() + .setCommonHeader(commonHeader) + .setPayload(payloadBuilder.build()) + .build() requestObs.onNext(input) val commonHeader2 = CommonHeader.newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId("2345") - .setSubRequestId("1234-56").build() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId("2345") + .setSubRequestId("1234-56").build() val actionIdentifier = ActionIdentifiers.newBuilder().setMode("sync").build() val input2 = ExecutionServiceInput.newBuilder() - .setCommonHeader(commonHeader2) - .setActionIdentifiers(actionIdentifier) - .setPayload(payloadBuilder.build()) - .build() + .setCommonHeader(commonHeader2) + .setActionIdentifiers(actionIdentifier) + .setPayload(payloadBuilder.build()) + .build() requestObs.onNext(input2) requestObs.onCompleted() } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt index 8971ebde2..b26781ad2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt @@ -36,7 +36,7 @@ class BluePrintProcessingIntegrationTest { private val log = logger(BluePrintProcessingIntegrationTest::class) /** This is Integration test sample, Do not enable this test case in server build, this is for local desktop testing*/ - //@Test + // @Test fun integrationTestGrpcManagement() { runBlocking { val tokenAuthGrpcClientProperties = TokenAuthGrpcClientProperties().apply { @@ -65,26 +65,26 @@ class BluePrintProcessingIntegrationTest { }) val commonHeader = CommonHeader.newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId("1234-$it") - .setSubRequestId("1234-56").build() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId("1234-$it") + .setSubRequestId("1234-56").build() val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json") val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder JsonFormat.parser().merge(jsonContent, payloadBuilder) val actionIdentifier = ActionIdentifiers.newBuilder() - .setActionName("SampleScript") - .setBlueprintName("sample-cba") - .setBlueprintVersion("1.0.0") - .build() + .setActionName("SampleScript") + .setBlueprintName("sample-cba") + .setBlueprintVersion("1.0.0") + .build() val input = ExecutionServiceInput.newBuilder() - .setCommonHeader(commonHeader) - .setActionIdentifiers(actionIdentifier) - .setPayload(payloadBuilder.build()) - .build() + .setCommonHeader(commonHeader) + .setActionIdentifiers(actionIdentifier) + .setPayload(payloadBuilder.build()) + .build() requestObs.onNext(input) requestObs.onCompleted() @@ -93,4 +93,4 @@ class BluePrintProcessingIntegrationTest { channel.shutdownNow() } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt index 01199c131..f71d1b444 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt @@ -34,8 +34,10 @@ import kotlin.test.Test import kotlin.test.assertNotNull @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]) +@ContextConfiguration( + classes = [BluePrintMessageLibConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintProcessingKafkaConsumerTest { @@ -45,15 +47,19 @@ class BluePrintProcessingKafkaConsumerTest { @Test fun testExecutionInputMessageConsumer() { runBlocking { - assertNotNull(bluePrintMessageLibPropertyService, - "failed to initialise bluePrintMessageLibPropertyService") + assertNotNull( + bluePrintMessageLibPropertyService, + "failed to initialise bluePrintMessageLibPropertyService" + ) val executionServiceHandle = mockk<ExecutionServiceHandler>() coEvery { executionServiceHandle.doProcess(any()) } returns mockk() - val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(bluePrintMessageLibPropertyService, - executionServiceHandle) + val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer( + bluePrintMessageLibPropertyService, + executionServiceHandle + ) launch { bluePrintProcessingKafkaConsumer.setupMessageListener() @@ -62,5 +68,4 @@ class BluePrintProcessingKafkaConsumerTest { bluePrintProcessingKafkaConsumer.shutdownMessageListener() } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt index e1a498a6f..a6ebe9c3e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt @@ -36,17 +36,21 @@ import org.springframework.test.context.junit4.SpringRunner import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.web.reactive.function.BodyInserters import java.io.File -import java.util.* +import java.util.UUID import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.assertTrue @RunWith(SpringRunner::class) @WebFluxTest -@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, - BluePrintCatalogService::class, SecurityProperties::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", - "org.onap.ccsdk.cds.controllerblueprints"]) +@ContextConfiguration( + classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, SecurityProperties::class] +) +@ComponentScan( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class ExecutionServiceControllerTest { @@ -71,15 +75,17 @@ class ExecutionServiceControllerTest { blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) val executionServiceInput = JacksonUtils - .readValueFromClassPathFile("execution-input/default-input.json", - ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile( + "execution-input/default-input.json", + ExecutionServiceInput::class.java + )!! webTestClient - .post() - .uri("/api/v1/execution-service/process") - .body(BodyInserters.fromObject(executionServiceInput)) - .exchange() - .expectStatus().isOk + .post() + .uri("/api/v1/execution-service/process") + .body(BodyInserters.fromObject(executionServiceInput)) + .exchange() + .expectStatus().isOk } } @@ -89,15 +95,17 @@ class ExecutionServiceControllerTest { blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) val executionServiceInput = JacksonUtils - .readValueFromClassPathFile("execution-input/faulty-input.json", - ExecutionServiceInput::class.java)!! + .readValueFromClassPathFile( + "execution-input/faulty-input.json", + ExecutionServiceInput::class.java + )!! webTestClient - .post() - .uri("/api/v1/execution-service/process") - .body(BodyInserters.fromObject(executionServiceInput)) - .exchange() - .expectStatus().is5xxServerError + .post() + .uri("/api/v1/execution-service/process") + .body(BodyInserters.fromObject(executionServiceInput)) + .exchange() + .expectStatus().is5xxServerError } } @@ -106,4 +114,4 @@ class ExecutionServiceControllerTest { assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}") return testCbaFile } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt index 293da0da6..5a44403e1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt @@ -73,12 +73,12 @@ class ExecutionServiceHandlerTest { @Service("mock-service-action") class MockServiceAction : AbstractServiceFunction() { + override suspend fun processNB(executionRequest: ExecutionServiceInput) { val responsePayload = """{"answer" : "correct"}""".jsonAsJsonType() setResponsePayloadForAction(responsePayload) } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt index 27130a7bc..9f5cc6097 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt @@ -41,8 +41,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) { @@ -51,13 +53,14 @@ class MockComponentFunction : AbstractComponentFunction() { } open class MockResourceSource { - @Bean(name = [ - "rr-processor-source-input", - "rr-processor-source-default", - "rr-processor-source-db", - "rr-processor-source-rest"]) + @Bean( + name = [ + "rr-processor-source-input", + "rr-processor-source-default", + "rr-processor-source-db", + "rr-processor-source-rest"] + ) open fun sourceInstance(): ResourceAssignmentProcessor { return mockk<ResourceAssignmentProcessor>() } - } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/UtilsTest.kt index 07d8ca4e1..db2791101 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/UtilsTest.kt @@ -23,5 +23,4 @@ class UtilsTest { val nonExistentHttpStatusCode = determineHttpStatusCode(999999) assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, nonExistentHttpStatusCode) } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt index 08da9dc28..820c4be42 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt @@ -26,8 +26,10 @@ import org.springframework.test.context.junit4.SpringRunner import kotlin.test.assertNotNull @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BluePrintRuntimeValidatorService::class, - BluePrintValidationConfiguration::class, MockResourceSource::class]) +@ContextConfiguration( + classes = [BluePrintRuntimeValidatorService::class, + BluePrintValidationConfiguration::class, MockResourceSource::class] +) class BluePrintRuntimeValidatorServiceTest { @Autowired @@ -39,6 +41,5 @@ class BluePrintRuntimeValidatorServiceTest { assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService") bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath) - } -}
\ No newline at end of file +} |