From 8e617d64a7725f5fb0f0f31a5c551ff3e1e484de Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Mon, 8 Jan 2024 13:28:53 +0000 Subject: Clean up cps temporal related notification code - remove 'test' level folder - remove schemas but leave structure - remove 'data-updated' from test application.yaml - remove NOTIFICATION_DATASPACE_FILTER_PATTERNS from docker-compose Issue-ID: CPS-2005 Signed-off-by: JvD_Ericsson Change-Id: I3962d795c760de6ba5ff353e85894895437ad5e7 --- .../schemas/cps-data-updated-event-schema.json | 91 ------------- cps-events/src/main/resources/schemas/dummy.txt | 0 .../onap/cps/event/CpsDataUpdatedEventSpec.groovy | 145 --------------------- cps-events/src/test/resources/event-v1.json | 34 ----- .../test/resources/event-v2-create-operation.json | 36 ----- .../test/resources/event-v2-delete-operation.json | 13 -- .../event-v2-with-additional-properties.json | 36 ----- cps-service/src/test/resources/application.yml | 7 - docker-compose/docker-compose.yml | 1 - 9 files changed, 363 deletions(-) delete mode 100644 cps-events/src/main/resources/schemas/cps-data-updated-event-schema.json create mode 100644 cps-events/src/main/resources/schemas/dummy.txt delete mode 100644 cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy delete mode 100644 cps-events/src/test/resources/event-v1.json delete mode 100644 cps-events/src/test/resources/event-v2-create-operation.json delete mode 100644 cps-events/src/test/resources/event-v2-delete-operation.json delete mode 100644 cps-events/src/test/resources/event-v2-with-additional-properties.json diff --git a/cps-events/src/main/resources/schemas/cps-data-updated-event-schema.json b/cps-events/src/main/resources/schemas/cps-data-updated-event-schema.json deleted file mode 100644 index 3c95664d7a..0000000000 --- a/cps-events/src/main/resources/schemas/cps-data-updated-event-schema.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "urn:cps:org.onap.cps:data-updated-event-schema:v2", - - "$ref": "#/definitions/CpsDataUpdatedEvent", - - "definitions": { - - "CpsDataUpdatedEvent": { - "description": "The payload for CPS data updated event.", - "type": "object", - "properties": { - "schema": { - "description": "The schema, including its version, that this event adheres to. E.g. 'urn:cps:org.onap.cps:data-updated-event-schema:v99'.", - "type": "string", - "format": "uri" - }, - "id": { - "description": "The unique id identifying the event for the specified source. Producer must ensure that source + id is unique for each distinct event.", - "type": "string" - }, - "source": { - "description": "The source of the event. Producer must ensure that source + id is unique for each distinct event.", - "type": "string", - "format": "uri" - }, - "type": { - "description": "The type of the event.", - "type": "string" - }, - "content": { - "$ref": "#/definitions/Content" - } - }, - "required": [ - "schema", - "id", - "source", - "type", - "content" - ], - "additionalProperties": true - }, - - "Content": { - "description": "The event content.", - "type": "object", - "properties": { - "observedTimestamp": { - "description": "The timestamp when the data has been observed. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'. Ex: '2020-12-01T00:00:00.000+0000' ", - "type": "string" - }, - "dataspaceName": { - "description": "The name of CPS Core dataspace the data belongs to.", - "type": "string" - }, - "schemaSetName": { - "description": "The name of CPS Core schema set the data adheres to.", - "type": "string" - }, - "anchorName": { - "description": "The name of CPS Core anchor the data is attached to.", - "type": "string" - }, - "operation": { - "description": "The operation on the data", - "type": "string", - "enum": ["CREATE", "UPDATE", "DELETE"] - }, - "data": { - "$ref": "#/definitions/Data" - } - }, - "required": [ - "observedTimestamp", - "dataspaceName", - "schemaSetName", - "anchorName" - ], - "additionalProperties": true - }, - - "Data": { - "description": "Data as json object.", - "type": "object" - } - - } - -} diff --git a/cps-events/src/main/resources/schemas/dummy.txt b/cps-events/src/main/resources/schemas/dummy.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy b/cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy deleted file mode 100644 index aac0b5aba9..0000000000 --- a/cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy +++ /dev/null @@ -1,145 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (c) 2021 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.cps.event - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.ObjectNode -import org.onap.cps.event.model.Content -import org.onap.cps.event.model.CpsDataUpdatedEvent -import org.onap.cps.event.model.Data -import spock.lang.Shared -import spock.lang.Specification - -/** - * Test class for CpsDataUpdatedEvent. - */ -class CpsDataUpdatedEventSpec extends Specification { - - def objectMapper = new ObjectMapper() - - final DATASPACE_NAME = 'my-dataspace' - final BOOKSTORE_SCHEMA_SET = 'bookstore-schemaset' - final ANCHOR_NAME = 'chapters' - final EVENT_TIMESTAMP = '2020-12-01T00:00:00.000+0000' - final EVENT_ID = '77b8f114-4562-4069-8234-6d059ff742ac' - final EVENT_SOURCE = new URI('urn:cps:org.onap.cps') - final EVENT_TYPE = 'org.onap.cps.data-updated-event' - final EVENT_SCHEMA_V1 = new URI('urn:cps:org.onap.cps:data-updated-event-schema:v1') - final EVENT_SCHEMA_V2 = new URI('urn:cps:org.onap.cps:data-updated-event-schema:v2') - - @Shared - final DATA = [ - 'test:bookstore': [ - 'bookstore-name': 'Chapters', - 'categories' : [ - ['code' : '01', - 'name' : 'SciFi', - 'books': [ - ['authors' : ['Iain M. Banks'], - 'lang' : 'en', - 'price' : 895, - 'pub_year': '1994', - 'title' : 'Feersum Endjinn' - ] - ] - ] - ] - ] - ] - - def 'Conversion from Event V1 JSON String to CpsDataUpdatedEvent POJO.'() { - when: 'event V1 JSON String is converted to CpsDataUpdatedEvent' - def notificationMessage = getEventAsJsonStringFromFile('/event-v1.json') - def cpsDataUpdatedEvent = objectMapper.readValue(notificationMessage, CpsDataUpdatedEvent.class) - then: 'CpsDataUpdatedEvent POJO has the excepted values' - cpsDataUpdatedEvent.id == EVENT_ID - cpsDataUpdatedEvent.source == EVENT_SOURCE - cpsDataUpdatedEvent.schema == EVENT_SCHEMA_V1 - cpsDataUpdatedEvent.type == EVENT_TYPE - def content = cpsDataUpdatedEvent.content - content.observedTimestamp == EVENT_TIMESTAMP - content.dataspaceName == DATASPACE_NAME - content.schemaSetName == BOOKSTORE_SCHEMA_SET - content.anchorName == ANCHOR_NAME - content.data.getAdditionalProperties() == DATA - } - - def 'Conversion from Event V2 JSON String to CpsDataUpdatedEvent POJO'() { - when: 'event V2 JSON String is converted to CpsDataUpdatedEvent' - def notificationMessage = getEventAsJsonStringFromFile(inputEventJson) - def cpsDataUpdatedEvent = objectMapper.readValue(notificationMessage, CpsDataUpdatedEvent.class) - then: 'CpsDataUpdatedEvent POJO has the excepted values' - with(cpsDataUpdatedEvent) { - id == EVENT_ID - source == EVENT_SOURCE - schema == EVENT_SCHEMA_V2 - type == EVENT_TYPE - } - with(cpsDataUpdatedEvent.content) { - observedTimestamp == EVENT_TIMESTAMP - dataspaceName == DATASPACE_NAME - schemaSetName == BOOKSTORE_SCHEMA_SET - anchorName == ANCHOR_NAME - operation == expectedOperation - if (expectedData != null) - data.getAdditionalProperties() == expectedData - else - data == null - } - where: - scenario | inputEventJson || expectedData | expectedOperation - 'create operation' | '/event-v2-create-operation.json' || DATA | Content.Operation.CREATE - 'delete operation' | '/event-v2-delete-operation.json' || null | Content.Operation.DELETE - 'create with additional fields' | '/event-v2-with-additional-properties.json' || DATA | Content.Operation.CREATE - } - - def 'Conversion from CpsDataUpdatedEvent POJO to Event V2 JSON String.'() { - given: 'Event V2 content with the Data' - def data = new Data() - data.withAdditionalProperty('test:bookstore', DATA.'test:bookstore') - def content = new Content() - content.withAnchorName(ANCHOR_NAME) - .withDataspaceName(DATASPACE_NAME) - .withSchemaSetName(BOOKSTORE_SCHEMA_SET) - .withObservedTimestamp(EVENT_TIMESTAMP) - .withOperation(Content.Operation.CREATE) - .withData(data) - and: 'CpsDataUpdatedEvent with the content' - def cpsDataUpdateEvent = new CpsDataUpdatedEvent() - cpsDataUpdateEvent - .withSchema(EVENT_SCHEMA_V2) - .withId(EVENT_ID) - .withSource(EVENT_SOURCE) - .withType(EVENT_TYPE) - .withContent(content) - when: 'CpsDataUpdatedEvent is converted to Event V2 JSON string' - def actualMessage = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(cpsDataUpdateEvent) - then: 'the created JSON String is same as the expected JSON String' - def expectedMessage = getEventAsJsonStringFromFile('/event-v2-create-operation.json') - assert actualMessage == expectedMessage - } - - def getEventAsJsonStringFromFile(String fileName) { - return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString( - objectMapper.readValue( - this.class.getResource(fileName).getText('UTF-8'), - ObjectNode.class) - ) - } -} diff --git a/cps-events/src/test/resources/event-v1.json b/cps-events/src/test/resources/event-v1.json deleted file mode 100644 index 753426a60a..0000000000 --- a/cps-events/src/test/resources/event-v1.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v1", - "id": "77b8f114-4562-4069-8234-6d059ff742ac", - "source": "urn:cps:org.onap.cps", - "type": "org.onap.cps.data-updated-event", - "content": { - "observedTimestamp": "2020-12-01T00:00:00.000+0000", - "dataspaceName": "my-dataspace", - "schemaSetName": "bookstore-schemaset", - "anchorName": "chapters", - "data": { - "test:bookstore":{ - "bookstore-name": "Chapters", - "categories": [ - { - "code": "01", - "name": "SciFi", - "books": [ - { - "authors": [ - "Iain M. Banks" - ], - "lang": "en", - "price": 895, - "pub_year": "1994", - "title": "Feersum Endjinn" - } - ] - } - ] - } - } - } -} diff --git a/cps-events/src/test/resources/event-v2-create-operation.json b/cps-events/src/test/resources/event-v2-create-operation.json deleted file mode 100644 index 92ecab34f9..0000000000 --- a/cps-events/src/test/resources/event-v2-create-operation.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v2", - "id": "77b8f114-4562-4069-8234-6d059ff742ac", - "source": "urn:cps:org.onap.cps", - "type": "org.onap.cps.data-updated-event", - "content": { - "observedTimestamp": "2020-12-01T00:00:00.000+0000", - "dataspaceName": "my-dataspace", - "schemaSetName": "bookstore-schemaset", - "anchorName": "chapters", - "operation" : "CREATE", - "data": { - "test:bookstore":{ - "bookstore-name": "Chapters", - "categories": [ - { - "code": "01", - "name": "SciFi", - "books": [ - { - "authors": [ - "Iain M. Banks" - ], - "lang": "en", - "price": 895, - "pub_year": "1994", - "title": "Feersum Endjinn" - } - ] - } - ] - } - } - } -} - diff --git a/cps-events/src/test/resources/event-v2-delete-operation.json b/cps-events/src/test/resources/event-v2-delete-operation.json deleted file mode 100644 index e003088bff..0000000000 --- a/cps-events/src/test/resources/event-v2-delete-operation.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v2", - "id": "77b8f114-4562-4069-8234-6d059ff742ac", - "source": "urn:cps:org.onap.cps", - "type": "org.onap.cps.data-updated-event", - "content": { - "observedTimestamp": "2020-12-01T00:00:00.000+0000", - "dataspaceName": "my-dataspace", - "schemaSetName": "bookstore-schemaset", - "anchorName": "chapters", - "operation" : "DELETE" - } -} \ No newline at end of file diff --git a/cps-events/src/test/resources/event-v2-with-additional-properties.json b/cps-events/src/test/resources/event-v2-with-additional-properties.json deleted file mode 100644 index 4e2db6898e..0000000000 --- a/cps-events/src/test/resources/event-v2-with-additional-properties.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v2", - "id": "77b8f114-4562-4069-8234-6d059ff742ac", - "source": "urn:cps:org.onap.cps", - "type": "org.onap.cps.data-updated-event", - "content": { - "observedTimestamp": "2020-12-01T00:00:00.000+0000", - "dataspaceName": "my-dataspace", - "schemaSetName": "bookstore-schemaset", - "anchorName": "chapters", - "operation" : "CREATE", - "additionalField" : "value", - "data": { - "test:bookstore":{ - "bookstore-name": "Chapters", - "categories": [ - { - "code": "01", - "name": "SciFi", - "books": [ - { - "authors": [ - "Iain M. Banks" - ], - "lang": "en", - "price": 895, - "pub_year": "1994", - "title": "Feersum Endjinn" - } - ] - } - ] - } - } - } -} diff --git a/cps-service/src/test/resources/application.yml b/cps-service/src/test/resources/application.yml index dc100667ba..b666885f22 100644 --- a/cps-service/src/test/resources/application.yml +++ b/cps-service/src/test/resources/application.yml @@ -18,11 +18,6 @@ # ============LICENSE_END========================================================= notification: - enabled: true - data-updated: - filters: - enabled-dataspaces: ".*-published,.*-important" - topic: cps-event async: executor: core-pool-size: 2 @@ -42,8 +37,6 @@ spring: group-id: cps-test auto-offset-reset: earliest value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer - properties: - spring.json.value.default.type: org.onap.cps.event.model.CpsDataUpdatedEvent logging: level: diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 80f8782af0..11d39b59dc 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -49,7 +49,6 @@ services: KAFKA_BOOTSTRAP_SERVER: kafka:29092 notification.enabled: 'true' notification.async.executor.time-out-value-in-ms: 2000 - NOTIFICATION_DATASPACE_FILTER_PATTERNS: '.*' NCMP_TIMERS_ADVISED-MODULES-SYNC_SLEEP-TIME-MS: ${ADVISED_MODULES_SYNC_SLEEP_TIME_MS:-30000} NCMP_TIMERS_CM-HANDLE-DATA-SYNC_SLEEP-TIME-MS: ${CMHANDLE_DATA_SYNC_SLEEP_TIME_MS:-30000} JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -- cgit 1.2.3-korg