diff options
Diffstat (limited to 'main/src/test')
6 files changed, 26 insertions, 36 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java index 8fb7664e..86804425 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,12 +29,12 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.Arrays; import org.junit.AfterClass; 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; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.models.pdp.concepts.PdpResponseDetails; import org.onap.policy.models.pdp.concepts.PdpStateChange; @@ -43,10 +43,10 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager; import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator; +@RunWith(MockitoJUnitRunner.class) public class XacmlStateTest { private static final String PDP_TYPE = "xacml"; private static final String GROUP = "my-group"; @@ -59,9 +59,6 @@ public class XacmlStateTest { @Mock private XacmlPdpActivator act; - private ToscaConceptIdentifier ident1; - private ToscaConceptIdentifier ident2; - private String hostName; private XacmlState state; @@ -71,15 +68,8 @@ public class XacmlStateTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - hostName = NetworkUtil.getHostname(); - ident1 = new ToscaConceptIdentifier("nameA", "typeA"); - ident2 = new ToscaConceptIdentifier("nameB", "typeB"); - - when(appmgr.getToscaPolicyTypeIdents()).thenReturn(Arrays.asList(ident1, ident2)); - XacmlPdpActivator.setCurrent(act); state = new XacmlState(appmgr, GROUP); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java index 550091fa..7f902113 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 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. @@ -39,12 +39,14 @@ import java.util.concurrent.ScheduledFuture; 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; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.pdpx.main.XacmlState; +@RunWith(MockitoJUnitRunner.class) public class XacmlPdpHearbeatPublisherTest { private static final long INTERVAL1 = 1000L; @@ -79,8 +81,6 @@ public class XacmlPdpHearbeatPublisherTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - when(state.genHeartbeat()).thenReturn(status); timers = new LinkedList<>(Arrays.asList(timer1, timer2)); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java index 9f35f530..9f4d80bc 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * 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. @@ -25,12 +25,14 @@ import static org.mockito.Mockito.when; 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; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClientException; import org.onap.policy.models.pdp.concepts.PdpStatus; +@RunWith(MockitoJUnitRunner.class) public class XacmlPdpPapRegistrationTest { @Mock @@ -46,8 +48,6 @@ public class XacmlPdpPapRegistrationTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - when(client.send(status)).thenReturn(true); reg = new XacmlPdpPapRegistration(client); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java index c8c6a816..a4cee50a 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * 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. @@ -21,8 +21,8 @@ package org.onap.policy.pdpx.main.comm; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.startsWith; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.startsWith; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -34,8 +34,9 @@ import java.util.List; import java.util.Map; 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; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; @@ -50,6 +51,7 @@ import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager; /** * Initializes objects, including the publisher. */ +@RunWith(MockitoJUnitRunner.class) public class XacmlPdpUpdatePublisherTest { private static final int NEW_COUNT = 4; @@ -104,8 +106,6 @@ public class XacmlPdpUpdatePublisherTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - Map<ToscaPolicy, XacmlApplicationServiceProvider> deployedPolicies = new HashMap<>(); deployedPolicies.put(deployed1, null); deployedPolicies.put(deployed2, null); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java index a1b7e3e6..dbc065a1 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 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. @@ -27,14 +27,16 @@ import static org.mockito.Mockito.when; 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; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.models.pdp.concepts.PdpStateChange; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.pdpx.main.XacmlState; +@RunWith(MockitoJUnitRunner.class) public class XacmlPdpStateChangeListenerTest { private static final String TOPIC = "my-topic"; @@ -57,8 +59,6 @@ public class XacmlPdpStateChangeListenerTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - listener = new XacmlPdpStateChangeListener(client, state); when(state.shouldHandle(change)).thenReturn(true); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java index 39ba9017..17f71ddd 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 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. @@ -30,8 +30,9 @@ import static org.mockito.Mockito.when; 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; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.models.pdp.concepts.PdpUpdate; @@ -41,6 +42,7 @@ import org.onap.policy.pdpx.main.comm.XacmlPdpUpdatePublisher; import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager; import org.powermock.reflect.Whitebox; +@RunWith(MockitoJUnitRunner.class) public class XacmlPdpUpdateListenerTest { private static final String EXPECTED_EXCEPTION = "expected exception"; private static final String TOPIC = "my-topic"; @@ -70,8 +72,6 @@ public class XacmlPdpUpdateListenerTest { */ @Before public void setUp() { - MockitoAnnotations.initMocks(this); - listener = new MyListener(client, state, heartbeat, appmgr); update = new PdpUpdate(); |