Refactor MockServer dependencies 30/142630/3
authorwaynedunican <wayne.dunican@est.tech>
Wed, 3 Dec 2025 09:41:39 +0000 (09:41 +0000)
committerWayne Dunican <wayne.dunican@est.tech>
Wed, 3 Dec 2025 13:21:56 +0000 (13:21 +0000)
Removed MockServer and MockRestEndpoint classes

Removed policy-common dependencies
- org.onap.policy.common.endpoints.http.server.*
- org.onap.policy.common.utils.network.NetworkUtil
- org.onap.policy.common.gson.GsonMessageBodyHandler

Issue-ID: POLICY-5506
Change-Id: I833dcfdc491d113a0bdfad904c3fff1ec3ffc7d7
Signed-off-by: waynedunican <wayne.dunican@est.tech>
participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockRestEndpoint.java [deleted file]
participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockServerRest.java [deleted file]
participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/webclient/AcA1PmsClientTest.java
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockRestEndpoint.java [deleted file]
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockServerRest.java [deleted file]
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java [deleted file]
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockServer.java [deleted file]
participant/participant-impl/pom.xml

diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockRestEndpoint.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockRestEndpoint.java
deleted file mode 100644 (file)
index bbbc5ab..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.a1pms.utils;
-
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Response;
-
-/**
- * The Class MockRestEndpoint creates rest server endpoints for simulating Rest calls.
- */
-@Path("/")
-@Produces("application/json")
-public class MockRestEndpoint {
-
-    /**
-     * Get dummy health endpoint.
-     *
-     * @return the response
-     */
-    @Path("/healthy")
-    @GET
-    public Response getApplicationHealthy() {
-        return Response.status(200).entity("{}").build();
-    }
-
-    /**
-     * Get dummy health endpoint.
-     *
-     * @return the response
-     */
-    @Path("/unhealthy")
-    @GET
-    public Response getApplicationUnHealthy() {
-        return Response.status(500).entity("{}").build();
-    }
-
-    @Path("/services/success")
-    @PUT
-    public Response createServiceSuccess() {
-        return Response.status(200).entity("{}").build();
-    }
-
-    @Path("/services/failure")
-    @PUT
-    public Response createServiceFailure() {
-        return Response.status(500).entity("{}").build();
-    }
-
-    @Path("/service/success/{clientId}")
-    @DELETE
-    public Response deleteServiceSuccess(@PathParam("clientId") String clientId) {
-        return Response.status(204).entity("{}").build();
-    }
-
-    @Path("/service/failure/{clientId}")
-    @DELETE
-    public Response deleteServiceFailure(@PathParam("clientId") String clientId) {
-        return Response.status(500).entity("{}").build();
-    }
-}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockServerRest.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/MockServerRest.java
deleted file mode 100644 (file)
index eca42fe..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022-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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.a1pms.utils;
-
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-/**
- * The Class MockServerRest that manages test servers for REST requests for the test.
- */
-public class MockServerRest implements AutoCloseable {
-    private static final String HOST = "localhost";
-    private HttpServletServer restServer;
-    private int restServerPort = 0;
-
-    /**
-     * Instantiates a new REST simulator.
-     */
-    public MockServerRest(int restServerPort) {
-        this.restServerPort = restServerPort;
-        restServer = HttpServletServerFactoryInstance.getServerFactory().build("MockRestEndpoint", false, HOST,
-                restServerPort, false, "/", false, false);
-        restServer.addServletClass(null, MockRestEndpoint.class.getName());
-        restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName());
-        restServer.start();
-    }
-
-    /**
-     * Validate the Rest server.
-     * @throws InterruptedException if is not alive
-     */
-    public void validate() throws InterruptedException {
-        if (!NetworkUtil.isTcpPortOpen(HOST, restServerPort, 50, 200L)) {
-            throw new IllegalStateException("port " + restServerPort + " is still not in use");
-        }
-    }
-
-    @Override
-    public void close() throws Exception {
-        if (restServer != null) {
-            restServer.stop();
-            restServer = null;
-        }
-    }
-}
index 0c4eabc..45ef494 100644 (file)
@@ -27,6 +27,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
+import okhttp3.mockwebserver.Dispatcher;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.jetbrains.annotations.NotNull;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -34,8 +39,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.onap.policy.clamp.acm.participant.a1pms.parameters.A1PmsParameters;
 import org.onap.policy.clamp.acm.participant.a1pms.utils.CommonTestData;
