aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
diff options
context:
space:
mode:
authorITSERVICES\rb7147 <rb7147@att.com>2017-04-25 11:46:00 -0400
committerITSERVICES\rb7147 <rb7147@att.com>2017-05-03 09:58:17 -0400
commite0addf5b588a1244f9679becd90999dfcb4c3a94 (patch)
tree1212772d6366730266ff0e093c874b07aa716c29 /ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
parent39fb0f30472777e4b60d6a7ac8aa4eb9773961ff (diff)
Policy 1707 commit to LF
Change-Id: Ibe6f01d92f9a434c040abb05d5386e89d675ae65 Signed-off-by: ITSERVICES\rb7147 <rb7147@att.com>
Diffstat (limited to 'ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java')
-rw-r--r--ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java224
1 files changed, 0 insertions, 224 deletions
diff --git a/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java b/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
deleted file mode 100644
index 42a0aed75..000000000
--- a/ECOMP-TEST/src/test/java/org/openecomp/policy/pdp/test/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-TEST
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.policy.pdp.test.std.functions;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.math.BigInteger;
-
-import org.junit.Test;
-
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.StdAttributeValue;
-import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.Bag;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentBag;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
-import com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionBagOneAndOnly;
-
-/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- *
- */
-public class FunctionDefinitionBagOneAndOnlyTest {
-
-
- /*
- * variables useful in the following tests
- */
- List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
-
-
- @Test
- public void testString() {
- String v1 = new String("abc");
- String v2 = new String("def");
- BigInteger vOtherType = BigInteger.valueOf(11);
-
- Bag bag0 = new Bag();
- Bag bag1 = new Bag();
- bag1.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));
- Bag bag2 = new Bag();
- bag2.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));
- bag2.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v2));
- Bag bagOtherType = new Bag();
- bagOtherType.add(new StdAttributeValue<BigInteger>(DataTypes.DT_INTEGER.getId(), vOtherType));
-
- FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
- FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
- FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
- FunctionArgumentBag attrBagOtherType = new FunctionArgumentBag(bagOtherType);
-
-
- FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>) StdFunctions.FD_STRING_ONE_AND_ONLY;
-
- // check identity and type of the thing created
- assertEquals(XACML3.ID_FUNCTION_STRING_ONE_AND_ONLY, fd.getId());
- assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeId());
-
- // just to be safe... If tests take too long these can probably be eliminated
- assertFalse(fd.returnsBag());
-
-
-
-
- // bag with only one
- arguments.clear();
- arguments.add(attrBag1);
- ExpressionResult res = fd.evaluate(null, arguments);
- assertTrue(res.isOk());
- assertEquals(java.lang.String.class, res.getValue().getValue().getClass());
- String resValue = (String)res.getValue().getValue();
- assertEquals(v1, resValue);
-
- // null bag
- arguments.clear();
- arguments.add(null);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with exactly one but of other type in it
- arguments.clear();
- arguments.add(attrBagOtherType);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Element in bag of wrong type. Expected string got integer", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with none
- arguments.clear();
- arguments.add(attrBag0);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Expected 1 but Bag has 0 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with multiple
- arguments.clear();
- arguments.add(attrBag2);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Expected 1 but Bag has 2 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
- }
-
-
-
- @Test
- public void testBoolean() {
- Boolean v1 = new Boolean(true);
- Boolean v2 = new Boolean(false);
- BigInteger vOtherType = BigInteger.valueOf(11);
-
- Bag bag0 = new Bag();
- Bag bag1 = new Bag();
- bag1.add(new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v1));
- Bag bag2 = new Bag();
- bag2.add(new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v1));
- bag2.add(new StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v2));
- Bag bagOtherType = new Bag();
- bagOtherType.add(new StdAttributeValue<BigInteger>(DataTypes.DT_STRING.getId(), vOtherType));
-
-
- FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
- FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
- FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
- FunctionArgumentBag attrBagOtherType = new FunctionArgumentBag(bagOtherType);
-
-
- FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>) StdFunctions.FD_BOOLEAN_ONE_AND_ONLY;
-
- // check identity and type of the thing created
- assertEquals(XACML3.ID_FUNCTION_BOOLEAN_ONE_AND_ONLY, fd.getId());
- assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
-
- // just to be safe... If tests take too long these can probably be eliminated
- assertFalse(fd.returnsBag());
-
-
-
-
- // bag with only one
- arguments.clear();
- arguments.add(attrBag1);
- ExpressionResult res = fd.evaluate(null, arguments);
- assertTrue(res.isOk());
- assertEquals(java.lang.Boolean.class, res.getValue().getValue().getClass());
- Boolean resValue = (Boolean)res.getValue().getValue();
- assertEquals(new Boolean(true), resValue);
-
- // null bag
- arguments.clear();
- arguments.add(null);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with exactly one but of other type in it
- arguments.clear();
- arguments.add(attrBagOtherType);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Element in bag of wrong type. Expected boolean got string", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with none
- arguments.clear();
- arguments.add(attrBag0);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Expected 1 but Bag has 0 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
- // bag with multiple
- arguments.clear();
- arguments.add(attrBag2);
- res = fd.evaluate(null, arguments);
- assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Expected 1 but Bag has 2 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
- }
-
-
- //
- //
- // REST OF DATA TYPES OMITTED
- // because they "should" all work the same
- //
- //
-
-
-
-
-}