From ea9113151c030efdd9b393787f1e57bc72734e88 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 3 Apr 2020 17:45:29 -0400 Subject: Models junits are failing locally Junits were failing in my local eclipse environment. Fixed the following: - more cases of "is marked @NonNull but is null" (I thought Liam had already fixed all of these, but I'm still seeing errors, so fixed some more) - comparing "Instant" values in event time stamps assumes that the times will be different, but may not be, if the JVM is fast enough. Modified the test to set the times of the new events to Instant+1, to ensure that they are different from the original Issue-ID: POLICY-2305 Change-Id: Ic05bc6a58b559ba589583ce887711ee01f76691c Signed-off-by: Jim Hahn --- .../events/src/test/java/org/onap/policy/controlloop/AbatedTest.java | 2 +- .../test/java/org/onap/policy/controlloop/CanonicalAbatedTest.java | 4 ++-- .../src/test/java/org/onap/policy/controlloop/CanonicalOnsetTest.java | 4 ++-- .../events/src/test/java/org/onap/policy/controlloop/OnsetTest.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'models-interactions/model-impl/events/src/test/java') diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/AbatedTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/AbatedTest.java index e1ef77e22..22ef769f9 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/AbatedTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/AbatedTest.java @@ -41,7 +41,7 @@ public class AbatedTest { assertEquals(event.getClosedLoopAlarmStart(), abated.getClosedLoopAlarmStart()); assertEquals(ControlLoopEventStatus.ABATED, abated.getClosedLoopEventStatus()); - abated.setClosedLoopAlarmEnd(Instant.now()); + abated.setClosedLoopAlarmEnd(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); assertNotEquals(abated, event); assertEquals(new Abated(abated), abated); diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalAbatedTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalAbatedTest.java index d7007bc97..5aa7497e9 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalAbatedTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalAbatedTest.java @@ -38,8 +38,8 @@ public class CanonicalAbatedTest { CanonicalAbated abated2 = new CanonicalAbated(new Abated()); abated2.setRequestId(UUID.randomUUID()); - abated2.setClosedLoopAlarmStart(Instant.now()); - abated2.setClosedLoopAlarmEnd(Instant.now()); + abated2.setClosedLoopAlarmStart(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); + abated2.setClosedLoopAlarmEnd(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); CanonicalAbated abated3 = new CanonicalAbated(abated2); diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalOnsetTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalOnsetTest.java index 7b0a43f9e..23e1fffbd 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalOnsetTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/CanonicalOnsetTest.java @@ -38,8 +38,8 @@ public class CanonicalOnsetTest { CanonicalOnset onset2 = new CanonicalOnset(new Onset()); onset2.setRequestId(UUID.randomUUID()); - onset2.setClosedLoopAlarmStart(Instant.now()); - onset2.setClosedLoopAlarmEnd(Instant.now()); + onset2.setClosedLoopAlarmStart(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); + onset2.setClosedLoopAlarmEnd(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); CanonicalOnset onset3 = new CanonicalOnset(onset2); diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/OnsetTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/OnsetTest.java index b229b024b..5dadff1b6 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/OnsetTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/OnsetTest.java @@ -42,7 +42,7 @@ public class OnsetTest { assertEquals(ControlLoopEventStatus.ONSET, onset.getClosedLoopEventStatus()); assertEquals(event.getClosedLoopAlarmEnd(), onset.getClosedLoopAlarmEnd()); - onset.setClosedLoopAlarmEnd(Instant.now()); + onset.setClosedLoopAlarmEnd(Instant.ofEpochSecond(Instant.now().getEpochSecond() + 1)); assertNotEquals(onset, event); assertEquals(new Onset(onset), onset); -- cgit 1.2.3-korg