diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-11-04 10:17:03 +0000 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2024-11-07 10:17:37 +0000 |
commit | cd9cbc8d353e24bfff76049e187bd5f2216bf71d (patch) | |
tree | 854465a7f91612f05f863bcaa1fc2e80bb538f8e /models-interactions/model-actors/actorServiceProvider/src | |
parent | d8c2934b30d287011f95300bc5516f0df9dedfa9 (diff) |
Fix references and organize dependencies after splitting
policy-endpoints and message-bus
Issue-ID: POLICY-5131
Change-Id: I7542caaccc130bc6120cc105d31a1e1e951c8cff
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src')
12 files changed, 126 insertions, 126 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActor.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActor.java index 564bbc346..689622d60 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActor.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActor.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +25,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException; +import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClientException; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicActorParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java index 8f2199f05..7b87e2534 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +25,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import lombok.Getter; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java index 1e11bce4c..90dfdb91b 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,10 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.function.Function; import lombok.Getter; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.http.client.HttpClient; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java index c19ad6c31..90ac49cb4 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +43,9 @@ import java.util.function.UnaryOperator; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandler.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandler.java index 30ee1e2d0..6ee9059e0 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandler.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandler.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +22,8 @@ package org.onap.policy.controlloop.actorserviceprovider.topic; import java.util.List; -import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClient; -import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException; +import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClient; +import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClientException; /** * Handler for a bidirectional topic, supporting both publishing and forwarding of diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImpl.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImpl.java index 93beab1cb..95b0ab7ed 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImpl.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImpl.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; @@ -33,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A topic listener. When a message arrives on a topic, it is forwarded to listeners based + * A topic listener. When a message arrives at a topic, it is forwarded to listeners based * on the content of fields found within the message. However, depending on the message * type, the relevant fields might be found in different places within the message's * object hierarchy. For each different list of keys, this class maintains a diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java index 7e4543eca..8f0b42baf 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java @@ -42,8 +42,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException; +import org.onap.policy.common.message.bus.event.TopicEndpointManager; +import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClientException; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicActorParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException; diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java index 67283f5d4..bb2d7f9a0 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java @@ -35,7 +35,6 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -51,7 +50,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -142,7 +141,7 @@ class BidirectionalTopicOperationTest { CompletableFuture<OperationOutcome> future = oper.startOperationAsync(1, outcome); assertFalse(future.isDone()); - verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture()); + verify(forwarder).register(eq(List.of(REQ_ID)), listenerCaptor.capture()); verify(forwarder, never()).unregister(any(), any()); @@ -167,7 +166,7 @@ class BidirectionalTopicOperationTest { assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(response, outcome.getResponse()); - verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue()); + verify(forwarder).unregister(List.of(REQ_ID), listenerCaptor.getValue()); } /** @@ -186,7 +185,7 @@ class BidirectionalTopicOperationTest { CompletableFuture<OperationOutcome> future = oper.startOperationAsync(1, outcome); assertFalse(future.isDone()); - verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture()); + verify(forwarder).register(eq(List.of(REQ_ID)), listenerCaptor.capture()); verify(forwarder, never()).unregister(any(), any()); @@ -195,7 +194,7 @@ class BidirectionalTopicOperationTest { assertTrue(executor.runAll(MAX_REQUESTS)); assertTrue(future.isCompletedExceptionally()); - verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue()); + verify(forwarder).unregister(List.of(REQ_ID), listenerCaptor.getValue()); } /** @@ -208,10 +207,10 @@ class BidirectionalTopicOperationTest { assertThatIllegalStateException().isThrownBy(() -> oper.startOperationAsync(1, outcome)); - verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture()); + verify(forwarder).register(eq(List.of(REQ_ID)), listenerCaptor.capture()); // must still unregister - verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue()); + verify(forwarder).unregister(List.of(REQ_ID), listenerCaptor.getValue()); } @Test @@ -360,7 +359,7 @@ class BidirectionalTopicOperationTest { } - private class MyStringOperation extends BidirectionalTopicOperation<String, String> { + private static class MyStringOperation extends BidirectionalTopicOperation<String, String> { MyStringOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) { super(params, config, String.class, Collections.emptyList()); @@ -373,7 +372,7 @@ class BidirectionalTopicOperationTest { @Override protected List<String> getExpectedKeyValues(int attempt, String request) { - return Arrays.asList(REQ_ID); + return List.of(REQ_ID); } @Override @@ -383,7 +382,7 @@ class BidirectionalTopicOperationTest { } - private class MyScoOperation extends BidirectionalTopicOperation<MyRequest, StandardCoderObject> { + private static class MyScoOperation extends BidirectionalTopicOperation<MyRequest, StandardCoderObject> { MyScoOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) { super(params, config, StandardCoderObject.class, Collections.emptyList()); } @@ -395,7 +394,7 @@ class BidirectionalTopicOperationTest { @Override protected List<String> getExpectedKeyValues(int attempt, MyRequest request) { - return Arrays.asList(REQ_ID); + return List.of(REQ_ID); } @Override @@ -417,7 +416,7 @@ class BidirectionalTopicOperationTest { @Override protected List<String> getExpectedKeyValues(int attempt, MyRequest request) { - return Arrays.asList(REQ_ID); + return List.of(REQ_ID); } @Override diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java index 8e1a8783a..c64903d5e 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java @@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -68,18 +69,17 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientFactory; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams.TopicParamsBuilder; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; @@ -122,8 +122,8 @@ class HttpOperationTest { @Mock private Executor executor; - private ControlLoopOperationParams params; - private OperationOutcome outcome; + private ControlLoopOperationParams operationParams; + private OperationOutcome operationOutcome; private AtomicReference<InvocationCallback<Response>> callback; private Future<Response> future; private HttpConfig config; @@ -133,7 +133,7 @@ class HttpOperationTest { * Starts the simulator. */ @BeforeAll - void setUpBeforeClass() throws Exception { + void setUpBeforeClass() throws Exception { // allocate a port int port = NetworkUtil.allocPort(); @@ -141,7 +141,7 @@ class HttpOperationTest { * Start the simulator. Must use "Properties" to configure it, otherwise the * server will use the wrong serialization provider. */ - Properties svrprops = getServerProperties("my-server", port); + Properties svrprops = getServerProperties(port); HttpServletServerFactoryInstance.getServerFactory().build(svrprops).forEach(HttpServletServer::start); if (!NetworkUtil.isTcpPortOpen("localhost", port, 100, 100)) { @@ -157,14 +157,14 @@ class HttpOperationTest { HttpClientFactoryInstance.getClientFactory().build(builder.clientName(HTTP_CLIENT).port(port).build()); HttpClientFactoryInstance.getClientFactory() - .build(builder.clientName(HTTP_NO_SERVER).port(NetworkUtil.allocPort()).build()); + .build(builder.clientName(HTTP_NO_SERVER).port(NetworkUtil.allocPort()).build()); } /** * Destroys the Http factories and stops the appender. */ @AfterAll - static void tearDownAfterClass() { + static void tearDownAfterClass() { HttpClientFactoryInstance.getClientFactory().destroy(); HttpServletServerFactoryInstance.getServerFactory().destroy(); } @@ -174,7 +174,7 @@ class HttpOperationTest { * the REST server. */ @BeforeEach - void setUp() { + void setUp() { rejectRequest = false; nget = 0; npost = 0; @@ -184,41 +184,42 @@ class HttpOperationTest { Mockito.lenient().when(response.readEntity(String.class)).thenReturn(TEXT); Mockito.lenient().when(response.getStatus()).thenReturn(200); - params = ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).requestId(REQ_ID).build(); + operationParams = ControlLoopOperationParams.builder().actor(ACTOR) + .operation(OPERATION).requestId(REQ_ID).build(); - outcome = params.makeOutcome(); + operationOutcome = operationParams.makeOutcome(); callback = new AtomicReference<>(); future = new CompletableFuture<>(); Mockito.lenient().when(clientFactory.get(any())).thenReturn(client); - initConfig(HTTP_CLIENT); + initConfig(); oper = new MyGetOperation<>(String.class); } @Test - void testHttpOperator() { + void testHttpOperator() { assertEquals(ACTOR, oper.getActorName()); assertEquals(OPERATION, oper.getName()); assertEquals(ACTOR + "." + OPERATION, oper.getFullName()); } @Test - void testMakeHeaders() { + void testMakeHeaders() { assertEquals(Collections.emptyMap(), oper.makeHeaders()); } @Test - void testGetPath() { + void testGetPath() { assertEquals(PATH, oper.getPath()); } @Test - void testMakeUrl() { + void testMakeUrl() { // use a real client - initRealConfig(HTTP_CLIENT); + initRealConfig(); oper = new MyGetOperation<>(String.class); @@ -226,7 +227,7 @@ class HttpOperationTest { } @Test - void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() { + void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() { // use value from operator assertEquals(1000L, oper.getTimeoutMs(null)); @@ -240,8 +241,8 @@ class HttpOperationTest { * Tests handleResponse() when it completes. */ @Test - void testHandleResponseComplete() throws Exception { - CompletableFuture<OperationOutcome> future2 = oper.handleResponse(outcome, PATH, cb -> { + void testHandleResponseComplete() throws Exception { + CompletableFuture<OperationOutcome> future2 = oper.handleResponse(operationOutcome, PATH, cb -> { callback.set(cb); return future; }); @@ -250,18 +251,18 @@ class HttpOperationTest { assertNotNull(callback.get()); callback.get().completed(response); - assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); - assertSame(TEXT, outcome.getResponse()); + assertSame(operationOutcome, future2.get(5, TimeUnit.SECONDS)); + assertSame(TEXT, operationOutcome.getResponse()); - assertEquals(OperationResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, operationOutcome.getResult()); } /** * Tests handleResponse() when it fails. */ @Test - void testHandleResponseFailed() { - CompletableFuture<OperationOutcome> future2 = oper.handleResponse(outcome, PATH, cb -> { + void testHandleResponseFailed() { + CompletableFuture<OperationOutcome> future2 = oper.handleResponse(operationOutcome, PATH, cb -> { callback.set(cb); return future; }); @@ -282,11 +283,11 @@ class HttpOperationTest { */ @Test void testProcessResponseSuccessString() throws Exception { - CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response); + CompletableFuture<OperationOutcome> result = oper.processResponse(operationOutcome, PATH, response); assertTrue(result.isDone()); - assertSame(outcome, result.get()); - assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertSame(TEXT, outcome.getResponse()); + assertSame(operationOutcome, result.get()); + assertEquals(OperationResult.SUCCESS, operationOutcome.getResult()); + assertSame(TEXT, operationOutcome.getResponse()); } /** @@ -295,11 +296,11 @@ class HttpOperationTest { @Test void testProcessResponseFailure() throws Exception { when(response.getStatus()).thenReturn(555); - CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response); + CompletableFuture<OperationOutcome> result = oper.processResponse(operationOutcome, PATH, response); assertTrue(result.isDone()); - assertSame(outcome, result.get()); - assertEquals(OperationResult.FAILURE, outcome.getResult()); - assertSame(TEXT, outcome.getResponse()); + assertSame(operationOutcome, result.get()); + assertEquals(OperationResult.FAILURE, operationOutcome.getResult()); + assertSame(TEXT, operationOutcome.getResponse()); } /** @@ -311,11 +312,11 @@ class HttpOperationTest { MyGetOperation<Integer> oper2 = new MyGetOperation<>(Integer.class); - CompletableFuture<OperationOutcome> result = oper2.processResponse(outcome, PATH, response); + CompletableFuture<OperationOutcome> result = oper2.processResponse(operationOutcome, PATH, response); assertTrue(result.isDone()); - assertSame(outcome, result.get()); - assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertEquals(Integer.valueOf(10), outcome.getResponse()); + assertSame(operationOutcome, result.get()); + assertEquals(OperationResult.SUCCESS, operationOutcome.getResult()); + assertEquals(Integer.valueOf(10), operationOutcome.getResponse()); } /** @@ -325,12 +326,12 @@ class HttpOperationTest { void testProcessResponseDecodeExcept() { MyGetOperation<Integer> oper2 = new MyGetOperation<>(Integer.class); - assertThatIllegalArgumentException().isThrownBy(() -> oper2.processResponse(outcome, PATH, response)); + assertThatIllegalArgumentException().isThrownBy(() -> oper2.processResponse(operationOutcome, PATH, response)); } @Test void testPostProcessResponse() { - assertThatCode(() -> oper.postProcessResponse(outcome, PATH, null, null)).doesNotThrowAnyException(); + assertThatCode(() -> oper.postProcessResponse(operationOutcome, PATH, null, null)).doesNotThrowAnyException(); } @Test @@ -348,7 +349,7 @@ class HttpOperationTest { @Test void testGet() throws Exception { // use a real client - initRealConfig(HTTP_CLIENT); + initRealConfig(); MyGetOperation<MyResponse> oper2 = new MyGetOperation<>(MyResponse.class); @@ -356,7 +357,7 @@ class HttpOperationTest { assertNotNull(outcome); assertEquals(1, nget); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof MyResponse); + assertInstanceOf(MyResponse.class, outcome.getResponse()); } /** @@ -365,7 +366,7 @@ class HttpOperationTest { @Test void testDelete() throws Exception { // use a real client - initRealConfig(HTTP_CLIENT); + initRealConfig(); MyDeleteOperation oper2 = new MyDeleteOperation(); @@ -373,7 +374,7 @@ class HttpOperationTest { assertNotNull(outcome); assertEquals(1, ndelete); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof String); + assertInstanceOf(String.class, outcome.getResponse()); } /** @@ -382,14 +383,14 @@ class HttpOperationTest { @Test void testPost() throws Exception { // use a real client - initRealConfig(HTTP_CLIENT); + initRealConfig(); MyPostOperation oper2 = new MyPostOperation(); OperationOutcome outcome = runOperation(oper2); assertNotNull(outcome); assertEquals(1, npost); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof MyResponse); + assertInstanceOf(MyResponse.class, outcome.getResponse()); } /** @@ -398,7 +399,7 @@ class HttpOperationTest { @Test void testPut() throws Exception { // use a real client - initRealConfig(HTTP_CLIENT); + initRealConfig(); MyPutOperation oper2 = new MyPutOperation(); @@ -406,7 +407,7 @@ class HttpOperationTest { assertNotNull(outcome); assertEquals(1, nput); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof MyResponse); + assertInstanceOf(MyResponse.class, outcome.getResponse()); } @Test @@ -417,15 +418,14 @@ class HttpOperationTest { /** * Gets server properties. * - * @param name server name * @param port server port * @return server properties */ - private static Properties getServerProperties(String name, int port) { + private static Properties getServerProperties(int port) { final Properties props = new Properties(); - props.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, name); + props.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, "my-server"); - final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + name; + final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "my-server"; props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX, Server.class.getName()); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, "localhost"); @@ -434,51 +434,45 @@ class HttpOperationTest { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SWAGGER_SUFFIX, "false"); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER, - GsonMessageBodyHandler.class.getName()); + GsonMessageBodyHandler.class.getName()); return props; } /** * Initializes the configuration. - * - * @param clientName name of the client which it should use */ - private void initConfig(String clientName) { - initConfig(clientName, clientFactory); + private void initConfig() { + initConfig(clientFactory); } /** * Initializes the configuration with a real client. - * - * @param clientName name of the client which it should use */ - private void initConfig(String clientName, HttpClientFactory factory) { - HttpParams params = HttpParams.builder().clientName(clientName).path(PATH).timeoutSec(1).build(); + private void initConfig(HttpClientFactory factory) { + HttpParams params = HttpParams.builder().clientName(HttpOperationTest.HTTP_CLIENT) + .path(PATH).timeoutSec(1).build(); config = new HttpConfig(executor, params, factory); } /** * Initializes the configuration with a real client. - * - * @param clientName name of the client which it should use */ - private void initRealConfig(String clientName) { - initConfig(clientName, HttpClientFactoryInstance.getClientFactory()); + private void initRealConfig() { + initConfig(HttpClientFactoryInstance.getClientFactory()); } /** * Runs the operation. * * @param operator operator on which to start the operation - * @return the outcome of the operation, or {@code null} if it does not complete in - * time + * @return the outcome of the operation, or {@code null} if it does not complete in time */ private <T> OperationOutcome runOperation(HttpOperation<T> operator) - throws InterruptedException, ExecutionException, TimeoutException { + throws InterruptedException, ExecutionException, TimeoutException { - CompletableFuture<OperationOutcome> future = operator.start(); + CompletableFuture<OperationOutcome> completableFuture = operator.start(); - return future.get(5, TimeUnit.SECONDS); + return completableFuture.get(5, TimeUnit.SECONDS); } @Getter @@ -495,7 +489,8 @@ class HttpOperationTest { private class MyGetOperation<T> extends HttpOperation<T> { MyGetOperation(Class<T> responseClass) { - super(HttpOperationTest.this.params, HttpOperationTest.this.config, responseClass, Collections.emptyList()); + super(HttpOperationTest.this.operationParams, HttpOperationTest.this.config, + responseClass, Collections.emptyList()); } @Override @@ -509,15 +504,15 @@ class HttpOperationTest { // @formatter:off return handleResponse(outcome, url, - callback -> getClient().get(callback, getPath(), headers)); + invocationCallback -> getClient().get(invocationCallback, getPath(), headers)); // @formatter:on } } private class MyPostOperation extends HttpOperation<MyResponse> { MyPostOperation() { - super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class, - Collections.emptyList()); + super(HttpOperationTest.this.operationParams, HttpOperationTest.this.config, MyResponse.class, + Collections.emptyList()); } @Override @@ -537,15 +532,15 @@ class HttpOperationTest { // @formatter:off return handleResponse(outcome, url, - callback -> getClient().post(callback, getPath(), entity, headers)); + invocationCallback -> getClient().post(invocationCallback, getPath(), entity, headers)); // @formatter:on } } private class MyPutOperation extends HttpOperation<MyResponse> { MyPutOperation() { - super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class, - Collections.emptyList()); + super(HttpOperationTest.this.operationParams, HttpOperationTest.this.config, MyResponse.class, + Collections.emptyList()); } @Override @@ -565,14 +560,15 @@ class HttpOperationTest { // @formatter:off return handleResponse(outcome, url, - callback -> getClient().put(callback, getPath(), entity, headers)); + invocationCallback -> getClient().put(invocationCallback, getPath(), entity, headers)); // @formatter:on } } private class MyDeleteOperation extends HttpOperation<String> { MyDeleteOperation() { - super(HttpOperationTest.this.params, HttpOperationTest.this.config, String.class, Collections.emptyList()); + super(HttpOperationTest.this.operationParams, HttpOperationTest.this.config, + String.class, Collections.emptyList()); } @Override @@ -586,7 +582,7 @@ class HttpOperationTest { // @formatter:off return handleResponse(outcome, url, - callback -> getClient().delete(callback, getPath(), headers)); + invocationCallback -> getClient().delete(invocationCallback, getPath(), headers)); // @formatter:on } } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java index d2ca7dbc6..04300c4d9 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java @@ -60,8 +60,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -1063,9 +1063,7 @@ class OperationPartialTest { * @param expectedCallbacks number of callbacks expected * @param expectedOperations number of operation invocations expected * @param expectedResult expected outcome - * @param manipulator function to modify the future returned by - * {@link OperationPartial#start(ControlLoopOperationParams)} before the tasks - * in the executor are run + * @param manipulator function to modify the future returned before the tasks in the executor are run */ private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, OperationResult expectedResult, Consumer<CompletableFuture<OperationOutcome>> manipulator) { diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java index 862e6c49d..dcf190bbb 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java @@ -31,17 +31,18 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -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.TopicSink; -import org.onap.policy.common.endpoints.event.comm.TopicSource; -import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicEndpoint; +import org.onap.policy.common.message.bus.event.TopicSink; +import org.onap.policy.common.message.bus.event.TopicSource; +import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClientException; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ExtendWith(MockitoExtension.class) @@ -69,8 +70,8 @@ class BidirectionalTopicHandlerTest { */ @BeforeEach void setUp() throws BidirectionalTopicClientException { - when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher)); - when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber)); + when(mgr.getTopicSinks(MY_SINK)).thenReturn(List.of(publisher)); + when(mgr.getTopicSources(List.of(MY_SOURCE))).thenReturn(List.of(subscriber)); when(publisher.getTopicCommInfrastructure()).thenReturn(CommInfrastructure.NOOP); diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java index 3044a1e44..8ca49db84 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java @@ -30,6 +30,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import org.junit.jupiter.api.BeforeEach; @@ -38,7 +39,7 @@ import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; @@ -86,8 +87,8 @@ class TopicListenerImplTest { assertNotNull(forwarder2); assertNotSame(forwarder1, forwarder2); - forwarder1.register(Arrays.asList(VALUEA_REQID), listener1); - forwarder1.register(Arrays.asList(VALUEB_REQID), listener1b); + forwarder1.register(List.of(VALUEA_REQID), listener1); + forwarder1.register(List.of(VALUEB_REQID), listener1b); forwarder2.register(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener2); } |