Java 17 Upgrade
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / impl / HttpPollingOperationTest.java
index 7809646..2f7976c 100644 (file)
@@ -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,27 +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";
@@ -84,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);
@@ -120,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());
     }
@@ -134,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());
 
@@ -144,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());
     }
@@ -175,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());
 
         /*
@@ -186,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();