From fc297c8a98df155971e2fa485c7724a61b70c69c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 4 Apr 2019 12:16:12 +0000 Subject: 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 --- .../simple/provider/SimpleToscaProviderTest.java | 27 ++++------------------ 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'models-tosca/src/test') 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 -- cgit 1.2.3-korg