summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java4
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java3
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java7
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java67
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java8
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java2
8 files changed, 54 insertions, 41 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java b/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java
index 47d1de5f..45c278c5 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,7 +206,8 @@ public class CommonRequestBase {
PdpUpdate message = new PdpUpdate();
message.setName(pdpName);
- message.setPolicies(Collections.emptyList());
+ message.setPoliciesToBeDeployed(Collections.emptyList());
+ message.setPoliciesToBeUndeployed(Collections.emptyList());
message.setPdpGroup(group);
message.setPdpSubgroup(subgroup);
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 0ceef772..31d4af46 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -225,8 +225,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
PdpStatusMessageHandler handler = new PdpStatusMessageHandler(params);
PdpUpdate update10 = handler.createPdpUpdateMessage(
status3.getPdpGroup(), new PdpSubGroup(), "pdp_2",
- policies, policies, polsUndep);
- assertSame(update10.getPolicies(), policies);
+ policies, polsUndep);
assertSame(update10.getPoliciesToBeDeployed(), policies);
assertSame(update10.getPoliciesToBeUndeployed(), polsUndep);
assertThat(update10.getPoliciesToBeDeployed()).isInstanceOf(List.class);
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
index 6a0800f1..df036d25 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
@@ -585,7 +585,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
when(policy.getIdentifier()).thenReturn(ident);
// add some policies to the update
- update.setPolicies(Arrays.asList(policy));
+ update.setPoliciesToBeDeployed(Arrays.asList(policy));
map.addRequest(update);
@@ -597,7 +597,8 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
doAnswer(ans -> {
PdpUpdate update2 = new PdpUpdate(update);
- update2.setPolicies(Collections.emptyList());
+ update2.setPoliciesToBeDeployed(Collections.emptyList());
+ update2.setPoliciesToBeUndeployed(Arrays.asList(policy.getIdentifier()));
assertTrue(req.reconfigure(update2));
throw makeException();
}).when(undeployer).undeploy(any(), any(), any());
@@ -630,7 +631,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
when(policy.getIdentifier()).thenReturn(ident);
// add some policies to the update
- update.setPolicies(Arrays.asList(policy));
+ update.setPoliciesToBeDeployed(Arrays.asList(policy));
map.addRequest(update);
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
index 02f47287..306418c4 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +72,8 @@ public class UpdateReqTest extends CommonRequestBase {
response.setPdpGroup(update.getPdpGroup());
response.setPdpSubgroup(update.getPdpSubgroup());
response.setPolicies(
- update.getPolicies().stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList()));
+ update.getPoliciesToBeDeployed().stream().map(ToscaPolicy::getIdentifier)
+ .collect(Collectors.toList()));
data = new UpdateReq(reqParams, MY_REQ_NAME, update);
data.setNotifier(notifier);
@@ -90,7 +92,7 @@ public class UpdateReqTest extends CommonRequestBase {
verifyResponse();
// both policy lists null
- update.setPolicies(null);
+ update.setPoliciesToBeDeployed(null);
response.setPolicies(null);
assertNull(data.checkResponse(response));
assertTrue(data.getUndeployPolicies().isEmpty());
@@ -147,7 +149,7 @@ public class UpdateReqTest extends CommonRequestBase {
@Test
public void testUpdateReqCheckResponse_MismatchedPolicies() {
- ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPolicies());
+ ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPoliciesToBeDeployed());
policies.set(0, makePolicy(DIFFERENT, "10.0.0"));
response.setPolicies(policies.stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList()));
@@ -156,15 +158,15 @@ public class UpdateReqTest extends CommonRequestBase {
verifyResponse();
// the first policy from the original update is all that should be undeployed
- assertEquals(Collections.singleton(update.getPolicies().get(0).getIdentifier()).toString(),
+ assertEquals(Collections.singleton(update.getPoliciesToBeDeployed().get(0).getIdentifier()).toString(),
data.getUndeployPolicies().toString());
}
@Test
public void testUpdateReqCheckResponse_MismatchedPolicies_Null_NotNull() {
- update.setPolicies(null);
+ update.setPoliciesToBeDeployed(null);
- assertEquals("policies do not match", data.checkResponse(response));
+ assertEquals(null, data.checkResponse(response));
assertTrue(data.getUndeployPolicies().isEmpty());
verifyResponse();
}
@@ -177,7 +179,8 @@ public class UpdateReqTest extends CommonRequestBase {
verifyResponse();
// all policies in the update should be undeployed
- assertEquals(update.getPolicies().stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList())
+ assertEquals(update.getPoliciesToBeDeployed().stream().map(ToscaPolicy::getIdentifier)
+ .collect(Collectors.toList())
.toString(), new TreeSet<>(data.getUndeployPolicies()).toString());
}
@@ -201,23 +204,22 @@ public class UpdateReqTest extends CommonRequestBase {
@Test
public void testReconfigureIsFullSameAsDeployList() {
PdpUpdate msg2 = new PdpUpdate(update);
- ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPolicies());
+ ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPoliciesToBeDeployed());
- msg2.setPolicies(policies);
msg2.setPoliciesToBeDeployed(policies);
assertTrue(data.reconfigure(msg2));
- assertThat(data.getMessage().getPolicies()).containsAll(msg2.getPolicies());
+ assertThat(data.getMessage().getPoliciesToBeDeployed()).containsAll(msg2.getPoliciesToBeDeployed());
}
@Test
public void testListsNewVsResult() {
PdpUpdate msg2 = new PdpUpdate(update);
- ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPolicies());
+ ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPoliciesToBeDeployed());
// some items in both deploy and newMessage.deploy
msg2.setPoliciesToBeDeployed(policies);
policies.remove(0);
- data.getMessage().setPolicies(policies);
+ data.getMessage().setPoliciesToBeDeployed(policies);
assertTrue(data.reconfigure(msg2));
assertThat(data.getMessage().getPoliciesToBeDeployed()).containsAll(msg2.getPoliciesToBeDeployed());
@@ -228,7 +230,7 @@ public class UpdateReqTest extends CommonRequestBase {
data.getMessage().setPoliciesToBeDeployed(policies);
policies.clear();
- policies = new ArrayList<>(update.getPolicies());
+ policies = new ArrayList<>(update.getPoliciesToBeDeployed());
List<ToscaConceptIdentifier> polsToUndep = policies.parallelStream()
.map(ToscaPolicy::getIdentifier)
.collect(Collectors.toList());
@@ -236,10 +238,8 @@ public class UpdateReqTest extends CommonRequestBase {
assertTrue(data.reconfigure(msg2));
- assertThat(data.getMessage().getPoliciesToBeDeployed()).isEmpty();
-
// some items only in deploy
- policies = new ArrayList<>(update.getPolicies());
+ policies = new ArrayList<>(update.getPoliciesToBeDeployed());
msg2.setPoliciesToBeDeployed(policies);
data.getMessage().setPoliciesToBeDeployed(new LinkedList<>());
assertTrue(data.reconfigure(msg2));
@@ -249,13 +249,13 @@ public class UpdateReqTest extends CommonRequestBase {
List<ToscaConceptIdentifier> pols = policies.stream().map(ToscaPolicy::getIdentifier)
.collect(Collectors.toList());
msg2.setPoliciesToBeUndeployed(pols);
- pols.remove(0);
+ pols.add(makePolicy("policy-zz-1", "1.1.0").getIdentifier());
data.getMessage().setPoliciesToBeUndeployed(pols);
assertTrue(data.reconfigure(msg2));
assertThat(data.getMessage().getPoliciesToBeUndeployed()).containsAll(msg2.getPoliciesToBeUndeployed());
// some items in both undeploy and newMessage.deploy
- policies = new ArrayList<>(update.getPolicies());
+ policies = new ArrayList<>(update.getPoliciesToBeDeployed());
List<ToscaConceptIdentifier> polsToUndep2 = policies.parallelStream()
.map(ToscaPolicy::getIdentifier)
.collect(Collectors.toList());
@@ -290,12 +290,16 @@ public class UpdateReqTest extends CommonRequestBase {
PdpUpdate msg2 = new PdpUpdate(update);
msg2.setName("world");
- assertFalse(data.isSameContent(msg2));
+ update.setPoliciesToBeDeployed(null);
+ List<ToscaPolicy> polsToDep2 = new LinkedList<>();
+ polsToDep2.add(makePolicy("policy-m-1", "1.0.0"));
+ polsToDep2.add(makePolicy("policy-n-1", "1.0.0"));
+ msg2.setPoliciesToBeDeployed(polsToDep2);
+ assertThat(data.isSameContent(msg2)).isFalse();
// both policy lists null
- update.setPolicies(null);
- msg2.setPolicies(null);
- assertEquals(data.getMessage().getPolicies(), msg2.getPolicies());
+ msg2.setPoliciesToBeDeployed(null);
+ assertEquals(data.getMessage().getPoliciesToBeDeployed(), msg2.getPoliciesToBeDeployed());
}
@Test
@@ -344,9 +348,9 @@ public class UpdateReqTest extends CommonRequestBase {
public void testIsSameContent_DiffPolicies() {
PdpUpdate msg2 = new PdpUpdate(update);
- ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPolicies());
+ ArrayList<ToscaPolicy> policies = new ArrayList<>(update.getPoliciesToBeDeployed());
policies.set(0, makePolicy(DIFFERENT, "10.0.0"));
- msg2.setPolicies(policies);
+ msg2.setPoliciesToBeDeployed(policies);
assertFalse(data.isSameContent(msg2));
}
@@ -354,18 +358,22 @@ public class UpdateReqTest extends CommonRequestBase {
@Test
public void testIsSameContent_DiffPolicies_NotNull_Null() {
PdpUpdate msg2 = new PdpUpdate(update);
- msg2.setPolicies(null);
+ msg2.setPoliciesToBeDeployed(null);
assertFalse(data.isSameContent(msg2));
}
@Test
public void testIsSameContent_DiffPolicies_Null_NotNull() {
- PdpUpdate msg2 = new PdpUpdate(update);
+ final PdpUpdate msg2 = new PdpUpdate(update);
- update.setPolicies(null);
+ update.setPoliciesToBeDeployed(null);
+ List<ToscaPolicy> polsToDep2 = new LinkedList<>();
+ polsToDep2.add(makePolicy("policy-m-1", "1.0.0"));
+ polsToDep2.add(makePolicy("policy-n-1", "1.0.0"));
+ msg2.setPoliciesToBeDeployed(polsToDep2);
- assertFalse(data.isSameContent(msg2));
+ assertThat(data.isSameContent(msg2)).isFalse();
}
@SuppressWarnings("unchecked")
@@ -394,7 +402,8 @@ public class UpdateReqTest extends CommonRequestBase {
ToscaPolicy policy1 = makePolicy("policy-1-a", "1.0.0");
ToscaPolicy policy2 = makePolicy("policy-2-a", "1.1.0");
- upd.setPolicies(Arrays.asList(policy1, policy2));
+ upd.setPoliciesToBeDeployed(Arrays.asList(policy1, policy2));
+ upd.setPoliciesToBeUndeployed(Collections.emptyList());
return upd;
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
index 64534530..1ea13119 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
@@ -548,7 +548,7 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
assertEquals(groupName, update.getPdpGroup());
assertEquals(pdpType, update.getPdpSubgroup());
assertEquals(pdpName, update.getName());
- assertTrue(update.getPolicies().contains(policy1));
+ assertTrue(update.getPoliciesToBeDeployed().contains(policy1));
}
private void assertNoGroupAction() throws Exception {
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
index fc71c62c..30b5b16f 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
@@ -194,7 +194,7 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
assertEquals("pdpA", req.getName());
assertEquals(GROUP1_NAME, req.getPdpGroup());
assertEquals("pdpTypeA", req.getPdpSubgroup());
- assertEquals(Arrays.asList(policy1, policy1), req.getPolicies());
+ assertEquals(Arrays.asList(policy1.getIdentifier()), req.getPoliciesToBeUndeployed());
}
@Test
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
index 575dfefc..8d7ec96c 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
@@ -21,6 +21,7 @@
package org.onap.policy.pap.main.rest;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
@@ -646,7 +647,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
assertEquals(groupName, update.getPdpGroup());
assertEquals(pdpType, update.getPdpSubgroup());
assertEquals(pdpName, update.getName());
- assertTrue(update.getPolicies().contains(policy1));
+ assertThat(update.getPoliciesToBeDeployed()).contains(policy1);
}
private void assertNoGroupAction() throws Exception {
@@ -670,10 +671,11 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
assertEquals(subgrp.getPdpType(), pdpUpdate.getPdpSubgroup());
List<ToscaConceptIdentifier> pdpPolicies =
- pdpUpdate.getPolicies().stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList());
+ pdpUpdate.getPoliciesToBeDeployed().stream().map(ToscaPolicy::getIdentifier)
+ .collect(Collectors.toList());
Collections.sort(pdpPolicies);
- assertEquals(subgrp.getPolicies().toString(), pdpPolicies.toString());
+ assertThat(subgrp.getPolicies()).containsAll(pdpPolicies);
List<PdpGroup> updates = getGroupUpdates();
assertEquals(Arrays.asList(group), updates);
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
index 2bf4f3df..ce032647 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
@@ -282,7 +282,7 @@ public class TestProviderBase extends ProviderSuper {
assertEquals(groupName, update.getPdpGroup());
assertEquals(pdpType, update.getPdpSubgroup());
assertEquals(pdpName, update.getName());
- assertTrue(update.getPolicies().contains(policy1));
+ assertTrue(update.getPoliciesToBeDeployed().contains(policy1));
}
/**