diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-11-04 11:28:16 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-11-04 11:29:27 +0000 |
commit | 687db79756f7119e76fefa3bd5d2fc4f22a8a818 (patch) | |
tree | 39cbd906d3a063c37e543a4cd05777a27ecd07d3 /main/src/test | |
parent | 646881bafcf735aeadac905f0d945c8201b8b1f7 (diff) |
Fix references and organize dependencies in policy-distribution
after splitting policy-endpoints and message-bus in policy-common
Issue-ID: POLICY-5131
Change-Id: I93082f1db411c3f2c55244cca355ecce7f4e4dea
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'main/src/test')
4 files changed, 24 insertions, 27 deletions
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 57fa97d1..744c7a0a 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 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. @@ -29,7 +29,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.HashMap; import java.util.Map; -import org.onap.policy.common.endpoints.parameters.RestServerParameters; +import org.onap.policy.common.parameters.rest.RestServerParameters; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -77,7 +77,7 @@ public class CommonTestData { public static final String CONFIG_FILE = "src/test/resources/parameters/TestConfigParams.json"; - private Coder coder = new StandardCoder(); + private final Coder coder = new StandardCoder(); /** * Makes a parameter configuration file by substituting an available port number within a @@ -153,11 +153,10 @@ public class CommonTestData { * @return the receptionHandlerParameters object */ public Map<String, ReceptionHandlerParameters> getReceptionHandlerParameters(final boolean isEmpty) { - final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = - new HashMap<String, ReceptionHandlerParameters>(); + final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = new HashMap<>(); if (!isEmpty) { - final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(isEmpty); - final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(isEmpty); + final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(false); + final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(false); final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders); final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE, RECEPTION_HANDLER_CLASS_NAME, RECEPTION_CONFIGURATION_PARAMETERS, pHParameters); @@ -175,7 +174,7 @@ public class CommonTestData { public Map<String, ReceptionHandlerConfigurationParameterGroup> getReceptionHandlerConfigurationParameters( final boolean isEmpty) { final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters = - new HashMap<String, ReceptionHandlerConfigurationParameterGroup>(); + new HashMap<>(); if (!isEmpty) { final DummyReceptionHandlerParameterGroup dummyReceptionHandlerParameterGroup = new DummyReceptionHandlerParameterGroup(); @@ -197,9 +196,7 @@ public class CommonTestData { public PluginHandlerParameters getPluginHandlerParameters(final boolean isEmpty) { final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(isEmpty); final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(isEmpty); - final PluginHandlerParameters pluginHandlerParameters = - new PluginHandlerParameters(policyDecoders, policyForwarders); - return pluginHandlerParameters; + return new PluginHandlerParameters(policyDecoders, policyForwarders); } /** @@ -210,7 +207,7 @@ public class CommonTestData { */ public Map<String, PolicyForwarderParameters> getPolicyForwarders(final boolean isEmpty) { final Map<String, PolicyForwarderParameters> policyForwarders = - new HashMap<String, PolicyForwarderParameters>(); + new HashMap<>(); if (!isEmpty) { final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters(FORWARDER_TYPE, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS); @@ -226,7 +223,7 @@ public class CommonTestData { * @return the policyDecoders object */ public Map<String, PolicyDecoderParameters> getPolicyDecoders(final boolean isEmpty) { - final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<String, PolicyDecoderParameters>(); + final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>(); if (!isEmpty) { final PolicyDecoderParameters pDParameters = new PolicyDecoderParameters(DECODER_TYPE, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS); @@ -244,7 +241,7 @@ public class CommonTestData { public Map<String, PolicyForwarderConfigurationParameterGroup> getPolicyForwarderConfigurationParameters( final boolean isEmpty) { final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters = - new HashMap<String, PolicyForwarderConfigurationParameterGroup>(); + new HashMap<>(); if (!isEmpty) { final DummyPolicyForwarderParameterGroup parameters = new DummyPolicyForwarderParameterGroup(); parameters.setHostname(FORWARDER_HOST); @@ -267,7 +264,7 @@ public class CommonTestData { public Map<String, PolicyDecoderConfigurationParameterGroup> getPolicyDecoderConfigurationParameters( final boolean isEmpty) { final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters = - new HashMap<String, PolicyDecoderConfigurationParameterGroup>(); + new HashMap<>(); if (!isEmpty) { final DummyPolicyDecoderParameterGroup dummyPolicyForwarderParameterGroup = new DummyPolicyDecoderParameterGroup(); diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java index a48b0bd7..4f472b3d 100755 --- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java +++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020-2021 Nordix Foundation. + * Modifications Copyright (C) 2020-2021, 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. @@ -29,8 +29,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.rest.RestServerParameters; import org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup; import org.onap.policy.distribution.main.testclasses.DummyReceptionHandlerParameterGroup; import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; 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 c85994d8..10039e80 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.http.server.RestServer; -import org.onap.policy.common.endpoints.report.HealthCheckReport; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.common.utils.report.HealthCheckReport; import org.onap.policy.distribution.main.PolicyDistributionException; import org.onap.policy.distribution.main.parameters.CommonTestData; import org.onap.policy.distribution.main.startstop.Main; 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 a99b1e3f..0a2ea51d 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 @@ -24,6 +24,7 @@ package org.onap.policy.distribution.main.rest; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.core.MediaType; @@ -33,9 +34,9 @@ import javax.net.ssl.SSLContext; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.report.HealthCheckReport; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.common.utils.report.HealthCheckReport; import org.onap.policy.common.utils.security.SelfSignedKeyStore; import org.onap.policy.distribution.main.PolicyDistributionException; import org.onap.policy.distribution.main.parameters.CommonTestData; @@ -65,7 +66,7 @@ class TestHttpsDistributionRestServer { "HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive)"; final var main = startDistributionService(); final var report = performHealthCheck(); - validateReport(NAME, SELF, true, 200, ALIVE, reportString, report); + validateReport(reportString, report); assertThatCode(() -> stopDistributionService(main)).doesNotThrowAnyException(); } @@ -104,13 +105,12 @@ class TestHttpsDistributionRestServer { return invocationBuilder.get(HealthCheckReport.class); } - private void validateReport(final String name, final String url, final boolean healthy, final int code, - final String message, final String reportString, final HealthCheckReport report) { - assertEquals(name, report.getName()); - assertEquals(url, report.getUrl()); - assertEquals(healthy, report.isHealthy()); - assertEquals(code, report.getCode()); - assertEquals(message, report.getMessage()); + private void validateReport(final String reportString, final HealthCheckReport report) { + assertEquals(TestHttpsDistributionRestServer.NAME, report.getName()); + assertEquals(TestHttpsDistributionRestServer.SELF, report.getUrl()); + assertTrue(report.isHealthy()); + assertEquals(200, report.getCode()); + assertEquals(TestHttpsDistributionRestServer.ALIVE, report.getMessage()); assertEquals(reportString, report.toString()); } } |