Define EventType contract for gRPC message 38/79638/3
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Mon, 4 Mar 2019 15:22:04 +0000 (10:22 -0500)
committerAlexis de Talhouët <adetalhouet89@gmail.com>
Tue, 5 Mar 2019 14:23:44 +0000 (14:23 +0000)
Change-Id: Ic8bde56d13f774120c8d64a56993ade71e7b4612
Issue-ID: CCSDK-1118
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
components/model-catalog/proto-definition/proto/BluePrintCommon.proto
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
ms/blueprintsprocessor/modules/services/execution-service/pom.xml
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/parent/pom.xml

index 0f17783..de92bdc 100644 (file)
@@ -26,6 +26,13 @@ message Status {
   int32 code = 1;
   string errorMessage = 2;
   string message = 3;
-  string eventType = 4;
+  EventType eventType = 4;
   string timestamp = 5;
+}
+
+enum EventType {
+  EVENT_COMPONENT_FAILURE = 0;
+  EVENT_COMPONENT_PROCESSING = 1;
+  EVENT_COMPONENT_NOTIFICATION = 2;
+  EVENT_COMPONENT_EXECUTED = 3;
 }
\ No newline at end of file
index c53f039..5278c17 100644 (file)
@@ -30,6 +30,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
 import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile
 import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
@@ -112,11 +113,11 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
         val status = Status()
         status.errorMessage = errorMessage
         if (failure) {
-            status.eventType = "EVENT-COMPONENT-FAILURE"
+            status.eventType = EventType.EVENT_COMPONENT_FAILURE.name
             status.code = 500
             status.message = BluePrintConstants.STATUS_FAILURE
         } else {
-            status.eventType = "EVENT-COMPONENT-PROCESSING"
+            status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
             status.code = 200
             status.message = BluePrintConstants.STATUS_PROCESSING
         }
index df17785..c344ca0 100644 (file)
@@ -21,6 +21,7 @@ import com.google.protobuf.Struct
 import com.google.protobuf.util.JsonFormat
 import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
 import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
 import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
 import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -101,7 +102,7 @@ fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status.toProto(): Stat
     status.errorMessage = this.errorMessage ?: ""
     status.message = this.message
     status.timestamp = this.timestamp.toString()
-    status.eventType = this.eventType
+    status.eventType = EventType.valueOf(this.eventType)
     return status.build()
 }
 
index 04a2c1e..770e4a9 100644 (file)
@@ -6,6 +6,7 @@ import org.junit.runner.RunWith
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags
 import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
 import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
 import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
 import org.springframework.test.context.junit4.SpringRunner
 import java.text.SimpleDateFormat
@@ -47,7 +48,7 @@ class BluePrintMappingsTest {
         val status = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status()
         status.code = 400
         status.errorMessage = "Concurrent modification exception"
-        status.eventType = "Update"
+        status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
         status.message = "Error uploading data"
         status.timestamp = dateForTest
         return status
@@ -60,7 +61,7 @@ class BluePrintMappingsTest {
 
         Assert.assertEquals(status.code, status2.code)
         Assert.assertEquals(status.errorMessage, status2.errorMessage)
-        Assert.assertEquals(status.eventType, status2.eventType)
+        Assert.assertEquals(status.eventType, status2.eventType.name)
         Assert.assertEquals(status.message, status2.message)
         Assert.assertEquals(status.timestamp.toString(), status2.timestamp)
     }
index 283a8a6..df68b95 100644 (file)
@@ -15,7 +15,8 @@
   ~  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">
+<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.apps.blueprintsprocessor</groupId>
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
             <artifactId>resource-dict</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.components</groupId>
+            <artifactId>proto-definition</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.onap.ccsdk.sli.core</groupId>
index 7086ebb..a67e006 100644 (file)
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
@@ -113,7 +114,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
 \r
         // Populate Status\r
         val status = Status()\r
-        status.eventType = "EVENT-COMPONENT-EXECUTED"\r
+        status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name\r
         status.code = 200\r
         status.message = BluePrintConstants.STATUS_SUCCESS\r
         executionServiceOutput.status = status\r
index 51eae8b..cad5a4b 100755 (executable)
                 <artifactId>protobuf-java-util</artifactId>
                 <version>${protobuff.java.utils.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.components</groupId>
+                <artifactId>proto-definition</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- SLI Version -->
             <dependency>