From: PatrikBuhr Date: Wed, 27 Apr 2022 08:56:15 +0000 (+0200) Subject: Bugfix X-Git-Tag: 1.1.0~8^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=54f5e91c0ac2b54ab7c76b7024bcd67dd10f2980;p=nonrtric%2Fplt%2Fdmaapadapter.git Bugfix Timing issue in unittest Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-743 Change-Id: I5bbf1d56f494948b2a59ea6fd26a29947707fcde --- diff --git a/src/test/java/org/oran/dmaapadapter/IcsSimulatorController.java b/src/test/java/org/oran/dmaapadapter/IcsSimulatorController.java index 286712e..6d29c29 100644 --- a/src/test/java/org/oran/dmaapadapter/IcsSimulatorController.java +++ b/src/test/java/org/oran/dmaapadapter/IcsSimulatorController.java @@ -20,6 +20,8 @@ package org.oran.dmaapadapter; +import static org.assertj.core.api.Assertions.assertThat; + import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -27,6 +29,7 @@ import com.google.gson.GsonBuilder; import io.swagger.v3.oas.annotations.tags.Tag; import java.lang.invoke.MethodHandles; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -58,12 +61,12 @@ public class IcsSimulatorController { public static class TestResults { ProducerRegistrationInfo registrationInfo = null; - Map types = new HashMap<>(); + Map types = Collections.synchronizedMap(new HashMap<>()); String infoProducerId = null; public TestResults() {} - public void reset() { + public synchronized void reset() { registrationInfo = null; types.clear(); infoProducerId = null; @@ -107,7 +110,12 @@ public class IcsSimulatorController { ProducerJobInfo request = new ProducerJobInfo(job.jobDefinition, jobId, job.infoTypeId, job.jobResultUri, job.owner, "TIMESTAMP"); String body = gson.toJson(request); - validateJsonObjectAgainstSchema(job.jobDefinition, testResults.types.get(job.infoTypeId).jobDataSchema); + ProducerInfoTypeInfo type = testResults.types.get(job.infoTypeId); + if (type == null) { + logger.error("type not found: {} size: {}", job.infoTypeId, testResults.types.size()); + } + assertThat(type).isNotNull(); + validateJsonObjectAgainstSchema(job.jobDefinition, type.jobDataSchema); logger.info("ICS Simulator PUT job: {}", body); restClient.post(url, body, MediaType.APPLICATION_JSON).block(); }