diff options
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners')
3 files changed, 27 insertions, 31 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java index 1c5a175d..e4c84f3a 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java @@ -1,4 +1,4 @@ -/* +/*-- * ============LICENSE_START======================================================= * ONAP * ================================================================================ @@ -37,8 +37,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; -import org.onap.policy.common.endpoints.listeners.ScoListener; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java index 94717e53..d71d413e 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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. @@ -23,7 +23,6 @@ package org.onap.policy.common.endpoints.listeners; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -119,16 +118,16 @@ public class RequestIdDispatcherTest { // should process message that does not have a request id status = new MyMessage(); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1).onTopicEvent(INFRA, TOPIC, status); // should process again primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, times(2)).onTopicEvent(INFRA, TOPIC, status); // should NOT process a message that has a request id status = new MyMessage(REQID1); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status); } @Test @@ -138,21 +137,21 @@ public class RequestIdDispatcherTest { // should NOT process message that does not have a request id status = new MyMessage(); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status); // should process a message that has the desired request id status = new MyMessage(REQID1); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1).onTopicEvent(INFRA, TOPIC, status); // should process again primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, times(2)).onTopicEvent(INFRA, TOPIC, status); // should NOT process a message that does NOT have the desired request id status = new MyMessage(REQID2); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status); // null request id => exception assertThatIllegalArgumentException().isThrownBy(() -> primary.register(null, secondary1)); @@ -169,17 +168,17 @@ public class RequestIdDispatcherTest { // should process message status = new MyMessage(); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary2).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1).onTopicEvent(INFRA, TOPIC, status); + verify(secondary2).onTopicEvent(INFRA, TOPIC, status); primary.unregister(secondary1); // should NOT process again primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, times(1)).onTopicEvent(INFRA, TOPIC, status); // other listener should still have processed it - verify(secondary2, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary2, times(2)).onTopicEvent(INFRA, TOPIC, status); } @Test @@ -190,18 +189,18 @@ public class RequestIdDispatcherTest { // should process a message that has the desired request id status = new MyMessage(REQID1); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1).onTopicEvent(INFRA, TOPIC, status); primary.unregister(REQID1); // should NOT re-process primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, times(1)).onTopicEvent(INFRA, TOPIC, status); // secondary should still be able to process status = new MyMessage(REQID2); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary2).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary2).onTopicEvent(INFRA, TOPIC, status); } @Test @@ -214,18 +213,18 @@ public class RequestIdDispatcherTest { // without request id status = new MyMessage(); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary2, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary3).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary4).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status); + verify(secondary2, never()).onTopicEvent(INFRA, TOPIC, status); + verify(secondary3).onTopicEvent(INFRA, TOPIC, status); + verify(secondary4).onTopicEvent(INFRA, TOPIC, status); // with request id status = new MyMessage(REQID1); primary.onTopicEvent(INFRA, TOPIC, makeSco(status)); - verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary2, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary3, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); - verify(secondary4, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status)); + verify(secondary1).onTopicEvent(INFRA, TOPIC, status); + verify(secondary2, never()).onTopicEvent(INFRA, TOPIC, status); + verify(secondary3, never()).onTopicEvent(INFRA, TOPIC, status); + verify(secondary4, never()).onTopicEvent(INFRA, TOPIC, status); } @Test diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java index 8543b73e..a782e4b2 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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. @@ -22,7 +22,6 @@ package org.onap.policy.common.endpoints.listeners; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -111,14 +110,14 @@ public class ScoListenerTest { status = new MyMessage(NAME); sco = makeSco(status); primary.onTopicEvent(INFRA, TOPIC, sco); - verify(primary).onTopicEvent(eq(INFRA), eq(TOPIC), eq(sco), eq(status)); + verify(primary).onTopicEvent(INFRA, TOPIC, sco, status); assertFalse(appender.getExtracted().toString().contains("unable to decode")); // undecodable message logger.addAppender(appender); primary.onTopicEvent(INFRA, TOPIC, makeSco("[]")); - verify(primary, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(sco), eq(status)); + verify(primary, times(1)).onTopicEvent(INFRA, TOPIC, sco, status); assertTrue(appender.getExtracted().toString().contains("unable to decode")); } |