X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=ONAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fjpa%2FActionDictionaryJpaTest.java;fp=ONAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fjpa%2FActionDictionaryJpaTest.java;h=047053a835f2d6924dcd03d96e878f1dfb92ab94;hb=e4ac1ef3c51fc9afe44849ada5bea8c3d6057897;hp=b2c3a77c1155895d0500a038eb122b6b0ce205c7;hpb=f4ec47c009cdc385a7efed02dda5d26f2ec31b57;p=policy%2Fengine.git diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java index b2c3a77c1..047053a83 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java @@ -8,9 +8,9 @@ * 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. @@ -21,8 +21,13 @@ package org.onap.policy.rest.jpa; +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 com.att.research.xacml.api.Identifier; + import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -39,7 +44,7 @@ public class ActionDictionaryJpaTest { /** * Set up the test. - * + * * @throws Exception on test errors */ @Before @@ -141,7 +146,6 @@ public class ActionDictionaryJpaTest { data.removeAttribute(new Attribute()); data.isStandard(); data.isCustom(); - Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"); data.getIdentifer(); data.toString(); assertTrue(data.getAttributes() != null); @@ -153,6 +157,33 @@ public class ActionDictionaryJpaTest { assertTrue("Test".equals(data.getShortName())); data.setXacmlId("Test"); assertTrue("Test".equals(data.getXacmlId())); + + data.setIsStandard(Category.STANDARD); + assertEquals(Category.STANDARD, data.getIsStandard()); + assertTrue(data.isStandard()); + assertFalse(data.isCustom()); + + data.setIsStandard(Category.CUSTOM); + assertEquals(Category.CUSTOM, data.getIsStandard()); + assertFalse(data.isStandard()); + assertTrue(data.isCustom()); + + Identifier categoryIdentifier = new DummyIdentifier(); + Category data2 = new Category(categoryIdentifier, + "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject", Category.STANDARD); + assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue()); + + Category data3 = new Category(categoryIdentifier, + "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"); + assertEquals(DummyIdentifier.class.getName(), data3.getIdentifer().stringValue()); + + assertEquals("subject", + Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject")); + assertNull(Category.extractGrouping(null)); + assertNull(Category.extractGrouping("some random string")); + assertNull(Category.extractGrouping("")); + assertEquals("intermediary-attribute", Category + .extractGrouping("urn:oasis:names:tc:xacml:1.0:attribute-category:intermediary-attribute")); } @Test @@ -283,6 +314,19 @@ public class ActionDictionaryJpaTest { assertTrue(data.isStandard()); data.setIsStandard(Datatype.CUSTOM); assertTrue(data.isCustom()); + + data.setIsStandard(Category.STANDARD); + assertEquals(Category.STANDARD, data.getIsStandard()); + assertTrue(data.isStandard()); + assertFalse(data.isCustom()); + + data.setIsStandard(Category.CUSTOM); + assertEquals(Category.CUSTOM, data.getIsStandard()); + assertFalse(data.isStandard()); + assertTrue(data.isCustom()); + + Datatype data2 = new Datatype(new DummyIdentifier(), Datatype.STANDARD); + assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue()); } @Test