ksession.insert( p1 );
ksession.insert( p2 );
ksession.insert( p3 );
ksession.insert( p4 );
QueryResults results = ksession.getQueryResults( "peeps", new Object[]{Variable.v, Variable.v, Variable.v} );
assertEquals( 4,
results.size() );
List names = new ArrayList();
for ( QueryResultsRow row : results ) {
names.add( ((Person) row.get( "$p" )).getName() );
}
assertEquals( 4,
names.size() );
assertTrue( names.contains( "luke" ) );
assertTrue( names.contains( "yoda" ) );
assertTrue( names.contains( "bobba" ) );
assertTrue( names.contains( "darth" ) );
results = ksession.getQueryResults( "peeps",
new Object[]{Variable.v, Variable.v, 300} );
assertEquals( 3,
results.size() );
names = new ArrayList();
for ( QueryResultsRow row : results ) {
names.add( ((Person) row.get( "$p" )).getName() );
}
assertEquals( 3,
names.size() );
assertTrue( names.contains( "luke" ) );
assertTrue( names.contains( "yoda" ) );
assertTrue( names.contains( "bobba" ) );
results = ksession.getQueryResults( "peeps",
new Object[]{Variable.v, "stilton", 300} );
assertEquals( 1,
results.size() );
names = new ArrayList();
for ( QueryResultsRow row : results ) {
names.add( ((Person) row.get( "$p" )).getName() );
}
assertEquals( 1,
names.size() );
assertTrue( names.contains( "yoda" ) );
results = ksession.getQueryResults( "peeps",
new Object[]{Variable.v, "stilton", Variable.v} );
assertEquals( 2,
results.size() );
names = new ArrayList();
for ( QueryResultsRow row : results ) {
names.add( ((Person) row.get( "$p" )).getName() );
}
assertEquals( 2,
names.size() );
assertTrue( names.contains( "yoda" ) );
assertTrue( names.contains( "darth" ) );
results = ksession.getQueryResults( "peeps",
new Object[]{"darth", Variable.v, Variable.v} );
assertEquals( 1,
results.size() );
names = new ArrayList();
for ( QueryResultsRow row : results ) {
names.add( ((Person) row.get( "$p" )).getName() );
}
assertEquals( 1,