@Test
public void testAttributeValue() throws Exception
{
Set<Attribute> attributes = new HashSet<Attribute>();
attributes.add( new DefaultAttribute( "cn", CN_AT, "valueA" ) );
Collection<ACITuple> tuples = getTuples( new AttributeValueItem( attributes ) );
// Test wrong scope
AciContext aciContext = new AciContext( null, null );
aciContext.setAciTuples( tuples );
aciContext.setUserDn( USER_NAME );
aciContext.setAttributeType( CN_AT );
assertEquals( 0, filterA.filter( aciContext, OperationScope.ENTRY, null ).size() );
tuples = getTuples( new AttributeValueItem( attributes ) );
aciContext = new AciContext( null, null );
aciContext.setAciTuples( tuples );
aciContext.setUserDn( USER_NAME );
aciContext.setAttributeType( CN_AT );
assertEquals( 0, filterA.filter( aciContext, OperationScope.ATTRIBUTE_TYPE, null ).size() );
tuples = getTuples( new AttributeValueItem( attributes ) );
aciContext = new AciContext( null, null );
aciContext.setAciTuples( tuples );
aciContext.setUserDn( USER_NAME );
aciContext.setAttributeType( CN_AT );
aciContext.setAttrValue( new StringValue( "valueA" ) );
assertEquals( 1, filterA.filter( aciContext, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null ).size() );
aciContext = new AciContext( null, null );
aciContext.setAciTuples( tuples );
aciContext.setUserDn( USER_NAME );
aciContext.setAttributeType( CN_AT );
aciContext.setAttrValue( new StringValue( "valueB" ) );
assertEquals( 0, filterA.filter( aciContext, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null ).size() );
tuples = getTuples( new AttributeValueItem( attributes ) );
aciContext = new AciContext( null, null );
aciContext.setAciTuples( tuples );
aciContext.setUserDn( USER_NAME );
aciContext.setAttributeType( SN_AT );