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=287c95ec74a4a449aaf63930a2690bf9fb52ca41;hb=ce1d9f2d3e1d2713289dc4d2b5c246f99ec65160;hp=cbaa59fa448732e4f08d98d11450603f2b7671ce;hpb=4917d45e3e4a08e3e587c88ec17a12dc6da4d073;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 cbaa59fa..287c95ec 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 @@ -49,7 +49,6 @@ import org.oran.dmaapadapter.r1.ProducerJobInfo; import org.oran.dmaapadapter.repository.InfoType; import org.oran.dmaapadapter.repository.InfoTypes; import org.oran.dmaapadapter.repository.Jobs; -import org.oran.dmaapadapter.tasks.ProducerRegstrationTask; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -80,9 +79,6 @@ class ApplicationTest { @Autowired private ApplicationConfig applicationConfig; - @Autowired - private ProducerRegstrationTask producerRegstrationTask; - @Autowired private Jobs jobs; @@ -147,7 +143,6 @@ class ApplicationTest { this.consumerController.testResults.reset(); this.ecsSimulatorController.testResults.reset(); this.jobs.clear(); - this.types.clear(); } private AsyncRestClient restClient(boolean useTrustValidation) { @@ -232,7 +227,8 @@ class ApplicationTest { ProducerJobInfo info = new ProducerJobInfo(null, "id", "typeId", "targetUri", "owner", "lastUpdated"); String body = gson.toJson(info); - testErrorCode(restClient().post(jobUrl, body), HttpStatus.NOT_FOUND, "Could not find type"); + testErrorCode(restClient().post(jobUrl, body, MediaType.APPLICATION_JSON), HttpStatus.NOT_FOUND, + "Could not find type"); } @Test @@ -240,7 +236,8 @@ class ApplicationTest { final String JOB_ID = "ID"; // Register producer, Register types - await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInEcs()).isTrue()); + await().untilAsserted(() -> assertThat(ecsSimulatorController.testResults.registrationInfo).isNotNull()); + assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1); // Create a job this.ecsSimulatorController.addJob(consumerJobInfo(), JOB_ID, restClient()); @@ -254,9 +251,32 @@ class ApplicationTest { await().untilAsserted(() -> assertThat(consumer.receivedBodies.size()).isEqualTo(2)); assertThat(consumer.receivedBodies.get(0)).isEqualTo("DmaapResponse1"); + String jobUrl = baseUrl() + ProducerCallbacksController.JOB_URL; + String jobs = restClient().get(jobUrl).block(); + assertThat(jobs).contains("ExampleInformationType"); + // 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); + + // 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); + + // Just clear the registerred types, should trigger a re-register + ecsSimulatorController.testResults.types.clear(); + await().untilAsserted( + () -> assertThat(ecsSimulatorController.testResults.registrationInfo.supportedTypeIds).hasSize(1)); + } private void testErrorCode(Mono request, HttpStatus expStatus, String responseContains) {