aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml3
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java3
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml3
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java25
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java20
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java8
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java25
7 files changed, 21 insertions, 66 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
index 6dd33237d..14b743884 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
@@ -2,6 +2,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2020 Nordix Foundation.
+ Modifications Copyright (C) 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.
@@ -50,7 +51,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
index 13ecaba6a..31be69e3a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 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,7 +31,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.cds.client.CdsProcessorGrpcClient;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
index f11bd4158..694c32fb0 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
@@ -3,6 +3,7 @@
Copyright (C) 2018 Ericsson. All rights reserved.
Modifications Copyright (C) 2019-2020 Nordix Foundation.
Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ Modifications Copyright (C) 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.
@@ -52,7 +53,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
index 20d6feb5b..545499b40 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
@@ -40,8 +40,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
@@ -73,8 +72,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerErrors() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -105,11 +102,8 @@ public class ApexRestClientConusmerTest {
assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
- Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).get();
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
// We have not set the URL, this test should not receive any events
@@ -118,8 +112,6 @@ public class ApexRestClientConusmerTest {
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
- Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
-
// We have not set the URL, this test should not receive any events
arcc.start();
await().atMost(200, TimeUnit.MILLISECONDS).until(() -> incomingEventReceiver.getEventCount() == 0);
@@ -129,8 +121,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerHttpError() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -156,7 +146,6 @@ public class ApexRestClientConusmerTest {
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -171,8 +160,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerJsonError() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -196,7 +183,6 @@ public class ApexRestClientConusmerTest {
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -212,8 +198,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerJsonEmpty() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -239,7 +223,6 @@ public class ApexRestClientConusmerTest {
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -260,8 +243,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerJsonOk() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -287,7 +268,6 @@ public class ApexRestClientConusmerTest {
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
// We have not set the URL, this test should not receive any events
@@ -299,8 +279,6 @@ public class ApexRestClientConusmerTest {
@Test
public void testApexRestClientConsumerInvalidStatusCode() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -326,7 +304,6 @@ public class ApexRestClientConusmerTest {
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getHttpCodeFilter());
arcc.setClient(httpClientMock);
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
index ac35081f2..85a6214fb 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
@@ -35,8 +35,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
@@ -107,8 +106,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerPutEvent() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -135,8 +132,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerPostEventFail() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -150,11 +145,6 @@ public class ApexRestClientProducerTest {
assertEquals("RestClientConsumer", arcp.getName());
rcctp.setUrl("http://some.place.that.does.not/exist");
- Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
- Mockito.doReturn(builderMock).when(targetMock).request("application/json");
- Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
arcp.setClient(httpClientMock);
// test property not found
@@ -171,8 +161,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerPostEventOK() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -203,8 +191,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerPostEventCache() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -237,8 +223,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerPostEventCacheTrace() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -271,8 +255,6 @@ public class ApexRestClientProducerTest {
@Test
public void testApexRestClientProducerHttpError() throws ApexEventException {
- MockitoAnnotations.initMocks(this);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
index 3efe054ad..08803db41 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 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,11 +31,13 @@ import javax.ws.rs.core.MultivaluedMap;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+@RunWith(MockitoJUnitRunner.class)
public class AccessControlFilterTest {
private AccessControlFilter acf;
@@ -46,7 +49,6 @@ public class AccessControlFilterTest {
@Before
public void beforeEach() {
- MockitoAnnotations.initMocks(this);
acf = new AccessControlFilter();
}
@@ -73,4 +75,4 @@ public class AccessControlFilterTest {
assertEquals(expected, actual);
}
-} \ No newline at end of file
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java
index 2f4764fb5..5abf28ee6 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 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,15 +22,16 @@ package org.onap.policy.apex.service.engine.event.impl.eventrequestor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import java.util.Random;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Matchers;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventProducer;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
@@ -39,6 +41,7 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+@RunWith(MockitoJUnitRunner.class)
public class EventRequestorProducerTest {
private final Random random = new Random();
private EventRequestorProducer producer;
@@ -50,7 +53,6 @@ public class EventRequestorProducerTest {
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
producer = new EventRequestorProducer();
}
@@ -122,18 +124,13 @@ public class EventRequestorProducerTest {
@Test
public void sendEvent() {
final int id = random.nextInt(1000);
- // Prepare mocks
- final PeeredReference peeredReference = Mockito.mock(PeeredReference.class);
-
- Mockito.when(apexConsumer.getPeeredReference(Matchers.any())).thenReturn(peeredReference);
- Mockito.when(peeredReference.getPeeredConsumer()).thenReturn(apexConsumer);
final PeeredReference reference =
new PeeredReference(EventHandlerPeeredMode.REQUESTOR, apexConsumer, apexProducer);
producer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, reference);
producer.sendEvent(id, null, null, null);
- Mockito.verify(apexConsumer, Mockito.times(1)).processEvent(Matchers.any());
+ Mockito.verify(apexConsumer, Mockito.times(1)).processEvent(any());
}
@Test
@@ -144,18 +141,12 @@ public class EventRequestorProducerTest {
final SynchronousEventCache eventCache = Mockito.mock(SynchronousEventCache.class);
producer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, eventCache);
- // Prepare other mocks
- final PeeredReference peeredReference = Mockito.mock(PeeredReference.class);
-
- Mockito.when(peeredReference.getPeeredConsumer()).thenReturn(apexConsumer);
- Mockito.when(apexConsumer.getPeeredReference(Matchers.any())).thenReturn(peeredReference);
-
final PeeredReference reference =
new PeeredReference(EventHandlerPeeredMode.REQUESTOR, apexConsumer, apexProducer);
producer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, reference);
producer.sendEvent(id, null, null, null);
- Mockito.verify(apexConsumer, Mockito.times(1)).processEvent(Matchers.any());
+ Mockito.verify(apexConsumer, Mockito.times(1)).processEvent(any());
Mockito.verify(eventCache, Mockito.times(1)).removeCachedEventToApexIfExists(id);
}
-} \ No newline at end of file
+}