ExprNode exprNode = new SubstringNode( schemaManager.getAttributeType( "cn" ), "J", null );
Evaluator<? extends ExprNode> eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store,
schemaManager );
notNode.addNode( exprNode );
NotCursor<String> cursor = new NotCursor( store, eval ); //cursorBuilder.build( andNode );
cursor.beforeFirst();
Set<String> set = new HashSet<String>();
while ( cursor.next() )
{
assertTrue( cursor.available() );
set.add( cursor.get().getId() );
assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getKey() ) );
}
assertEquals( 5, set.size() );
assertTrue( set.contains( Strings.getUUID( 1L ) ) );
assertTrue( set.contains( Strings.getUUID( 2L ) ) );
assertTrue( set.contains( Strings.getUUID( 3L ) ) );
assertTrue( set.contains( Strings.getUUID( 4L ) ) );
assertTrue( set.contains( Strings.getUUID( 7L ) ) );
assertFalse( cursor.next() );
assertFalse( cursor.available() );
cursor.afterLast();
set.clear();
while ( cursor.previous() )
{
assertTrue( cursor.available() );
set.add( cursor.get().getId() );
assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getKey() ) );
}
assertEquals( 5, set.size() );
assertTrue( set.contains( Strings.getUUID( 1L ) ) );
assertTrue( set.contains( Strings.getUUID( 2L ) ) );
assertTrue( set.contains( Strings.getUUID( 3L ) ) );
assertTrue( set.contains( Strings.getUUID( 4L ) ) );
assertTrue( set.contains( Strings.getUUID( 7L ) ) );
assertFalse( cursor.previous() );
assertFalse( cursor.available() );
try
{
cursor.get();
fail( "should fail with InvalidCursorPositionException" );
}
catch ( InvalidCursorPositionException ice )
{
}
try
{
cursor.after( new IndexEntry<String, String>() );
fail( "should fail with UnsupportedOperationException " );
}
catch ( UnsupportedOperationException uoe )
{
}
try
{
cursor.before( new IndexEntry<String, String>() );
fail( "should fail with UnsupportedOperationException " );
}
catch ( UnsupportedOperationException uoe )
{
}
cursor.close();
}