X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-adaptor-java%2Fsrc%2Ftest%2Fjava%2Forg%2Foran%2Fdmaapadapter%2FIntegrationWithEcs.java;h=376d23e532cb1c6e8a5ba81172332afe86902ee0;hb=6f48adb69090799c74c29204dd2cd1737cc9d6ac;hp=f9ead03ad7ab694e24547c325a3806dd9981a53b;hpb=82378715d387362e97a064665a2467c587afdeed;p=nonrtric.git diff --git a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithEcs.java b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithEcs.java index f9ead03a..376d23e5 100644 --- a/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithEcs.java +++ b/dmaap-adaptor-java/src/test/java/org/oran/dmaapadapter/IntegrationWithEcs.java @@ -52,17 +52,19 @@ import org.springframework.context.annotation.Bean; 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) @TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks", // - "app.vardata-directory=./target", // "app.configuration-filepath=./src/test/resources/test_application_configuration.json", // "app.ecs-base-url=https://localhost:8434" // }) class IntegrationWithEcs { + private static final String EI_JOB_ID = "EI_JOB_ID"; + @Autowired private ApplicationConfig applicationConfig; @@ -162,20 +164,27 @@ class IntegrationWithEcs { return applicationConfig.getEcsBaseUrl(); } - private void createInformationJobInEcs() { - String url = ecsBaseUrl() + "/data-consumer/v1/info-jobs/jobId"; + private String jobUrl(String jobId) { + return ecsBaseUrl() + "/data-consumer/v1/info-jobs/" + jobId; + } + + private void createInformationJobInEcs(String jobId) { String body = gson.toJson(consumerJobInfo()); try { // Delete the job if it already exists - restClient().delete(url).block(); + deleteInformationJobInEcs(jobId); } catch (Exception e) { } - restClient().putForEntity(url, body).block(); + restClient().putForEntity(jobUrl(jobId), body).block(); + } + + private void deleteInformationJobInEcs(String jobId) { + restClient().delete(jobUrl(jobId)).block(); } private ConsumerJobInfo consumerJobInfo() { InfoType type = this.types.getAll().iterator().next(); - return consumerJobInfo(type.getId(), "EI_JOB_ID"); + return consumerJobInfo(type.getId(), EI_JOB_ID); } private Object jsonObject() { @@ -203,7 +212,7 @@ class IntegrationWithEcs { void testWholeChain() throws Exception { await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInEcs()).isTrue()); - createInformationJobInEcs(); + createInformationJobInEcs(EI_JOB_ID); await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1)); @@ -214,6 +223,10 @@ class IntegrationWithEcs { await().untilAsserted(() -> assertThat(results.receivedBodies.size()).isEqualTo(2)); assertThat(results.receivedBodies.get(0)).isEqualTo("DmaapResponse1"); + deleteInformationJobInEcs(EI_JOB_ID); + + await().untilAsserted(() -> assertThat(this.jobs.size()).isZero()); + synchronized (this) { // logger.warn("**************** Keeping server alive! " + // this.applicationConfig.getLocalServerHttpPort());