Fix sonars from depeendency upgrade 63/117763/1
authorJim Hahn <jrh3@att.com>
Thu, 11 Feb 2021 21:13:32 +0000 (16:13 -0500)
committerJim Hahn <jrh3@att.com>
Thu, 11 Feb 2021 21:15:51 +0000 (16:15 -0500)
The dependency upgrades in policy-parent caused some new sonars.  In
particular, initMocks() has been deprecated - replaced with calls to the
Mockito Runner.

Issue-ID: POLICY-2914
Change-Id: Iaf10f676c380adb9785e836cb15792596b378e4e
Signed-off-by: Jim Hahn <jrh3@att.com>
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java
utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledFutureTest.java

index ffa7c5a..cfb65e1 100644 (file)
@@ -37,8 +37,9 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
@@ -46,6 +47,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicListener;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicClientTest {
     private static final String SINK_TOPIC = "my-sink-topic";
     private static final String SOURCE_TOPIC = "my-source-topic";
@@ -90,8 +92,6 @@ public class BidirectionalTopicClientTest {
      */
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
         when(sink.send(anyString())).thenReturn(true);
         when(sink.getTopicCommInfrastructure()).thenReturn(SINK_INFRA);
 
index e23bbd2..248edf6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,9 +31,11 @@ import java.util.concurrent.Delayed;
 import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 
+@RunWith(MockitoJUnitRunner.class)
 public class PseudoScheduledFutureTest {
     private static final long DELAY_MS = 1000L;
 
@@ -49,8 +51,6 @@ public class PseudoScheduledFutureTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(work.getDelay()).thenReturn(DELAY_MS);
 
         count = 0;