StoredISORecords { public MetadataResultSet<ISORecord> getRecordById( List<String> idList ) { if ( idList == null ) { throw new IllegalArgumentException( "List with ids must not be null!" ); } List<ISORecord> result = new ArrayList<ISORecord>(); for ( String id : idList ) { if ( identifierToRecord.containsKey( id ) ) { result.add( identifierToRecord.get( id ) ); } } 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 testGetRecordById() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); MetadataResultSet<ISORecord> recordResultSet = storedIsoRecords.getRecordById( singletonList( "f90258d9a412aa5f3ba679b4997bb176" ) ); assertTrue( recordResultSet.next() ); assertNotNull( recordResultSet.getRecord() ); assertFalse( recordResultSet.next() ); }
@Test public void testGetRecordByIdWithUnknownId() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); MetadataResultSet<ISORecord> recordResultSet = storedIsoRecords.getRecordById( singletonList( "UNKNOWN_ID" ) ); assertFalse( recordResultSet.next() ); }
@Test public void testGetRecordByIds() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); List<String> ids = new ArrayList<String>(); ids.add( "f90258d9a412aa5f3ba679b4997bb176" ); ids.add( "15c1c1bbe5b4409c2fe10639bb54330f" ); MetadataResultSet<ISORecord> recordResultSet = storedIsoRecords.getRecordById( ids ); assertTrue( recordResultSet.next() ); assertNotNull( recordResultSet.getRecord() ); assertTrue( recordResultSet.next() ); assertNotNull( recordResultSet.getRecord() ); assertFalse( recordResultSet.next() ); }
@Test(expected = IllegalArgumentException.class) public void testGetRecordByIdNullList() throws Exception { StoredISORecords storedIsoRecords = getStoredIsoRecords(); storedIsoRecords.getRecordById( null ); }