-import org.onap.policy.clamp.acm.participant.a1pms.utils.MockServerRest;
-import org.onap.policy.common.utils.network.NetworkUtil;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 @ExtendWith(SpringExtension.class)
@@ -43,7 +46,7 @@ class AcA1PmsClientTest {
 
     private static int mockServerPort;
 
-    private static MockServerRest mockServer;
+    private static MockWebServer mockServer;
 
     private static CommonTestData commonTestData;
 
@@ -61,10 +64,47 @@ class AcA1PmsClientTest {
      * Set up Mock server.
      */
     @BeforeAll
-    static void setUpMockServer() throws IOException, InterruptedException {
-        mockServerPort = NetworkUtil.allocPort();
-        mockServer = new MockServerRest(mockServerPort);
-        mockServer.validate();
+    static void setUpMockServer() throws IOException {
+        mockServerPort = 42545;
+        mockServer = new MockWebServer();
+        mockServer.start(mockServerPort);
+        mockServer.setDispatcher(new Dispatcher() {
+            @NotNull
+            @Override
+            public MockResponse dispatch(@NotNull RecordedRequest request) {
+                String path = request.getPath();
+                assert path != null;
+                if (path.equals("/healthy") && "GET".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200);
+                }
+                if (path.equals("/unhealthy") && "GET".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(500);
+                }
+                if (path.equals("/services/success") && "PUT".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200)
+                            .addHeader("Content-Type", "application/json");
+                }
+                if (path.equals("/services/failure") && "PUT".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(500)
+                            .addHeader("Content-Type", "application/json");
+                }
+                if (path.startsWith("/service/success/") && "DELETE".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(204)
+                            .addHeader("Content-Type", "application/json");
+                }
+
+                if (path.startsWith("/service/failure/") && "DELETE".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(500);
+                }
+                return new MockResponse().setResponseCode(404);
+            }
+        });
         commonTestData = new CommonTestData();
     }
 
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockRestEndpoint.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockRestEndpoint.java
deleted file mode 100644 (file)
index 19ee960..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.http.utils;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Response;
-import java.util.List;
-
-/**
- * The Class MockRestEndpoint creates rest server endpoints for simulating Rest calls.
- */
-@Path("/")
-@Produces("application/json")
-public class MockRestEndpoint {
-
-    /**
-     * Get dummy endpoint.
-     *
-     * @param name the name
-     * @param version the version
-     * @return the response
-     */
-    @Path("get")
-    @GET
-    public Response getMessages(@QueryParam("name") String name, @QueryParam("version") String version) {
-        String createRequest = "dummy body";
-        return Response.status(200).entity(List.of(createRequest)).build();
-    }
-
-    /**
-     * Post dummy endpoint.
-     *
-     * @param name the name
-     * @param version the version
-     * @param jsonString the message
-     * @return the response
-     */
-    @Path("post")
-    @POST
-    public Response policyMessage(@QueryParam("name") String name, @QueryParam("version") String version,
-            final String jsonString) {
-        return Response.status(200).build();
-    }
-}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockServerRest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/MockServerRest.java
deleted file mode 100644 (file)
index fb7b790..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022-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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.http.utils;
-
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-/**
- * The Class MockServerRest that manages test servers for REST requests for the test.
- */
-public class MockServerRest implements AutoCloseable {
-    private static final String HOST = "localhost";
-    private HttpServletServer restServer;
-    private int restServerPort = 0;
-
-    /**
-     * Instantiates a new REST simulator.
-     */
-    public MockServerRest(int restServerPort) {
-        this.restServerPort = restServerPort;
-        restServer = HttpServletServerFactoryInstance.getServerFactory().build("MockRestEndpoint", false, HOST,
-                restServerPort, false, "/", false, false);
-        restServer.addServletClass(null, MockRestEndpoint.class.getName());
-        restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName());
-        restServer.start();
-    }
-
-    /**
-     * Validate the Rest server.
-     * @throws InterruptedException if is not alive
-     */
-    public void validate() throws InterruptedException {
-        if (!NetworkUtil.isTcpPortOpen(HOST, restServerPort, 50, 200L)) {
-            throw new IllegalStateException("port " + restServerPort + " is still not in use");
-        }
-    }
-
-    @Override
-    public void close() throws Exception {
-        if (restServer != null) {
-            restServer.stop();
-            restServer = null;
-        }
-    }
-}
index e43e7f3..752e7c3 100644 (file)
@@ -24,6 +24,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
 import java.util.List;
