@Test public void testRfc822Name_Equal() { RFC822Name name1 = null; RFC822Name name1a = null; RFC822Name differentLocalName = null; RFC822Name differentDomainName = null; RFC822Name localCaseName = null; RFC822Name domainCaseName = null; @SuppressWarnings("unused") RFC822Name noAtName = null; try { name1 = RFC822Name.newInstance("localPart@DomainPart"); name1a = RFC822Name.newInstance("localPart@DomainPart"); differentLocalName = RFC822Name.newInstance("differentlocalPart@DomainPart"); differentDomainName = RFC822Name.newInstance("localPart@differentDomainPart"); localCaseName = RFC822Name.newInstance("LOCALPart@DomainPart"); domainCaseName = RFC822Name.newInstance("localPart@DOMAINPart"); } catch (Exception e) { fail(e.toString()); } Exception exSeen = null; try { noAtName = RFC822Name.newInstance("nameWithoutAnAtSign"); } catch (Exception e) { exSeen = e; } assertNotNull(exSeen); FunctionArgumentAttributeValue attrName1 = null; FunctionArgumentAttributeValue attrName1a = null; FunctionArgumentAttributeValue attrDifferentLocalName = null; FunctionArgumentAttributeValue attrDifferentDomainName = null; FunctionArgumentAttributeValue attrLocalCaseName = null; FunctionArgumentAttributeValue attrDomainCaseName = null; try { attrName1 = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(name1)); attrName1a = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(name1a)); attrDifferentLocalName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(differentLocalName)); attrDifferentDomainName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(differentDomainName)); attrLocalCaseName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(localCaseName)); attrDomainCaseName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(domainCaseName)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_RFC822NAME_EQUAL; assertEquals(XACML3.ID_FUNCTION_RFC822NAME_EQUAL, fd.getId()); assertEquals(DataTypeRFC822Name.newInstance().getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(2), fd.getNumArgs()); arguments.add(attrName1); arguments.add(attrName1a); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); Boolean resValue = (Boolean)res.getValue().getValue(); assertTrue(resValue); arguments.clear(); arguments.add(attrName1); arguments.add(attrDifferentLocalName); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertFalse(resValue); arguments.clear(); arguments.add(attrName1); arguments.add(attrDifferentDomainName); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertFalse(resValue); arguments.clear(); arguments.add(attrName1); arguments.add(attrLocalCaseName); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertFalse(resValue); arguments.clear(); arguments.add(attrName1); arguments.add(attrDomainCaseName); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertTrue(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);  }