aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-04 12:16:12 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-04 12:16:12 +0000
commitfc297c8a98df155971e2fa485c7724a61b70c69c (patch)
tree4ee7cd37b8535417b467d8680455f87c52d534be /models-tosca/src/test/java
parent162cb586fe139460dd3d0404274e85b3f4ead15b (diff)
Add filter obejcts for concepts
This review: - Fixes the bug in getting policies where the key fields were null - Removes complex version checks from DAO interface - Simplifies provider API by introducing filter objects for searches Issue-ID: POLICY-1095 Change-Id: I5ab7471c03e8b61849e7882ed18541acd627dc39 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/test/java')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java27
1 files changed, 5 insertions, 22 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
index 0d486e3ea..dca34b08e 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.models.tosca.simple.provider;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.Connection;
@@ -93,26 +94,12 @@ public class SimpleToscaProviderTest {
@Test
public void testPoliciesGet() throws Exception {
try {
- new SimpleToscaProvider().getPolicies(null, null);
+ new SimpleToscaProvider().getPolicies(null, null, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
- try {
- new SimpleToscaProvider().getPolicies(null, new PfConceptKey());
- fail("test should throw an exception here");
- } catch (Exception exc) {
- assertEquals("dao is marked @NonNull but is null", exc.getMessage());
- }
-
- try {
- new SimpleToscaProvider().getPolicies(pfDao, null);
- fail("test should throw an exception here");
- } catch (Exception exc) {
- assertEquals("policyKey is marked @NonNull but is null", exc.getMessage());
- }
-
ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(
ResourceUtils.getResourceAsString("policies/vCPE.policy.monitoring.input.tosca.json"),
ToscaServiceTemplate.class);
@@ -129,7 +116,7 @@ public class SimpleToscaProviderTest {
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
JpaToscaServiceTemplate gotServiceTemplate =
- new SimpleToscaProvider().getPolicies(pfDao, new PfConceptKey(policyKey));
+ new SimpleToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion());
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey),
gotServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey));
@@ -254,12 +241,8 @@ public class SimpleToscaProviderTest {
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey),
deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey));
- try {
- new SimpleToscaProvider().getPolicies(pfDao, new PfConceptKey(policyKey));
- fail("test should throw an exception here");
- } catch (Exception exc) {
- assertEquals("policy not found: onap.restart.tca:1.0.0", exc.getMessage());
- }
+ assertTrue(new SimpleToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion())
+ .getTopologyTemplate().getPolicies().getConceptMap().isEmpty());
}
@Test