+import okhttp3.mockwebserver.Dispatcher;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.jetbrains.annotations.NotNull;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -31,8 +36,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
 import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
 import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData;
-import org.onap.policy.clamp.acm.participant.http.utils.MockServerRest;
-import org.onap.policy.common.utils.network.NetworkUtil;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 @ExtendWith(SpringExtension.class)
@@ -45,23 +48,40 @@ class AcHttpClientTest {
     private static final String MOCK_URL = "http://localhost";
     private static final String WRONG_URL = "http://wrong-url";
 
-    private static MockServerRest mockServer;
+    private static MockWebServer mockServer;
 
     /**
      * Set up Mock server.
      */
     @BeforeAll
-    static void setUpMockServer() throws IOException, InterruptedException {
-        mockServerPort = NetworkUtil.allocPort();
-        mockServer = new MockServerRest(mockServerPort);
-        mockServer.validate();
+    static void setUpMockServer() throws IOException {
+        mockServerPort = 42545;
+        mockServer = new MockWebServer();
+        mockServer.start(mockServerPort);
+        mockServer.setDispatcher(new Dispatcher() {
+            @NotNull
+            @Override
+            public MockResponse dispatch(@NotNull RecordedRequest request) {
+                String path = request.getPath();
+                assert path != null;
+                if (path.startsWith("/get") && "GET".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200);
+                }
+                if (path.equals("/post") && "POST".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200)
+                            .addHeader("Content-Type", "application/json");
+                }
+                return new MockResponse().setResponseCode(404);
+            }
+        });
         commonTestData = new CommonTestData();
     }
 
     @AfterAll
     static void stopServer() throws Exception {
-        mockServer.close();
-        mockServer = null;
+        mockServer.shutdown();
     }
 
     @Test
index 6426707..467af60 100644 (file)
@@ -28,14 +28,17 @@ import jakarta.ws.rs.client.Entity;
 import jakarta.ws.rs.core.MediaType;
 import jakarta.ws.rs.core.Response;
 import java.io.IOException;
+import okhttp3.mockwebserver.Dispatcher;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.jetbrains.annotations.NotNull;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentSubGroup;
 import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters;
-import org.onap.policy.clamp.acm.participant.policy.main.utils.MockServer;
 import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
 import org.onap.policy.common.parameters.rest.RestClientParameters;
