X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-adaptor-java%2Fsrc%2Ftest%2Fjava%2Forg%2Foran%2Fdmaapadapter%2FApplicationTest.java;h=e78313c04d34f25f218599623419da0193e94a06;hb=c9c6839d27aaad72ff7b3140992e0ade4b0f07bb;hp=287c95ec74a4a449aaf63930a2690bf9fb52ca41;hpb=c873fa9306739a14d05454d2ec27bc2fde497058;p=nonrtric.git 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 287c95ec..e78313c0 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 @@ -34,6 +34,7 @@ import java.nio.file.Paths; import org.json.JSONObject; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.oran.dmaapadapter.clients.AsyncRestClient; @@ -46,8 +47,8 @@ import org.oran.dmaapadapter.configuration.WebClientConfig.HttpProxyConfig; import org.oran.dmaapadapter.controllers.ProducerCallbacksController; import org.oran.dmaapadapter.r1.ConsumerJobInfo; import org.oran.dmaapadapter.r1.ProducerJobInfo; -import org.oran.dmaapadapter.repository.InfoType; import org.oran.dmaapadapter.repository.InfoTypes; +import org.oran.dmaapadapter.repository.Job; import org.oran.dmaapadapter.repository.Jobs; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -68,7 +69,7 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks", // @@ -138,6 +139,11 @@ class ApplicationTest { } } + @BeforeEach + void setPort() { + this.applicationConfig.setLocalServerHttpPort(this.localServerHttpPort); + } + @AfterEach void reset() { this.consumerController.testResults.reset(); @@ -174,8 +180,7 @@ class ApplicationTest { } private ConsumerJobInfo consumerJobInfo() { - InfoType type = this.types.getAll().iterator().next(); - return consumerJobInfo(type.getId(), "EI_JOB_ID"); + return consumerJobInfo("DmaapInformationType", "EI_JOB_ID"); } private Object jsonObject() { @@ -237,7 +242,7 @@ class ApplicationTest { // Register producer, Register types await().untilAsserted(() -> assertThat(ecsSimulatorController.testResults.registrationInfo).isNotNull()); - assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1); + assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(this.types.size()); // Create a job this.ecsSimulatorController.addJob(consumerJobInfo(), JOB_ID, restClient()); @@ -253,30 +258,48 @@ class ApplicationTest { String jobUrl = baseUrl() + ProducerCallbacksController.JOB_URL; String jobs = restClient().get(jobUrl).block(); - assertThat(jobs).contains("ExampleInformationType"); + assertThat(jobs).contains(JOB_ID); // Delete the job this.ecsSimulatorController.deleteJob(JOB_ID, restClient()); await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); - } @Test void testReRegister() throws Exception { // Wait foir register types and producer await().untilAsserted(() -> assertThat(ecsSimulatorController.testResults.registrationInfo).isNotNull()); - assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1); + assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(this.types.size()); // Clear the registration, should trigger a re-register ecsSimulatorController.testResults.reset(); await().untilAsserted(() -> assertThat(ecsSimulatorController.testResults.registrationInfo).isNotNull()); - assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1); + assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(this.types.size()); // Just clear the registerred types, should trigger a re-register ecsSimulatorController.testResults.types.clear(); await().untilAsserted( - () -> assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1)); + () -> assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(2)); + } + + @Test + void testCreateKafkaJob() { + await().untilAsserted(() -> assertThat(ecsSimulatorController.testResults.registrationInfo).isNotNull()); + assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(this.types.size()); + + final String TYPE_ID = "KafkaInformationType"; + Job.Parameters param = new Job.Parameters("filter", new Job.BufferTimeout(123, 456), 1); + String targetUri = baseUrl() + ConsumerController.CONSUMER_TARGET_URL; + ConsumerJobInfo jobInfo = new ConsumerJobInfo(TYPE_ID, jsonObject(gson.toJson(param)), "owner", targetUri, ""); + + // Create a job + this.ecsSimulatorController.addJob(jobInfo, "JOB_ID", restClient()); + await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1)); + + // Delete the job + this.ecsSimulatorController.deleteJob("JOB_ID", restClient()); + await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); } private void testErrorCode(Mono request, HttpStatus expStatus, String responseContains) { @@ -303,5 +326,4 @@ class ApplicationTest { } return true; } - }