aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-27 11:14:36 -0400
committerJim Hahn <jrh3@att.com>2021-08-27 12:42:29 -0400
commit18c8028c79d1bdd7bca80fe1e22e2cd9bc072695 (patch)
tree14441d6b1b4b5e50022153ac534e4783cd875aeb /services/services-engine/src/test/java/org
parenta90a763fa3c9260c3a5e08440ec99e4438852e77 (diff)
Address eclipse warnings in apex-pdp
Fixed: - deprecated mockito methods - unused mocks Issue-ID: POLICY-3093 Change-Id: I20d9aebb2a6390b2a3c95ae9ccc59b710b9e58ce Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'services/services-engine/src/test/java/org')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducerTest.java25
1 files changed, 8 insertions, 17 deletions
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
+}