-import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
@@ -43,22 +46,53 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
  */
 class HttpClientTest {
 
-    private static int mockServerPort;
-
     private static PolicyApiHttpClient apiHttpClient;
 
     private static PolicyPapHttpClient papHttpClient;
 
-    private static MockServer mockServer;
-
     /**
      * Set up Mock server.
      */
     @BeforeAll
-    static void setUpMockServer() throws IOException, InterruptedException {
-        mockServerPort = NetworkUtil.allocPort();
-        mockServer = new MockServer(mockServerPort);
-        mockServer.validate();
+    static void setUpMockServer() throws IOException {
+        // Setup mock web server
+        int mockServerPort = 42545;
+        MockWebServer mockServer = new MockWebServer();
+        mockServer.start(mockServerPort);
+        mockServer.setDispatcher(new Dispatcher() {
+            @NotNull
+            @Override
+            public MockResponse dispatch(@NotNull RecordedRequest request) {
+                String path = request.getPath();
+                assert path != null;
+                if (path.equals("/policy/api/v1/policytypes") && "POST".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200)
+                            .addHeader("Content-Type", "application/json");
+                }
+                if (path.equals("/policy/api/v1/policies") && "POST".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200)
+                            .addHeader("Content-Type", "application/json");
+                }
+                if (path.matches("^/policy/api/v1/policytypes/[^/]+/versions/[^/]+$")
+                        && "DELETE".equals(request.getMethod())) {
+                    return new MockResponse().setResponseCode(200);
+                }
+                if (path.matches("^/policy/api/v1/policies/[^/]+/versions/[^/]+$")
+                        && "DELETE".equals(request.getMethod())) {
+                    return new MockResponse().setResponseCode(200);
+                }
+                if (path.equals("/policy/pap/v1/pdps/deployments/batch")
+                        && "POST".equals(request.getMethod())) {
+                    return new MockResponse()
+                            .setResponseCode(200)
+                            .addHeader("Content-Type", "application/json");
+                }
+                return new MockResponse().setResponseCode(404);
+            }
+        });
+
         // Setup mock api and pap client
         ParticipantPolicyParameters params = new ParticipantPolicyParameters();
         RestClientParameters restClientParameters = getMockClientParameters(mockServerPort);
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java
deleted file mode 100644 (file)
index 64879aa..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. 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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.policy.main.utils;
-
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Response;
-import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentGroups;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.web.bind.annotation.RequestBody;
-
-/**
- * Mock rest endpoints for api and pap servers.
- */
-@Path("/")
-@Produces("application/json")
-public class MockRestEndpoint {
-
-    /**
-     * Dummy endpoint for create policy types.
-     *
-     * @param body tosca service template
-     * @return the response
-     */
-    @Path("policy/api/v1/policytypes")
-    @POST
-    public Response createPolicyType(@RequestBody ToscaServiceTemplate body) {
-        return Response.status(200).build();
-    }
-
-    /**
-     * Dummy endpoint for create policies.
-     *
-     * @param body tosca service template
-     * @return the response
-     */
-    @Path("policy/api/v1/policies")
-    @POST
-    public Response createPolicy(@RequestBody ToscaServiceTemplate body) {
-        return Response.status(200).build();
-    }
-
-    /**
-     * Dummy endpoint for delete policy types.
-     *
-     * @return the response
-     */
-    @Path("policy/api/v1/policytypes/{policyTypeId}/versions/{versionId}")
-    @DELETE
-    public Response deletePolicyType() {
-        return Response.status(200).build();
-    }
-
-    /**
-     * Dummy endpoint for delete policy.
-     *
-     * @return the response
-     */
-    @Path("policy/api/v1/policies/{policyId}/versions/{versionId}")
-    @DELETE
-    public Response deletePolicy() {
-        return Response.status(200).build();
-    }
-
-    /**
-     * Dummy endpoint for deploy/undeploy policy in pap.
-     *
-     * @param body pdp deployment group
-     * @return the response
-     */
-    @Path("policy/pap/v1/pdps/deployments/batch")
-    @POST
-    public Response handlePolicyDeployOrUndeploy(@RequestBody DeploymentGroups body) {
-        return Response.status(200).build();
-    }
-
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockServer.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockServer.java
deleted file mode 100644 (file)
index b45f1ea..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.participant.policy.main.utils;
-
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-/**
- * Mock REST server for pap and api tests.
- */
-public class MockServer implements AutoCloseable {
-    private static final String HOST = "localhost";
-    private HttpServletServer restServer;
-    private int restServerPort = 0;
-
-    /**
-     * Instantiates a new REST simulator.
-     */
-    public MockServer(int restServerPort) {
-        this.restServerPort = restServerPort;
-        restServer = HttpServletServerFactoryInstance.getServerFactory().build("MockRestEndpoint", false, HOST,
-                restServerPort, false, "/", false, false);
-        restServer.addServletClass(null, MockRestEndpoint.class.getName());
-        restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName());
-        restServer.start();
-    }
-
-    /**
-     * Validate the Rest server.
-     * @throws InterruptedException if is not alive
-     */
-    public void validate() throws InterruptedException {
-        if (!NetworkUtil.isTcpPortOpen(HOST, restServerPort, 50, 200L)) {
-            throw new IllegalStateException("port " + restServerPort + " is still not in use");
-        }
-    }
-
-    @Override
-    public void close() throws Exception {
-        if (restServer != null) {
-            restServer.stop();
-            restServer = null;
-        }
-    }
-
-
-}
index f5d2ea8..49769ac 100644 (file)
             <artifactId>junit-jupiter-engine</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>mockwebserver</artifactId>
+            <version>5.3.2</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>