X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=models-interactions%2Fmodel-actors%2FactorServiceProvider%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontrolloop%2Factorserviceprovider%2Fimpl%2FHttpPollingOperationTest.java;h=2f7976ce5434e3fef0b1cca23cff077678886b85;hb=refs%2Fchanges%2F05%2F136005%2F1;hp=ed5ba9b564f20be18cadadd2a4feccf63bf96ded;hpb=860a08ffb33bc0ae37e87c7d76ac6633f3ad3bee;p=policy%2Fmodels.git diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java index ed5ba9b56..2f7976ce5 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 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,26 +32,29 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import jakarta.ws.rs.client.InvocationCallback; +import jakarta.ws.rs.core.Response; +import java.util.Collections; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.InvocationCallback; -import javax.ws.rs.core.Response; 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.mockito.stubbing.Answer; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; -import org.onap.policy.controlloop.policy.PolicyResult; /** * Tests HttpOperation when polling is enabled. */ +@RunWith(MockitoJUnitRunner.class) public class HttpPollingOperationTest { private static final String BASE_URI = "http://my-host:6969/base-uri/"; private static final String MY_PATH = "my-path"; @@ -83,12 +87,9 @@ public class HttpPollingOperationTest { */ @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(client.getBaseUrl()).thenReturn(BASE_URI); when(config.getClient()).thenReturn(client); - when(config.getPath()).thenReturn(MY_PATH); when(config.getMaxPolls()).thenReturn(MAX_POLLS); when(config.getPollPath()).thenReturn(POLL_PATH); when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC); @@ -119,8 +120,6 @@ public class HttpPollingOperationTest { // should throw an exception if we pass a plain HttpConfig HttpConfig config2 = mock(HttpConfig.class); - when(config2.getClient()).thenReturn(client); - when(config2.getPath()).thenReturn(MY_PATH); assertThatIllegalStateException().isThrownBy(() -> new MyOper(params, config2).setUsePolling()); } @@ -133,7 +132,7 @@ public class HttpPollingOperationTest { oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNotNull(oper.getSubRequestId()); assertSame(response, outcome.getResponse()); @@ -143,7 +142,7 @@ public class HttpPollingOperationTest { future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertNotNull(oper.getSubRequestId()); assertSame(response, outcome.getResponse()); } @@ -174,7 +173,7 @@ public class HttpPollingOperationTest { oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(2, oper.getPollCount()); /* @@ -185,7 +184,7 @@ public class HttpPollingOperationTest { future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); - assertEquals(PolicyResult.FAILURE_TIMEOUT, outcome.getResult()); + assertEquals(OperationResult.FAILURE_TIMEOUT, outcome.getResult()); assertEquals(MAX_POLLS + 1, oper.getPollCount()); oper.resetPollCount(); @@ -196,7 +195,7 @@ public class HttpPollingOperationTest { @Test public void testDetmStatus() { // make an operation that does NOT override detmStatus() - oper = new HttpOperation(params, config, String.class) {}; + oper = new HttpOperation(params, config, String.class, Collections.emptyList()) {}; assertThatThrownBy(() -> oper.detmStatus(rawResponse, response)) .isInstanceOf(UnsupportedOperationException.class); @@ -230,7 +229,7 @@ public class HttpPollingOperationTest { private static class MyOper extends HttpOperation { public MyOper(ControlLoopOperationParams params, HttpConfig config) { - super(params, config, String.class); + super(params, config, String.class, Collections.emptyList()); setUsePolling(); }