Changeset 167

Show
Ignore:
Timestamp:
08/22/09 20:23:08 (2 years ago)
Author:
martijn
Message:

Fixed NPE in IDMapperFile
Also added unit test for this problem

Location:
trunk/corelib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/corelib/src/org/bridgedb/file/IDMapperFile.java

    r164 r167  
    131131        } 
    132132 
    133         for (Xref destRef : mapXrefs.get(srcXref)) 
     133        Set<Xref> destRefs = mapXrefs.get(srcXref); 
     134        if (destRefs != null) for (Xref destRef : mapXrefs.get(srcXref)) 
    134135        { 
    135136            if (tgtDataSources == null || tgtDataSources.contains(destRef.getDataSource())) 
  • trunk/corelib/test/org/bridgedb/TestFile.java

    r156 r167  
    9292            System.out.println(xr.getDataSource().getFullName() + ": " + xr.getId()); 
    9393        } 
     94         
     95        Xref nonsense = new Xref ("Humbug", DataSource.getByFullName("Ebenizer Scrooge")); 
     96        // non-existent id should just return empty list. 
     97        assertEquals (0, idMapper.mapID(nonsense, null).size()); 
    9498 
    9599        }