From 5ce0ce048084ad1504292a4315a0ba7446ee42bc Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Tue, 18 Jan 2022 11:14:53 +0100 Subject: [PATCH] Updates of typeSchemaKafka.json The typeschema is made more strict. The max buffering time is limitied due to implementation. Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-703 Change-Id: Ie4a0187836ece7bca02ec8e5a08e4ada9f20c231 --- .../src/main/resources/typeSchemaKafka.json | 10 +++++++--- .../java/org/oran/dmaapadapter/ApplicationTest.java | 6 +++--- .../org/oran/dmaapadapter/IntegrationWithIcs.java | 21 +++++++++++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/dmaap-adaptor-java/src/main/resources/typeSchemaKafka.json b/dmaap-adaptor-java/src/main/resources/typeSchemaKafka.json index 38e7807f..f7e6e875 100644 --- a/dmaap-adaptor-java/src/main/resources/typeSchemaKafka.json +++ b/dmaap-adaptor-java/src/main/resources/typeSchemaKafka.json @@ -6,16 +6,20 @@ "type": "string" }, "maxConcurrency": { - "type": "integer" + "type": "integer", + "minimum": 1 }, "bufferTimeout": { "type": "object", "properties": { "maxSize": { - "type": "integer" + "type": "integer", + "minimum": 1 }, "maxTimeMiliseconds": { - "type": "integer" + "type": "integer", + "minimum": 0, + "maximum": 160000 } }, "additionalProperties": false, diff --git a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/ApplicationTest.java b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/ApplicationTest.java index 8c414234..66601750 100644 --- a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/ApplicationTest.java +++ b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/ApplicationTest.java @@ -333,11 +333,11 @@ class ApplicationTest { () -> assertThat(icsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(2)); } - private void testErrorCode(Mono request, HttpStatus expStatus, String responseContains) { + public static void testErrorCode(Mono request, HttpStatus expStatus, String responseContains) { testErrorCode(request, expStatus, responseContains, true); } - private void testErrorCode(Mono request, HttpStatus expStatus, String responseContains, + public static void testErrorCode(Mono request, HttpStatus expStatus, String responseContains, boolean expectApplicationProblemJsonMediaType) { StepVerifier.create(request) // .expectSubscription() // @@ -346,7 +346,7 @@ class ApplicationTest { .verify(); } - private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains, + private static boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains, boolean expectApplicationProblemJsonMediaType) { assertTrue(throwable instanceof WebClientResponseException); WebClientResponseException responseException = (WebClientResponseException) throwable; diff --git a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithIcs.java b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithIcs.java index d1d7e910..9f0ef19f 100644 --- a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithIcs.java +++ b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithIcs.java @@ -49,9 +49,11 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpStatus; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; + @SuppressWarnings("java:S3577") // Rename class @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) @@ -232,7 +234,23 @@ class IntegrationWithIcs { } @Test - void testWholeChain() throws Exception { + void testKafkaJobParameterOutOfRange() { + await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInIcs()).isTrue()); + final String TYPE_ID = "KafkaInformationType"; + + Job.Parameters param = new Job.Parameters("filter", new Job.BufferTimeout(123, 170 * 1000), 1); + + ConsumerJobInfo jobInfo = + new ConsumerJobInfo(TYPE_ID, jsonObject(gson.toJson(param)), "owner", consumerUri(), ""); + String body = gson.toJson(jobInfo); + + ApplicationTest.testErrorCode(restClient().put(jobUrl("KAFKA_JOB_ID"), body), HttpStatus.BAD_REQUEST, + "Json validation failure"); + + } + + @Test + void testDmaapMessage() throws Exception { await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInIcs()).isTrue()); createInformationJobInIcs(DMAAP_TYPE_ID, DMAAP_JOB_ID, ".*DmaapResponse.*"); @@ -250,7 +268,6 @@ class IntegrationWithIcs { deleteInformationJobInIcs(DMAAP_JOB_ID); await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); - } } -- 2.16.6