StoredISORecords { public MetadataResultSet<ISORecord> getRecords( MetadataQuery query ) throws FilterEvaluationException { if ( query == null ) { throw new IllegalArgumentException( "MetadataQuery must not be null!" ); } List<ISORecord> result = applyFilter( query.getFilter(), query.getStartPosition(), query.getMaxRecords() ); return new ListMetadataResultSet( result ); } StoredISORecords();   StoredISORecords( List<File> recordDirectories ); String insertRecord( ISORecord record, File recordFile ); boolean deleteRecord( String identifier ); MetadataResultSet<ISORecord> getRecordById( List<String> idList ); MetadataResultSet<ISORecord> getRecords( MetadataQuery query ); int getNumberOfStoredRecords(); List<ISORecord> getRecords( Filter filter ); boolean contains( ISORecord record );  }
@Test public void testGetRecordsWithLimitedMaxRecord() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); int maxRecords = 2; MetadataQuery query = new MetadataQuery( null, null, null, null, 1, maxRecords ); MetadataResultSet<ISORecord> allRecords = storedIsoRecords.getRecords( query ); assertEquals( maxRecords, allRecords.getRemaining() ); }
@Test public void testGetRecordsAllWithFilterForSubject() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); Literal<PrimitiveValue> literal = new Literal<PrimitiveValue>( "SPOT 2" ); Operator operator = new PropertyIsEqualTo( new ValueReference( "Subject", nsContext ), literal, true, null ); Filter filter = new OperatorFilter( operator ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 100 ); MetadataResultSet<ISORecord> allRecords = storedIsoRecords.getRecords( query ); assertEquals( 1, allRecords.getRemaining() ); }
@Test public void testGetRecordsAllWithFilterForBBox() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); GeometryFactory geomFactory = new GeometryFactory(); ValueReference reference = new ValueReference( "apiso:BoundingBox", nsContext ); Operator operator = new BBOX( reference, geomFactory.createEnvelope( 10, 45.22, 11., 45.5, CRSUtils.EPSG_4326 ) ); Filter filter = new OperatorFilter( operator ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 100 ); MetadataResultSet<ISORecord> allRecords = storedIsoRecords.getRecords( query ); assertEquals( 3, allRecords.getRemaining() ); }
@Test public void testGetRecordsAllWithComplexFilter() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); Literal<PrimitiveValue> literalSubject = new Literal<PrimitiveValue>( "SPOT 2" ); Operator operatorSubject = new PropertyIsEqualTo( new ValueReference( "Subject", nsContext ), literalSubject, true, null ); Literal<PrimitiveValue> lowerCreation = new Literal<PrimitiveValue>( "2006-06-14" ); Literal<PrimitiveValue> upperCreation = new Literal<PrimitiveValue>( "2006-06-16" ); Operator operatorCreation = new PropertyIsBetween( new ValueReference( "apiso:CreationDate", nsContext ), lowerCreation, upperCreation, true, null ); Operator or = new Or( operatorSubject, operatorCreation ); Filter filter = new OperatorFilter( or ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 100 ); MetadataResultSet<ISORecord> allRecords = storedIsoRecords.getRecords( query ); assertEquals( 4, allRecords.getRemaining() ); }
@Test(expected = IllegalArgumentException.class) public void testGetRecordsWithNullQuery() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); MetadataQuery query = null; storedIsoRecords.getRecords( query ); }