summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-events/src/main/resources/schemas/cps-data-updated-event-schema.json11
-rw-r--r--cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy11
-rw-r--r--cps-events/src/test/resources/bookstore-chapters.json6
-rw-r--r--cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java9
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/notification/CpsDataUpdateEventFactorySpec.groovy3
5 files changed, 19 insertions, 21 deletions
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
index de445ec722..c2fa5f2871 100644
--- 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
@@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "urn:cps:org.onap.cps:data-updated-event-schema:1.1.0-SNAPSHOT",
+ "$id": "urn:cps:org.onap.cps:data-updated-event-schema:v1",
"$ref": "#/definitions/CpsDataUpdatedEvent",
@@ -12,10 +12,9 @@
"type": "object",
"properties": {
"schema": {
- "description": "The schema, including its version, that this event adheres to.",
+ "description": "The schema, including its version, that this event adheres to. Ex: 'urn:cps:org.onap.cps:data-updated-event-schema:v1'.",
"type": "string",
- "default": "urn:cps:org.onap.cps:data-updated-event-schema:1.1.0-SNAPSHOT",
- "enum": ["urn:cps:org.onap.cps:data-updated-event-schema:1.1.0-SNAPSHOT"]
+ "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.",
@@ -69,7 +68,7 @@
}
},
"required": [
- "timestamp",
+ "observedTimestamp",
"dataspaceName",
"schemaSetName",
"anchorName",
@@ -85,4 +84,4 @@
}
-} \ No newline at end of file
+}
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
index f72eceed1c..545b183378 100644
--- a/cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy
+++ b/cps-events/src/test/groovy/org/onap/cps/event/CpsDataUpdatedEventSpec.groovy
@@ -33,13 +33,13 @@ class CpsDataUpdatedEventSpec extends Specification {
def objectMapper = new ObjectMapper()
final DATASPACE_NAME = 'my-dataspace'
- final BOOKSTORE_SCHEMA_SET = 'bootstore-schemaset'
+ 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 = 'urn:cps:org.onap.cps:data-updated-event-schema:1.1.0-SNAPSHOT'
+ final EVENT_SCHEMA = new URI('urn:cps:org.onap.cps:data-updated-event-schema:v1')
final DATA = [
'test:bookstore': [
@@ -67,7 +67,7 @@ class CpsDataUpdatedEventSpec extends Specification {
then: 'CpsDataUpdatedEvent POJO has the excepted values'
cpsDataUpdatedEvent.id == EVENT_ID
cpsDataUpdatedEvent.source == EVENT_SOURCE
- cpsDataUpdatedEvent.schema.value() == EVENT_SCHEMA
+ cpsDataUpdatedEvent.schema == EVENT_SCHEMA
cpsDataUpdatedEvent.type == EVENT_TYPE
def content = cpsDataUpdatedEvent.content
content.observedTimestamp == EVENT_TIMESTAMP
@@ -90,8 +90,7 @@ class CpsDataUpdatedEventSpec extends Specification {
and: 'CpsDataUpdatedEvent with the content'
def cpsDataUpdateEvent = new CpsDataUpdatedEvent()
cpsDataUpdateEvent
- .withSchema(
- CpsDataUpdatedEvent.Schema.fromValue(EVENT_SCHEMA))
+ .withSchema(EVENT_SCHEMA)
.withId(EVENT_ID)
.withSource(EVENT_SOURCE)
.withType(EVENT_TYPE)
@@ -111,4 +110,4 @@ class CpsDataUpdatedEventSpec extends Specification {
)
}
-} \ No newline at end of file
+}
diff --git a/cps-events/src/test/resources/bookstore-chapters.json b/cps-events/src/test/resources/bookstore-chapters.json
index de46b71841..753426a60a 100644
--- a/cps-events/src/test/resources/bookstore-chapters.json
+++ b/cps-events/src/test/resources/bookstore-chapters.json
@@ -1,12 +1,12 @@
{
- "schema": "urn:cps:org.onap.cps:data-updated-event-schema:1.1.0-SNAPSHOT",
+ "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": "bootstore-schemaset",
+ "schemaSetName": "bookstore-schemaset",
"anchorName": "chapters",
"data": {
"test:bookstore":{
@@ -31,4 +31,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
index e1473d3ff9..26b89fcd57 100644
--- a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
+++ b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
@@ -27,7 +27,6 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.event.model.Content;
import org.onap.cps.event.model.CpsDataUpdatedEvent;
-import org.onap.cps.event.model.CpsDataUpdatedEvent.Schema;
import org.onap.cps.event.model.Data;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.Anchor;
@@ -38,6 +37,7 @@ import org.springframework.stereotype.Component;
@Component
class CpsDataUpdatedEventFactory {
+ private static final URI EVENT_SCHEMA;
private static final URI EVENT_SOURCE;
private static final String EVENT_TYPE = "org.onap.cps.data-updated-event";
private static final DateTimeFormatter dateTimeFormatter =
@@ -45,6 +45,7 @@ class CpsDataUpdatedEventFactory {
static {
try {
+ EVENT_SCHEMA = new URI("urn:cps:org.onap.cps:data-updated-event-schema:v1");
EVENT_SOURCE = new URI("urn:cps:org.onap.cps");
} catch (final URISyntaxException e) {
// As it is fixed string, I don't expect to see this error
@@ -52,8 +53,8 @@ class CpsDataUpdatedEventFactory {
}
}
- private CpsDataService cpsDataService;
- private CpsAdminService cpsAdminService;
+ private final CpsDataService cpsDataService;
+ private final CpsAdminService cpsAdminService;
public CpsDataUpdatedEventFactory(final CpsDataService cpsDataService, final CpsAdminService cpsAdminService) {
this.cpsDataService = cpsDataService;
@@ -71,7 +72,7 @@ class CpsDataUpdatedEventFactory {
final var cpsDataUpdatedEvent = new CpsDataUpdatedEvent();
cpsDataUpdatedEvent.withContent(createContent(anchor, dataNode));
cpsDataUpdatedEvent.withId(UUID.randomUUID().toString());
- cpsDataUpdatedEvent.withSchema(Schema.URN_CPS_ORG_ONAP_CPS_DATA_UPDATED_EVENT_SCHEMA_1_1_0_SNAPSHOT);
+ cpsDataUpdatedEvent.withSchema(EVENT_SCHEMA);
cpsDataUpdatedEvent.withSource(EVENT_SOURCE);
cpsDataUpdatedEvent.withType(EVENT_TYPE);
return cpsDataUpdatedEvent;
diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/CpsDataUpdateEventFactorySpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/CpsDataUpdateEventFactorySpec.groovy
index aecc3f7ee0..2ce77bd1a8 100644
--- a/cps-service/src/test/groovy/org/onap/cps/notification/CpsDataUpdateEventFactorySpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/notification/CpsDataUpdateEventFactorySpec.groovy
@@ -21,7 +21,6 @@ package org.onap.cps.notification
import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
-import org.onap.cps.event.model.CpsDataUpdatedEvent
import org.onap.cps.event.model.Data
import org.onap.cps.spi.FetchDescendantsOption
import org.onap.cps.spi.model.Anchor
@@ -61,7 +60,7 @@ class CpsDataUpdateEventFactorySpec extends Specification {
with(cpsDataUpdatedEvent) {
type == 'org.onap.cps.data-updated-event'
source == new URI('urn:cps:org.onap.cps')
- schema == CpsDataUpdatedEvent.Schema.URN_CPS_ORG_ONAP_CPS_DATA_UPDATED_EVENT_SCHEMA_1_1_0_SNAPSHOT
+ schema == new URI('urn:cps:org.onap.cps:data-updated-event-schema:v1')
StringUtils.hasText(id)
content != null
}