aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-06-28 14:28:01 -0400
committerJim Hahn <jrh3@att.com>2021-06-29 10:06:06 -0400
commitff04793e79c188ba4378dfc76db1085823a4fb75 (patch)
treea3b762c249035fd255fc981fc8059d9867044be9 /main/src/test/java
parent6eac3876d78c7fac402a4a9081132d1dede6e284 (diff)
Set "source" name in PAP PdpMessages
Used the unique name generator to initialize the PAP_NAME constant which is then stuffed into the various outgoing PdpMessages. Issue-ID: POLICY-3409 Change-Id: I45d26403b4f3de4b040cad779f29c82f35bacf42 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test/java')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java9
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java16
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java2
3 files changed, 11 insertions, 16 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java b/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
index 4733f91e..6d5d303a 100644
--- a/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,15 +21,14 @@
package org.onap.policy.pap.main;
-import org.assertj.core.api.Assertions;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
-import org.powermock.reflect.Whitebox;
public class PapConstantsTest {
@Test
public void test() {
- // verify that constructor does not throw an exception
- Assertions.assertThatCode(() -> Whitebox.invokeConstructor(PapConstants.class)).doesNotThrowAnyException();
+ assertThat(PapConstants.PAP_NAME).startsWith("pap").isNotEqualTo("pap");
}
}
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 1ea13119..f64a77b3 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
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -50,6 +49,7 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.pap.main.PapConstants;
public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -292,10 +292,12 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
assertEquals(2, pdpUpdates.size());
PdpUpdate pdpUpdate = pdpUpdates.get(0);
+ assertEquals(PapConstants.PAP_NAME, pdpUpdate.getSource());
assertEquals(PDP2, pdpUpdate.getName());
assertNull(pdpUpdate.getPdpGroup());
pdpUpdate = pdpUpdates.get(1);
+ assertEquals(PapConstants.PAP_NAME, pdpUpdate.getSource());
assertEquals(PDP4, pdpUpdate.getName());
assertNull(pdpUpdate.getPdpGroup());
@@ -304,10 +306,12 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
assertEquals(2, changes.size());
PdpStateChange change = changes.get(0);
+ assertEquals(PapConstants.PAP_NAME, change.getSource());
assertEquals(PDP2, change.getName());
assertEquals(PdpState.PASSIVE, change.getState());
change = changes.get(1);
+ assertEquals(PapConstants.PAP_NAME, change.getSource());
assertEquals(PDP4, change.getName());
assertEquals(PdpState.PASSIVE, change.getState());
}
@@ -541,16 +545,6 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
assertNoGroupAction();
}
- protected void assertUpdate(List<PdpUpdate> updates, String groupName, String pdpType, String pdpName) {
-
- PdpUpdate update = updates.remove(0);
-
- assertEquals(groupName, update.getPdpGroup());
- assertEquals(pdpType, update.getPdpSubgroup());
- assertEquals(pdpName, update.getName());
- assertTrue(update.getPoliciesToBeDeployed().contains(policy1));
- }
-
private void assertNoGroupAction() throws Exception {
verify(dao, never()).createPdpGroups(any());
verify(dao, never()).updatePdpGroups(any());
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 ce032647..49eec772 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
@@ -49,6 +49,7 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.pap.main.PapConstants;
import org.powermock.reflect.Whitebox;
public class TestProviderBase extends ProviderSuper {
@@ -279,6 +280,7 @@ public class TestProviderBase extends ProviderSuper {
PdpUpdate update = updates.remove(0);
+ assertEquals(PapConstants.PAP_NAME, update.getSource());
assertEquals(groupName, update.getPdpGroup());
assertEquals(pdpType, update.getPdpSubgroup());
assertEquals(pdpName, update.getName());