X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-adaptor-java%2Fsrc%2Ftest%2Fjava%2Forg%2Foran%2Fdmaapadapter%2FIntegrationWithIcs.java;h=9f0ef19fe5ad925a44312d6959dac3cd7689762b;hb=844931b62f35ce6ee2d9dc7274573fc54e14407a;hp=12696edc05c4ab88cf0e26478501e8fcb4874821;hpb=98ce5dc75fc222dadaf26a8a148788b0367bf6ca;p=nonrtric.git 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 12696edc..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) @@ -59,9 +61,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks", // "app.configuration-filepath=./src/test/resources/test_application_configuration.json", // - "app.ecs-base-url=https://localhost:8434" // + "app.ics-base-url=https://localhost:8434" // }) -class IntegrationWithEcs { +class IntegrationWithIcs { private static final String DMAAP_JOB_ID = "DMAAP_JOB_ID"; private static final String DMAAP_TYPE_ID = "DmaapInformationType"; @@ -160,25 +162,25 @@ class IntegrationWithEcs { return "https://localhost:" + this.applicationConfig.getLocalServerHttpPort(); } - private String ecsBaseUrl() { + private String icsBaseUrl() { return applicationConfig.getIcsBaseUrl(); } private String jobUrl(String jobId) { - return ecsBaseUrl() + "/data-consumer/v1/info-jobs/" + jobId + "?typeCheck=true"; + return icsBaseUrl() + "/data-consumer/v1/info-jobs/" + jobId + "?typeCheck=true"; } - private void createInformationJobInEcs(String typeId, String jobId, String filter) { + private void createInformationJobInIcs(String typeId, String jobId, String filter) { String body = gson.toJson(consumerJobInfo(typeId, filter)); try { // Delete the job if it already exists - deleteInformationJobInEcs(jobId); + deleteInformationJobInIcs(jobId); } catch (Exception e) { } restClient().putForEntity(jobUrl(jobId), body).block(); } - private void deleteInformationJobInEcs(String jobId) { + private void deleteInformationJobInIcs(String jobId) { restClient().delete(jobUrl(jobId)).block(); } @@ -227,15 +229,31 @@ class IntegrationWithEcs { await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1)); - deleteInformationJobInEcs("KAFKA_JOB_ID"); + deleteInformationJobInIcs("KAFKA_JOB_ID"); await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); } @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); - createInformationJobInEcs(DMAAP_TYPE_ID, DMAAP_JOB_ID, ".*DmaapResponse.*"); + 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.*"); await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1)); @@ -247,15 +265,9 @@ class IntegrationWithEcs { await().untilAsserted(() -> assertThat(results.receivedBodies.size()).isEqualTo(2)); assertThat(results.receivedBodies.get(0)).isEqualTo("DmaapResponse1"); - deleteInformationJobInEcs(DMAAP_JOB_ID); + deleteInformationJobInIcs(DMAAP_JOB_ID); await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); - - synchronized (this) { - // logger.warn("**************** Keeping server alive! " + - // this.applicationConfig.getLocalServerHttpPort()); - // this.wait(); - } } }