aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java29
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java17
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java29
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpAafFilterTest.java37
4 files changed, 18 insertions, 94 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
index 8c412386..62c90f54 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2023 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,19 +27,15 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
@@ -47,11 +43,7 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.pdpx.main.comm.XacmlPdpUpdatePublisher;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
-import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
@RunWith(MockitoJUnitRunner.class)
@@ -115,25 +107,6 @@ public class XacmlStateTest {
}
@Test
- public void testGetStatistics() {
- XacmlPdpStatisticsManager statmgr = new XacmlPdpStatisticsManager();
- XacmlPdpStatisticsManager.setCurrent(statmgr);
-
- ToscaPolicy policy1 = mock(ToscaPolicy.class);
- ToscaPolicy policy2 = mock(ToscaPolicy.class);
- ToscaConceptIdentifier ident = new ToscaConceptIdentifier("undeployed", "2.3.4");
- when(policy2.getIdentifier()).thenReturn(ident);
-
- PdpUpdate message = new PdpUpdate();
- message.setPoliciesToBeDeployed(Arrays.asList(policy1));
- message.setPoliciesToBeUndeployed(Arrays.asList(policy2.getIdentifier()));
-
- TopicSinkClient client = Mockito.mock(TopicSinkClient.class);
- XacmlPdpUpdatePublisher publisher = new XacmlPdpUpdatePublisher(client, state, appmgr);
- publisher.handlePdpUpdate(message);
- }
-
- @Test
public void testUpdateInternalStatePdpStateChange() {
PdpStateChange req = new PdpStateChange();
req.setName(pdpName);
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
index e4352181..ef338cd8 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 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.
@@ -21,8 +21,6 @@
package org.onap.policy.pdpx.main.parameters;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -43,7 +41,6 @@ public class CommonTestData {
private static final String PORT_KEY = "port";
private static final String SERVER_HOST_KEY = "host";
private static final String API_HOST_KEY = "hostname";
- private static final String AAF_KEY = "aaf";
private static final String HTTPS_KEY = "useHttps";
private static final String REST_SERVER_PASS = "zb!XztG34";
@@ -51,20 +48,15 @@ public class CommonTestData {
private static final int REST_SERVER_PORT = 6969;
private static final String REST_SERVER_HOST = "0.0.0.0";
private static final boolean REST_SERVER_HTTPS = false;
- private static final boolean REST_SERVER_AAF = false;
-
private static final String POLICY_API_PASS = "zb!XztG34";
private static final String POLICY_API_USER = "healthcheck";
private static final int POLICY_API_PORT = 6970;
private static final String POLICY_API_HOST = "0.0.0.0";
private static final boolean POLICY_API_HTTPS = false;
- private static final boolean POLICY_API_AAF = false;
-
public static final String PDPX_PARAMETER_GROUP_NAME = "XacmlPdpParameters";
public static final String PDPX_GROUP = "XacmlPdpGroup";
public static final String PDPX_TYPE = "xacml";
- public static final List<TopicParameters> TOPIC_PARAMS =
- Collections.unmodifiableList(Arrays.asList(getTopicParams()));
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder coder = new StandardCoder();
@@ -77,7 +69,7 @@ public class CommonTestData {
final TopicParameters topicParams = new TopicParameters();
topicParams.setTopic("POLICY-PDP-PAP");
topicParams.setTopicCommInfrastructure("noop");
- topicParams.setServers(Arrays.asList("message-router"));
+ topicParams.setServers(List.of("message-router"));
return topicParams;
}
@@ -90,7 +82,6 @@ public class CommonTestData {
public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) {
final Map<String, Object> map = new TreeMap<>();
map.put(HTTPS_KEY, REST_SERVER_HTTPS);
- map.put(AAF_KEY, REST_SERVER_AAF);
if (!isEmpty) {
map.put(SERVER_HOST_KEY, REST_SERVER_HOST);
@@ -111,7 +102,6 @@ public class CommonTestData {
public Map<String, Object> getRestServerParametersMap(final int port) {
final Map<String, Object> map = new TreeMap<>();
map.put(HTTPS_KEY, REST_SERVER_HTTPS);
- map.put(AAF_KEY, REST_SERVER_AAF);
map.put(SERVER_HOST_KEY, REST_SERVER_HOST);
map.put(PORT_KEY, port);
map.put(USER_KEY, REST_SERVER_USER);
@@ -146,7 +136,6 @@ public class CommonTestData {
final Map<String, Object> map = new TreeMap<>();
map.put(CLIENT_NAME, XacmlPdpParameterGroup.PARAM_POLICY_API);
map.put(HTTPS_KEY, POLICY_API_HTTPS);
- map.put(AAF_KEY, POLICY_API_AAF);
if (!isEmpty) {
map.put(API_HOST_KEY, POLICY_API_HOST);
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
index a9f3f12d..f39061a6 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 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.
@@ -25,6 +25,7 @@ package org.onap.policy.pdpx.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -43,9 +44,8 @@ import org.onap.policy.common.parameters.ValidationResult;
*
*/
public class TestXacmlPdpParameterGroup {
- CommonTestData commonTestData = new CommonTestData();
private static File applicationPath;
- private static CommonTestData testData = new CommonTestData();
+ private static final CommonTestData testData = new CommonTestData();
@ClassRule
public static final TemporaryFolder applicationFolder = new TemporaryFolder();
@@ -65,7 +65,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME,
CommonTestData.PDPX_GROUP, "flavor", restServerParameters, policyApiParameters,
@@ -80,7 +80,6 @@ public class TestXacmlPdpParameterGroup {
assertEquals(CommonTestData.PDPX_PARAMETER_GROUP_NAME, pdpxParameters.getName());
assertEquals("flavor", pdpxParameters.getPdpType());
assertFalse(pdpxParameters.getRestServerParameters().isHttps());
- assertFalse(pdpxParameters.getRestServerParameters().isAaf());
assertThat(pdpxParameters.getApplicationParameters().getExclusions()).isEmpty();
}
@@ -94,12 +93,12 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(null, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters, topicParameterGroup, xacmlApplicationParameters);
final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertEquals(null, pdpxParameters.getName());
+ assertNull(pdpxParameters.getName());
assertThat(validationResult.getResult()).contains("\"name\" value \"null\" INVALID, is null");
}
@@ -113,7 +112,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup("", CommonTestData.PDPX_GROUP,
CommonTestData.PDPX_TYPE, restServerParameters, policyApiParameters, topicParameterGroup,
xacmlApplicationParameters);
@@ -133,13 +132,13 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, null, null, restServerParameters,
policyApiParameters, topicParameterGroup, xacmlApplicationParameters);
final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertEquals(null, pdpxParameters.getPdpGroup());
+ assertNull(pdpxParameters.getPdpGroup());
assertThat(validationResult.getResult()).contains("\"pdpGroup\" value \"null\" INVALID, is null");
}
@@ -153,7 +152,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, "", null, restServerParameters,
policyApiParameters, topicParameterGroup, xacmlApplicationParameters);
@@ -173,7 +172,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
@@ -193,7 +192,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
@@ -213,7 +212,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(true), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(false,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
@@ -233,7 +232,7 @@ public class TestXacmlPdpParameterGroup {
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlApplicationParameters xacmlApplicationParameters =
testData.toObject(testData.getXacmlapplicationParametersMap(true,
- applicationPath.getAbsolutePath().toString()), XacmlApplicationParameters.class);
+ applicationPath.getAbsolutePath()), XacmlApplicationParameters.class);
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpAafFilterTest.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpAafFilterTest.java
deleted file mode 100644
index 088ca927..00000000
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpAafFilterTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. 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.pdpx.main.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-
-public class XacmlPdpAafFilterTest {
-
- @Test
- public void testAafFilter() {
- XacmlPdpAafFilter filter = new XacmlPdpAafFilter();
- assertNotNull(filter);
- assertEquals(XacmlPdpAafFilter.AAF_ROOT_PERMISSION, filter.getPermissionTypeRoot());
- }
-
-}