X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fenrichment%2FApplicationTest.java;h=5292d90e00d3e35afd657dd45f5a2a9860bd54ac;hb=f0e49a07dad877f94f635dda4ab477b9636536c8;hp=12d4e472826a169f205d648fdefcd504fa157cb1;hpb=327c5996e5095ed30a8163f5c0b4e678fc0b3ca2;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index 12d4e472..5292d90e 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -162,6 +162,7 @@ class ApplicationTest { this.infoJobs.clear(); this.infoTypes.clear(); this.infoProducers.clear(); + this.infoTypeSubscriptions.clear(); this.producerSimulator.getTestResults().reset(); this.consumerSimulator.getTestResults().reset(); } @@ -475,7 +476,6 @@ class ApplicationTest { putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); verifyJobStatus(EI_JOB_ID, "ENABLED"); - } @Test @@ -765,6 +765,7 @@ class ApplicationTest { ResponseEntity resp = restClient().getForEntity(url).block(); ProducerInfoTypeInfo info = gson.fromJson(resp.getBody(), ProducerInfoTypeInfo.class); assertThat(info.jobDataSchema).isNotNull(); + assertThat(info.typeSpecificInformation).isNotNull(); } @Test @@ -908,7 +909,6 @@ class ApplicationTest { InfoTypes types = new InfoTypes(this.applicationConfig); types.restoreTypesFromDatabase(); assertThat(types.size()).isEqualTo(1); - } { // Restore the jobs, no jobs in database @@ -922,6 +922,25 @@ class ApplicationTest { assertThat(this.infoJobs.size()).isZero(); } + @Test + void testConsumerTypeSubscriptionDatabase() { + final String callbackUrl = baseUrl() + ConsumerSimulatorController.getTypeStatusCallbackUrl(); + final ConsumerTypeSubscriptionInfo info = new ConsumerTypeSubscriptionInfo(callbackUrl, "owner"); + // PUT a subscription + String body = gson.toJson(info); + restClient().putForEntity(typeSubscriptionUrl() + "/subscriptionId", body).block(); + assertThat(this.infoTypeSubscriptions.size()).isEqualTo(1); + + InfoTypeSubscriptions restoredSubscriptions = new InfoTypeSubscriptions(this.applicationConfig); + assertThat(restoredSubscriptions.size()).isEqualTo(1); + assertThat(restoredSubscriptions.getSubscriptionsForOwner("owner")).hasSize(1); + + // Delete the subscription + restClient().deleteForEntity(typeSubscriptionUrl() + "/subscriptionId").block(); + restoredSubscriptions = new InfoTypeSubscriptions(this.applicationConfig); + assertThat(restoredSubscriptions.size()).isZero(); + } + @Test void testConsumerTypeSubscription() throws Exception { @@ -983,6 +1002,21 @@ class ApplicationTest { } } + @Test + void testRemovingNonWorkingSubscription() throws Exception { + // Test that subscriptions are removed for a unresponsive consumer + + // PUT a subscription with a junk callback + final ConsumerTypeSubscriptionInfo info = new ConsumerTypeSubscriptionInfo(baseUrl() + "JUNK", "owner"); + String body = gson.toJson(info); + restClient().putForEntity(typeSubscriptionUrl() + "/subscriptionId", body).block(); + assertThat(this.infoTypeSubscriptions.size()).isEqualTo(1); + + this.putInfoType(TYPE_ID); + // The callback will fail and the subscription will be removed + await().untilAsserted(() -> assertThat(this.infoTypeSubscriptions.size()).isZero()); + } + @Test void testTypeSubscriptionErrorCodes() throws Exception { @@ -1018,7 +1052,7 @@ class ApplicationTest { ProducerInfoTypeInfo producerEiTypeRegistrationInfo(String typeId) throws JsonMappingException, JsonProcessingException { - return new ProducerInfoTypeInfo(jsonSchemaObject()); + return new ProducerInfoTypeInfo(jsonSchemaObject(), typeSpecifcInfoObject()); } ProducerRegistrationInfo producerEiRegistratioInfoRejecting(String typeId) @@ -1061,6 +1095,10 @@ class ApplicationTest { } } + private Object typeSpecifcInfoObject() { + return jsonObject("{ \"propertyName\" : \"value\" }"); + } + private Object jsonSchemaObject() { // a json schema with one mandatory property named "string" String schemaStr = "{" //