diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api')
5 files changed, 2 insertions, 265 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index 1a9b5fc80..9f45c0f35 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -33,11 +33,6 @@ <description>Blueprints Processor Selfservice API</description> <dependencies> - - <dependency> - <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> - <artifactId>blueprint-proto</artifactId> - </dependency> <dependency> <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>blueprint-core</artifactId> 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 636a55423..b25acd148 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 @@ -20,7 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api import io.grpc.stub.StreamObserver import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.toJava +import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toJava import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput 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 ade47cf3f..356f0f7ee 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 @@ -22,7 +22,7 @@ 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.selfservice.api.utils.toProto +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 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt deleted file mode 100644 index 46633aa60..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. - * - * 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.selfservice.api.utils - -import com.fasterxml.jackson.databind.node.ObjectNode -import com.google.common.base.Strings -import com.google.protobuf.Struct -import com.google.protobuf.util.JsonFormat -import org.onap.ccsdk.cds.controllerblueprints.common.api.* -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput -import java.text.SimpleDateFormat -import java.util.* - -private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - -// ACTION IDENTIFIER - -fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers.toProto(): ActionIdentifiers { - val actionIdentifier = ActionIdentifiers.newBuilder() - actionIdentifier.actionName = this.actionName - actionIdentifier.blueprintName = this.blueprintName - actionIdentifier.blueprintVersion = this.blueprintVersion - actionIdentifier.mode = this.mode - return actionIdentifier.build() -} - -fun ActionIdentifiers.toJava(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers { - val actionIdentifier = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers() - actionIdentifier.actionName = this.actionName - actionIdentifier.blueprintName = this.blueprintName - actionIdentifier.blueprintVersion = this.blueprintVersion - actionIdentifier.mode = this.mode - return actionIdentifier -} - -// COMMON HEADER - -fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader.toProto(): CommonHeader { - val commonHeader = CommonHeader.newBuilder() - commonHeader.originatorId = this.originatorId - commonHeader.requestId = this.requestId - commonHeader.subRequestId = this.subRequestId - commonHeader.timestamp = this.timestamp.toString() - commonHeader.flag = this.flags?.toProto() - return commonHeader.build() -} - -fun CommonHeader.toJava(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader { - val commonHeader = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader() - commonHeader.originatorId = this.originatorId - commonHeader.requestId = this.requestId - commonHeader.subRequestId = this.subRequestId - commonHeader.timestamp = if (!Strings.isNullOrEmpty(this.timestamp)) { - formatter.parse(this.timestamp) - } else { - Date() - } - commonHeader.flags = this.flag?.toJava() - return commonHeader -} - -// FLAG - -fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Flags.toProto(): Flag { - val flag = Flag.newBuilder() - flag.isForce = this.isForce - flag.ttl = this.ttl - return flag.build() -} - -fun Flag.toJava(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Flags { - val flag = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Flags() - flag.isForce = this.isForce - flag.ttl = this.ttl - return flag -} - -// STATUS - -fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status.toProto(): Status { - val status = Status.newBuilder() - status.code = this.code - status.errorMessage = this.errorMessage ?: "" - status.message = this.message - status.timestamp = this.timestamp.toString() - status.eventType = EventType.valueOf(this.eventType) - return status.build() -} - -// EXECUTION INPUT - -fun ExecutionServiceInput.toJava(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput { - val executionServiceInput = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput() - executionServiceInput.actionIdentifiers = this.actionIdentifiers.toJava() - executionServiceInput.commonHeader = this.commonHeader.toJava() - executionServiceInput.payload = JacksonUtils.jsonNode(JsonFormat.printer().print(this.payload)) as ObjectNode - return executionServiceInput -} - -// EXECUTION OUPUT - -fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(): ExecutionServiceOutput { - val executionServiceOuput = ExecutionServiceOutput.newBuilder() - executionServiceOuput.actionIdentifiers = this.actionIdentifiers.toProto() - executionServiceOuput.commonHeader = this.commonHeader.toProto() - executionServiceOuput.status = this.status.toProto() - val struct = Struct.newBuilder() - JsonFormat.parser().merge(JacksonUtils.getJson(this.payload), struct) - executionServiceOuput.payload = struct.build() - return executionServiceOuput.build() -}
\ 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/utils/BluePrintMappingTests.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt deleted file mode 100644 index 230d1fde1..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt +++ /dev/null @@ -1,132 +0,0 @@ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils - -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Flags -import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers -import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader -import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.common.api.Flag -import org.springframework.test.context.junit4.SpringRunner -import java.text.SimpleDateFormat - -@RunWith(SpringRunner::class) -class BluePrintMappingsTest { - - val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - val dateString = "2019-01-16T18:25:43.511Z" - val dateForTest = formatter.parse(dateString) - - val flag = Flag.newBuilder().setIsForce(false).setTtl(1).build() - - fun createFlag(): Flags { - val flag = Flags() - flag.isForce = false - flag.ttl = 1 - return flag - } - - @Test - fun flagToJavaTest() { - val flag2 = flag.toJava() - - Assert.assertEquals(flag.isForce, flag2.isForce) - Assert.assertEquals(flag.ttl, flag2.ttl) - } - - @Test - fun flagToProtoTest() { - val flag = createFlag() - val flag2 = flag.toProto() - - Assert.assertEquals(flag.isForce, flag2.isForce) - Assert.assertEquals(flag.ttl, flag2.ttl) - } - - fun createStatus(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status { - val status = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status() - status.code = 400 - status.errorMessage = "Concurrent modification exception" - status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name - status.message = "Error uploading data" - status.timestamp = dateForTest - return status - } - - @Test - fun statusToProtoTest() { - val status = createStatus() - val status2 = status.toProto() - - Assert.assertEquals(status.code, status2.code) - Assert.assertEquals(status.errorMessage, status2.errorMessage) - Assert.assertEquals(status.eventType, status2.eventType.name) - Assert.assertEquals(status.message, status2.message) - Assert.assertEquals(status.timestamp.toString(), status2.timestamp) - } - - @Test - fun commonHeaderToJavaTest() { - val flag = Flag.newBuilder().setIsForce(true).setTtl(2).build() - - val commonHeader = CommonHeader.newBuilder().setOriginatorId("Origin").setRequestId("requestID").setSubRequestId("subRequestID").setTimestamp(dateString).setFlag(flag).build() - val commonHeader2 = commonHeader.toJava() - - Assert.assertEquals(commonHeader.originatorId, commonHeader2.originatorId) - Assert.assertEquals(commonHeader.requestId, commonHeader2.requestId) - Assert.assertEquals(commonHeader.subRequestId, commonHeader2.subRequestId) - Assert.assertEquals(commonHeader.timestamp, formatter.format(commonHeader2.timestamp)) - } - - fun createCommonHeader(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader { - val commonHeader = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader() - commonHeader.flags = createFlag() - commonHeader.originatorId = "1234" - commonHeader.requestId = "2345" - commonHeader.subRequestId = "0123" - commonHeader.timestamp = dateForTest - return commonHeader - } - - @Test - fun commonHeaderToProtoTest() { - val commonHeader = createCommonHeader() - val commonHeader2 = commonHeader.toProto() - Assert.assertEquals(commonHeader.originatorId, commonHeader2.originatorId) - Assert.assertEquals(commonHeader.requestId, commonHeader2.requestId) - Assert.assertEquals(commonHeader.subRequestId, commonHeader2.subRequestId) - Assert.assertEquals(commonHeader.timestamp.toString(), commonHeader2.timestamp) - } - - @Test - fun actionIdentifierToJavaTest() { - val actionIdentifiers = ActionIdentifiers.newBuilder().setActionName("Process Action").setBlueprintName("BlueprintName").setBlueprintVersion("3.0").setMode("Execution").build() - val actionIdentifiers2 = actionIdentifiers.toJava() - - Assert.assertEquals(actionIdentifiers.actionName, actionIdentifiers2.actionName) - Assert.assertEquals(actionIdentifiers.blueprintName, actionIdentifiers2.blueprintName) - Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion) - Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode) - } - - fun createActionIdentifier(): org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers { - val ac = org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers() - ac.mode = "mode" - ac.blueprintVersion = "version" - ac.blueprintName = "name" - ac.actionName = "action" - return ac - } - - @Test - fun actionIdentifierToProtoTest() { - val actionIdentifiers = createActionIdentifier() - val actionIdentifiers2 = actionIdentifiers.toProto() - - Assert.assertEquals(actionIdentifiers.actionName, actionIdentifiers2.actionName) - Assert.assertEquals(actionIdentifiers.blueprintName, actionIdentifiers2.blueprintName) - Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion) - Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode) - } -}
\ No newline at end of file |