summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/DataUpdatedEventListenerSpec.groovy18
-rw-r--r--src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/EventFixtures.groovy3
-rw-r--r--src/test/resources/application.yml2
3 files changed, 17 insertions, 6 deletions
diff --git a/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/DataUpdatedEventListenerSpec.groovy b/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/DataUpdatedEventListenerSpec.groovy
index 35ed977..055147f 100644
--- a/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/DataUpdatedEventListenerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/DataUpdatedEventListenerSpec.groovy
@@ -33,8 +33,11 @@ import static org.onap.cps.temporal.controller.event.listener.exception.InvalidE
*/
class DataUpdatedEventListenerSpec extends Specification {
+ public static final String EXPECTED_SCHEMA_EXCEPTION_MESSAGE = 'urn:cps:org.onap.cps:data-updated-event-schema:v99'
+
// Define event data
def anEventType = 'my-event-type'
+ def anEventSchema = new URI('my-event-schema')
def anEventSource = new URI('my-event-source')
def aTimestamp = EventFixtures.currentIsoTimestamp()
def aDataspace = 'my-dataspace'
@@ -82,9 +85,7 @@ class DataUpdatedEventListenerSpec extends Specification {
e.getInvalidFields().size() == 4
e.getInvalidFields().contains(
new InvalidEventEnvelopException.InvalidField(
- MISSING,"schema", null,
- CpsDataUpdatedEvent.Schema.URN_CPS_ORG_ONAP_CPS_DATA_UPDATED_EVENT_SCHEMA_1_1_0_SNAPSHOT
- .value()))
+ UNEXPECTED,"schema", null, EXPECTED_SCHEMA_EXCEPTION_MESSAGE))
e.getInvalidFields().contains(
new InvalidEventEnvelopException.InvalidField(
MISSING, "id", null, null))
@@ -101,12 +102,19 @@ class DataUpdatedEventListenerSpec extends Specification {
when: 'an event with an invalid envelop is received'
def invalidEvent =
new CpsDataUpdatedEvent()
- .withId('my-id').withSource(anEventSource).withType(anEventType)
+ .withId('my-id')
+ .withSchema(anEventSchema)
+ .withSource(anEventSource)
+ .withType(anEventType)
objectUnderTest.consume(invalidEvent)
then: 'an exception is thrown with 2 invalid fields'
def e = thrown(InvalidEventEnvelopException)
e.getCpsDataUpdatedEvent() == invalidEvent
- e.getInvalidFields().size() == 2
+ e.getInvalidFields().size() == 3
+ e.getInvalidFields().contains(
+ new InvalidEventEnvelopException.InvalidField(
+ UNEXPECTED, "schema", anEventSchema.toString(),
+ EXPECTED_SCHEMA_EXCEPTION_MESSAGE))
e.getInvalidFields().contains(
new InvalidEventEnvelopException.InvalidField(
UNEXPECTED, "type", anEventType, EventFixtures.defaultEventType))
diff --git a/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/EventFixtures.groovy b/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/EventFixtures.groovy
index 44a28de..7c4dee6 100644
--- a/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/EventFixtures.groovy
+++ b/src/test/groovy/org/onap/cps/temporal/controller/event/listener/kafka/EventFixtures.groovy
@@ -32,11 +32,14 @@ class EventFixtures {
static DateTimeFormatter isoTimestampFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
static String defaultEventType = 'org.onap.cps.data-updated-event'
+ static URI defaultEventSchema = new URI('urn:cps:org.onap.cps:data-updated-event-schema:v1')
static URI defaultEventSource = new URI('urn:cps:org.onap.cps')
static CpsDataUpdatedEvent buildEvent(final Map map) {
CpsDataUpdatedEvent event =
new CpsDataUpdatedEvent()
+ .withSchema(
+ map.eventSchema != null ? new URI(map.eventSchema.toString()) : defaultEventSchema)
.withId(
map.id != null ? map.id.toString() : UUID.randomUUID().toString())
.withType(
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index 6765057..9bdacbe 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -60,7 +60,7 @@ spring:
app:
listener:
data-updated:
- topic: cps.cfg-state-events
+ topic: cps.data-updated-events
query:
response:
max-page-size: 20