aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/workflow-api
diff options
context:
space:
mode:
authorKavitha P <pkavitha@aarnanetworks.com>2021-08-25 16:12:18 +0530
committerKAPIL SINGAL <ks220y@att.com>2021-08-27 16:58:22 +0000
commit35481027b3fdf251a3b520ab5b1ae89c7d2d0e34 (patch)
tree8fe9d3fe117005d54b31e1a136ad334e419268e4 /ms/blueprintsprocessor/modules/inbounds/workflow-api
parent6b6f2360e4e60d681a5ba0fc05477f9ac9bea051 (diff)
CCSDK-3434 CBA workflow status store
Change-Id: Iaeac6fa534c569bbc152e6c8a78c2dd23b6c4b1a Signed-off-by: Kavitha P <pkavitha@aarnanetworks.com> Issue-ID: CCSDK-3434
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/workflow-api')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/pom.xml56
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorHandling.kt35
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowController.kt109
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowExceptionHandler.kt29
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorCatalogTestConfiguration.kt28
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/TestDatabaseConfiguration.kt62
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowControllerTest.kt268
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/resources/application-test.properties39
8 files changed, 626 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/workflow-api/pom.xml
new file mode 100644
index 000000000..7e5ebecb8
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
+ <artifactId>modules-inbounds</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
+ <artifactId>workflow-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>MS Blueprints Processor Modules - Inbounds - Workflow API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
+ <artifactId>blueprint-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog-services</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
+ <artifactId>blueprint-audit-status</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
+ <artifactId>db-lib</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorHandling.kt
new file mode 100644
index 000000000..5e4289e7b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorHandling.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+object WorkflowApiDomains {
+
+ // Workflow Api Domains Constants
+ const val WORKFLOW_API = "org.onap.ccsdk.cds.blueprintsprocessor.workflow.api"
+}
+
+object WorkflowApiHttpErrorCodes {
+ init {
+ // Register HttpErrorCodes
+ }
+}
+
+object WorkflowGrpcErrorCodes {
+ init {
+ // Register GrpcErrorCodes
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowController.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowController.kt
new file mode 100644
index 000000000..e131bf378
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowController.kt
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import io.swagger.annotations.ApiParam
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.StoreAuditService
+import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
+import org.slf4j.LoggerFactory
+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.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+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
+
+/**
+ * Rest API which handles retrieving the workflow store records
+ */
+@RestController
+@RequestMapping("/api/v1/workflow")
+@Api(
+ value = "/api/v1/workflow",
+ description = "Interaction with blueprint workflow status resources"
+)
+class WorkflowController {
+ private val log =
+ LoggerFactory.getLogger(WorkflowController::class.toString())
+
+ @Autowired
+ lateinit var databaseStoreAuditService: StoreAuditService
+
+ private val JSON_MIME_TYPE = "application/json"
+
+ /**
+ * workflow healthcheck api
+ */
+ @RequestMapping(
+ path = ["/health-check"],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @ResponseBody
+ @ApiOperation(value = "Health Check", hidden = true)
+ fun workflowControllerHealthCheck(): JsonNode = runBlocking {
+ JacksonUtils.getJsonNode("Success")
+ }
+
+ /**
+ * API to retreive records based on request and subrequest ID *
+ */
+ @GetMapping(
+ "/audit-status/{requestId}/{subRequestId}",
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @ApiOperation(
+ value = "Get all workflow status records using request and Subrequest",
+ notes = "Retrieve all stored workflow audit records based on " +
+ "requestId and SubrequestId",
+ response = BlueprintWorkflowAuditStatus::class,
+ responseContainer = "List",
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
+ @ResponseBody
+ @PreAuthorize("hasRole('USER')")
+ suspend fun getWorkFlowByRequestAndSubRequest(
+ @ApiParam(value = "request ID", required = true)
+ @PathVariable(value = "requestId") requestId: String,
+ @ApiParam(value = "sub request ID", required = true)
+ @PathVariable(value = "subRequestId") subRequestId: String
+ ): ResponseEntity<List<BlueprintWorkflowAuditStatus>> = runBlocking {
+ var requestIdResults: List<BlueprintWorkflowAuditStatus>
+ if (requestId.isNotEmpty()) {
+ requestIdResults = databaseStoreAuditService
+ .getWorkflowStatusByRequestIdAndSubRequestId(requestId, subRequestId)
+ } else {
+ throw httpProcessorException(
+ ErrorCatalogCodes.REQUEST_NOT_FOUND, WorkflowApiDomains.WORKFLOW_API,
+ "Missing param."
+ )
+ }
+ val expectedMediaType: MediaType = MediaType.valueOf(JSON_MIME_TYPE)
+ ResponseEntity.ok().contentType(expectedMediaType).body(requestIdResults)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowExceptionHandler.kt
new file mode 100644
index 000000000..18dfe085b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowExceptionHandler.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+import org.onap.ccsdk.cds.error.catalog.services.ErrorCatalogExceptionHandler
+import org.onap.ccsdk.cds.error.catalog.services.ErrorCatalogService
+import org.springframework.web.bind.annotation.RestControllerAdvice
+
+/**
+ * Handle exceptions in Workflow API and provide relevant HTTP status codes and
+ * messages
+ *
+ */
+@RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.workflow.api")
+open class WorkflowExceptionHandler(private val errorCatalogService: ErrorCatalogService) :
+ ErrorCatalogExceptionHandler(errorCatalogService)
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorCatalogTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorCatalogTestConfiguration.kt
new file mode 100644
index 000000000..a05f569c0
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/ErrorCatalogTestConfiguration.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.error.catalog"]
+)
+@EnableAutoConfiguration
+open class ErrorCatalogTestConfiguration
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/TestDatabaseConfiguration.kt
new file mode 100644
index 000000000..7ca90e9ec
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/TestDatabaseConfiguration.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDataSourceProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Import
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
+import org.springframework.transaction.PlatformTransactionManager
+import javax.sql.DataSource
+
+@Configuration
+@Import(BluePrintDBLibConfiguration::class)
+@EnableJpaRepositories(
+ basePackages = [
+ "org.onap.ccsdk.cds.blueprintsprocessor.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit"
+ ],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
+)
+@EnableJpaAuditing
+open class TestDatabaseConfiguration(primaryDataSourceProperties: PrimaryDataSourceProperties) :
+ PrimaryDatabaseConfiguration(primaryDataSourceProperties) {
+
+ @Bean("primaryEntityManager")
+ open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
+ return primaryEntityManager(
+ "org.onap.ccsdk.cds.blueprintsprocessor.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db"
+ )
+ }
+
+ @Bean("primaryDataSource")
+ override fun primaryDataSource(): DataSource {
+ return super.primaryDataSource()
+ }
+
+ @Bean("primaryTransactionManager")
+ override fun primaryTransactionManager(): PlatformTransactionManager {
+ return super.primaryTransactionManager()
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowControllerTest.kt
new file mode 100644
index 000000000..bf6960f02
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/workflow/api/WorkflowControllerTest.kt
@@ -0,0 +1,268 @@
+/*
+ * Copyright © 2021 Aarna Networks, Inc.
+ * All rights reserved.
+ * 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.blueprintsprocessor.workflow.api
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.DatabaseStoreAuditService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.test.web.reactive.server.WebTestClient
+import java.text.SimpleDateFormat
+import java.util.List
+
+@RunWith(SpringRunner::class)
+@WebFluxTest
+@ContextConfiguration(
+ classes = [
+ TestDatabaseConfiguration::class, ErrorCatalogTestConfiguration::class,
+ WorkflowController::class, DatabaseStoreAuditService::class
+ ]
+)
+@ComponentScan(
+ basePackages = [
+ "org.onap.ccsdk.cds.controllerblueprints.core.service",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit",
+ "org.onap.ccsdk.cds.blueprintsprocessor.workflow.api"
+ ]
+)
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class WorkflowControllerTest {
+
+ @Autowired
+ lateinit var databaseStoreAuditService: DatabaseStoreAuditService
+ @Autowired
+ lateinit var testWebClient: WebTestClient
+
+ @Test
+ fun testWorkflowControllerHealthCheck() {
+ runBlocking {
+ testWebClient.get().uri("/api/v1/workflow/health-check")
+ .exchange()
+ .expectStatus().isOk
+ .expectBody()
+ .equals("Success")
+ }
+ }
+
+ @Test
+ fun testGetWorkFlowByRequestAndSubRequest() {
+
+ val wfAudit1 = createWorkflowAuditStatusRecord(1000)
+ val wfAudit2 = createWorkflowAuditStatusRecord(1001)
+ runBlocking {
+
+ storeToDB(wfAudit1)
+ storeToDB(wfAudit2)
+ val testRequestId: String = "ab543-3asd4"
+ val testSubRequestId: String = "81c9-4910"
+ testWebClient
+ .get()
+ .uri("/api/v1/workflow/audit-status/$testRequestId/$testSubRequestId")
+ .exchange()
+ .expectStatus().isOk
+ .expectBody()
+ .consumeWith {
+ val json = String(it.responseBody!!)
+ val typeFactory = JacksonUtils.objectMapper.typeFactory
+ val list: List<BlueprintWorkflowAuditStatus> = JacksonUtils.objectMapper.readValue(
+ json,
+ typeFactory.constructCollectionType(List::class.java, BlueprintWorkflowAuditStatus::class.java)
+ )
+ Assert.assertEquals(2, list.size)
+ assertEqual(list[0])
+ assertEqual(list[1])
+ }
+ }
+ }
+
+ @Test
+ fun testEmptyRequestAndSubRequest() {
+
+ val wfAudit1 = createWorkflowAuditStatusRecordSetTwo(1002)
+ val wfAudit2 = createWorkflowAuditStatusRecordSetTwo(1003)
+ runBlocking {
+
+ storeToDB(wfAudit1)
+ storeToDB(wfAudit2)
+ val testRequestId: String = ""
+ val testSubRequestId: String = ""
+ testWebClient
+ .get()
+ .uri("/api/v1/workflow/audit-status/$testRequestId/$testSubRequestId")
+ .exchange()
+ .expectStatus().is4xxClientError
+ .expectBody()
+ }
+ }
+
+ @Test
+ @Throws(BluePrintException::class)
+ fun testErrorRequestAndSubRequest() {
+
+ val wfAudit1 = createWorkflowAuditStatusRecordSetTwo(1002)
+ val wfAudit2 = createWorkflowAuditStatusRecordSetTwo(1003)
+ runBlocking {
+
+ storeToDB(wfAudit1)
+ storeToDB(wfAudit2)
+ val testRequestId: String = ""
+ val testSubRequestId: String = ""
+ testWebClient
+ .get()
+ .uri("/api/v1/workflow/audit-status/$testRequestId/$testSubRequestId")
+ .exchange()
+ .expectStatus().is4xxClientError
+ .expectBody()
+ .consumeWith {
+ Assert.assertTrue(
+ "Cause: request Id and requesy sub Id is empty. \n " +
+ "Action : Please verify your request.",
+ it.status.is4xxClientError
+ )
+ }
+ }
+ }
+
+ private fun assertEqual(blueprintWorkflowAuditStatus: BlueprintWorkflowAuditStatus) {
+ Assert.assertEquals(blueprintWorkflowAuditStatus.status, "In progress")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.requestId, "ab543-3asd4")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.subRequestId, "81c9-4910")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.blueprintName, "multi-steps")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.blueprintVersion, "1.0.0")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.requestMode, "sync")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.workflowName, "multi-steps-workflow")
+ Assert.assertEquals(blueprintWorkflowAuditStatus.originatorId, "SDNC_DG")
+ }
+
+ private fun createWorkflowAuditStatusRecord(
+ id: Long
+ ): BlueprintWorkflowAuditStatus {
+
+ var blueprintWorkflowAuditStatus: BlueprintWorkflowAuditStatus =
+ BlueprintWorkflowAuditStatus()
+ blueprintWorkflowAuditStatus.id = id
+ blueprintWorkflowAuditStatus.originatorId = "SDNC_DG"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.requestId = "ab543-3asd4"
+ blueprintWorkflowAuditStatus.subRequestId = "81c9-4910"
+ blueprintWorkflowAuditStatus.status = "In progress"
+ blueprintWorkflowAuditStatus.blueprintName = "multi-steps"
+ blueprintWorkflowAuditStatus.blueprintVersion = "1.0.0"
+ blueprintWorkflowAuditStatus.workflowName = "multi-steps-workflow"
+ blueprintWorkflowAuditStatus.updatedBy = "CBA"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.workflowTaskContent = "{\n" +
+ " \"multi-steps-workflow-request\": {\n" +
+ " \"multi-steps-workflow-properties\": {\n" +
+ " \"prop1\": \"testing\",\n" +
+ " \"prop2\": \"testing description\",\n" +
+ " \"prop3\": \"user name \",\n" +
+ " \"prop4\" : \"test project\"\n" +
+ " }\n" +
+ " }\n" +
+ " }"
+ blueprintWorkflowAuditStatus.workflowResponseContent = " "
+ return blueprintWorkflowAuditStatus
+ }
+
+ private fun createWorkflowAuditStatusRecordSetTwo(
+ id: Long
+ ): BlueprintWorkflowAuditStatus {
+
+ var blueprintWorkflowAuditStatus: BlueprintWorkflowAuditStatus =
+ BlueprintWorkflowAuditStatus()
+ blueprintWorkflowAuditStatus.id = id
+ blueprintWorkflowAuditStatus.originatorId = "SDNC_DG"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.requestId = "ab543-3asd5"
+ blueprintWorkflowAuditStatus.subRequestId = "81c9-4911"
+ blueprintWorkflowAuditStatus.status = "In progress"
+ blueprintWorkflowAuditStatus.blueprintName = "multi-steps"
+ blueprintWorkflowAuditStatus.blueprintVersion = "1.0.0"
+ blueprintWorkflowAuditStatus.workflowName = "multi-steps-workflow"
+ blueprintWorkflowAuditStatus.updatedBy = "CBA"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.workflowTaskContent = "{\n" +
+ " \"multi-steps-workflow-request\": {\n" +
+ " \"multi-steps-workflow-properties\": {\n" +
+ " \"prop1\": \"testing\",\n" +
+ " \"prop2\": \"testing description\",\n" +
+ " \"prop3\": \"user name \",\n" +
+ " \"prop4\" : \"test project\"\n" +
+ " }\n" +
+ " }\n" +
+ " }"
+ blueprintWorkflowAuditStatus.workflowResponseContent = " "
+ return blueprintWorkflowAuditStatus
+ }
+
+ private suspend fun store(
+ id: Long
+ ) {
+ val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ val dateString = "2021-08-08T18:25:43.511Z"
+ val dateForTest = formatter.parse(dateString)
+ databaseStoreAuditService.write(
+ id, "SDNC_DG", "ab543-3asd4",
+ "81c9-4910",
+ "multi-steps-workflow", "multi-steps", "1.0.0",
+ "{\n" +
+ " \"multi-steps-workflow-request\": {\n" +
+ " \"multi-steps-workflow-properties\": {\n" +
+ " \"prop1\": \"testing\",\n" +
+ " \"prop2\": \"testing description\",\n" +
+ " \"prop3\": \"user name \",\n" +
+ " \"prop4\" : \"test project\"\n" +
+ " }\n" +
+ " }\n" +
+ " }",
+ "In progress", dateForTest, dateForTest, dateForTest, "CBA", "sync", " "
+ )
+ }
+
+ private suspend fun storeToDB(
+ blueprintWorkflowAuditStatus: BlueprintWorkflowAuditStatus
+ ) {
+ databaseStoreAuditService.write(
+ blueprintWorkflowAuditStatus.id,
+ blueprintWorkflowAuditStatus.originatorId,
+ blueprintWorkflowAuditStatus.requestId,
+ blueprintWorkflowAuditStatus.subRequestId,
+ blueprintWorkflowAuditStatus.workflowName,
+ blueprintWorkflowAuditStatus.blueprintName,
+ blueprintWorkflowAuditStatus.blueprintVersion,
+ blueprintWorkflowAuditStatus.workflowTaskContent,
+ blueprintWorkflowAuditStatus.status,
+ blueprintWorkflowAuditStatus.startDate,
+ blueprintWorkflowAuditStatus.endDate,
+ blueprintWorkflowAuditStatus.updatedDate,
+ blueprintWorkflowAuditStatus.updatedBy,
+ blueprintWorkflowAuditStatus.requestMode,
+ blueprintWorkflowAuditStatus.workflowResponseContent
+ )
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/resources/application-test.properties
new file mode 100644
index 000000000..b970c53ef
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/workflow-api/src/test/resources/application-test.properties
@@ -0,0 +1,39 @@
+#
+# Copyright © 2021 Aarna Networks, Inc.
+# All rights reserved.
+# 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.
+#
+blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.username=sa
+blueprintsprocessor.db.password=
+blueprintsprocessor.db.driverClassName=org.h2.Driver
+blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.hibernateDDLAuto=update
+blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+
+# Error Managements
+error.catalog.applicationId=cds
+error.catalog.type=properties
+error.catalog.errorDefinitionDir=./../../../application/src/test/resources/
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
+
+#Workflow Audit store enable
+blueprintsprocessor.workflow.self-service-api.audit.storeEnable=true