@Test public void testBase64Binary_Equal() { Base64Binary binary = null; Base64Binary sameBinary = null; Base64Binary differentBinary = null; try { binary = Base64Binary.newInstance("TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"); sameBinary = Base64Binary.newInstance("TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"); differentBinary = Base64Binary.newInstance("f123a890ee3d"); } catch (Exception e) { fail(e.toString()); } FunctionArgumentAttributeValue attrBinary = null; FunctionArgumentAttributeValue attrSameBinary = null; FunctionArgumentAttributeValue attrDifferentBinary = null; try { attrBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(binary)); attrSameBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(sameBinary)); attrDifferentBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(differentBinary)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_BASE64BINARY_EQUAL; assertEquals(XACML3.ID_FUNCTION_BASE64BINARY_EQUAL, fd.getId()); assertEquals(DataTypes.DT_BASE64BINARY.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(2), fd.getNumArgs()); arguments.add(attrBinary); arguments.add(attrSameBinary); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); Boolean resValue = (Boolean)res.getValue().getValue(); assertTrue(resValue); arguments.clear(); arguments.add(attrBinary); arguments.add(attrDifferentBinary); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertFalse(resValue); arguments.clear(); arguments.add(stringAttr1); arguments.add(intAttr1); res = fd.evaluate(null, arguments); assertFalse(res.isOk()); }
@Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } if (this.isEqual(convertedArguments.get(0), convertedArguments.get(1))) { return ER_TRUE; } else { return ER_FALSE; } }
FunctionDefinitionEquality extends FunctionDefinitionHomogeneousSimple<Boolean, I> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } if (this.isEqual(convertedArguments.get(0), convertedArguments.get(1))) { return ER_TRUE; } else { return ER_FALSE; } } }
FunctionDefinitionEquality extends FunctionDefinitionHomogeneousSimple<Boolean, I> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } if (this.isEqual(convertedArguments.get(0), convertedArguments.get(1))) { return ER_TRUE; } else { return ER_FALSE; } } FunctionDefinitionEquality(Identifier idIn, DataType<I> dataTypeArgsIn); }
FunctionDefinitionEquality extends FunctionDefinitionHomogeneousSimple<Boolean, I> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } if (this.isEqual(convertedArguments.get(0), convertedArguments.get(1))) { return ER_TRUE; } else { return ER_FALSE; } } FunctionDefinitionEquality(Identifier idIn, DataType<I> dataTypeArgsIn); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments); }
FunctionDefinitionEquality extends FunctionDefinitionHomogeneousSimple<Boolean, I> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } if (this.isEqual(convertedArguments.get(0), convertedArguments.get(1))) { return ER_TRUE; } else { return ER_FALSE; } } FunctionDefinitionEquality(Identifier idIn, DataType<I> dataTypeArgsIn); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments);  }