diff options
Diffstat (limited to 'main')
5 files changed, 37 insertions, 18 deletions
diff --git a/main/pom.xml b/main/pom.xml index 37a889b1..7eb00839 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -51,6 +51,11 @@ <artifactId>gson</artifactId> </dependency> <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.6.11</version> + </dependency> + <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>utils-test</artifactId> <version>${policy.common.version}</version> diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java index 702f8a2a..e9e4b04e 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java +++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java @@ -26,11 +26,11 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.Info; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Tag; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import org.onap.policy.common.endpoints.report.HealthCheckReport; /** diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java index 9f6fab5a..57fa97d1 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java +++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java @@ -133,6 +133,22 @@ public class CommonTestData { /** * Returns an instance of ReceptionHandlerParameters for test cases. * + * @param port the port + * @return the restServerParameters object + */ + public RestServerParameters getRestServerParameters(final int port) { + final var fileName = "src/test/resources/parameters/RestServerParameters.json"; + try { + var json = Files.readString(new File(fileName).toPath()); + return coder.decode(json.replace("6969", String.valueOf(port)), RestServerParameters.class); + } catch (final Exception exp) { + throw new RuntimeException("cannot read/decode " + fileName, exp); + } + } + + /** + * Returns an instance of ReceptionHandlerParameters for test cases. + * * @param isEmpty boolean value to represent that object created should be empty or not * @return the receptionHandlerParameters object */ diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java index ce4cda24..ec4b001d 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java @@ -28,17 +28,16 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.MediaType; import java.io.IOException; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.Before; import org.junit.Test; -import org.mockito.internal.util.reflection.Whitebox; import org.onap.policy.common.endpoints.http.server.RestServer; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.report.HealthCheckReport; @@ -82,8 +81,7 @@ public class TestDistributionRestServer { port = NetworkUtil.allocPort(); final String reportString = "HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=false, code=500, message=not alive)"; - final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false); - Whitebox.setInternalState(restServerParams, "port", port); + final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(port); restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME); final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class); restServer.start(); diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java index 82e40ccd..ecb49ce6 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java @@ -25,16 +25,16 @@ package org.onap.policy.distribution.main.rest; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.MediaType; import java.io.IOException; import java.security.SecureRandom; import java.util.Properties; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.Before; import org.junit.Test; |