Changeset 402

Show
Ignore:
Timestamp:
06/10/10 13:16:51 (20 months ago)
Author:
martijn
Message:

Fixed failed test in synergizer by not supporting xrefExists anymore.
This means that xrefExists is now officially an optional operation

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/org.bridgedb.webservice.synergizer/src/org/bridgedb/webservice/synergizer/IDMapperSynergizer.java

    r308 r402  
    311311     * {@inheritDoc} 
    312312     */ 
    313     public boolean xrefExists(Xref xref) throws IDMapperException { 
    314         if (xref==null) 
    315             return false; 
    316  
    317         DataSource ds = xref.getDataSource(); 
    318         if (!supportedSrcDs.contains(ds)) 
    319             return false; 
    320  
    321         String src = ds.getFullName(); 
    322         String id = xref.getId(); 
    323         return stub.idExist(authority, species, src, id); 
     313    public boolean xrefExists(Xref xref) throws IDMapperException  
     314    { 
     315        throw new UnsupportedOperationException ("xrefExists operation not supported for synergizer"); 
    324316    } 
    325317} 
  • trunk/org.bridgedb.webservice.synergizer/src/org/bridgedb/webservice/synergizer/SynergizerStub.java

    r400 r402  
    258258    } 
    259259 
    260     public boolean idExist(final String authority, final String species, 
    261             final String domain, final String id) throws IDMapperException { 
    262         String range = domain; // bug: client now complains that domain==range! 
    263         Set<String> ids = new HashSet(1); 
    264         ids.add(id); 
    265  
    266         SynergizerClient.TranslateResult res; 
    267         try { 
    268              res = client.translate(authority, species, domain, range, ids); 
    269         } catch (IOException e) { 
    270             throw new IDMapperException(e); 
    271         } catch (JSONException e) { 
    272             throw new IDMapperException(e); 
    273         } 
    274  
    275         return res.foundSourceIDsWithFoundTargetIDs().contains(id) 
    276                 || res.foundSourceIDsWithUnfoundTargetIDs().contains(id); 
    277     } 
    278260} 
  • trunk/org.bridgedb.webservice.synergizer/test/org/bridgedb/webservice/synergizer/Test.java

    r400 r402  
    7272            IDMapper mapper = BridgeDb.connect("idmapper-synergizer:?authority=ensembl&species=Homo sapiens"); 
    7373            DataSource srcDs = DataSource.getByFullName("hgnc_symbol"); 
    74             assertTrue(mapper.xrefExists(new Xref("snph", srcDs))); 
     74             
     75            try 
     76            { 
     77                mapper.xrefExists(new Xref("snph", srcDs)); 
     78                fail ("Expected UnsupportedOperationException after calling xrefExists"); 
     79            } 
     80            catch (UnsupportedOperationException ex) 
     81            { 
     82                // ok. 
     83            } 
    7584 
    7685            Set<Xref> srcXrefs = new HashSet(); 
  • trunk/org.bridgedb/src/org/bridgedb/IDMapper.java

    r308 r402  
    5454         
    5555    /** 
    56      * Check whether an Xref exists. 
     56     * Check whether an Xref is known by the given mapping source. This is an optionally supported operation. 
    5757     * @param xref reference to check 
    5858     * @return if the reference exists, false if not 
    59      * @throws IDMapperException if failed 
     59     * @throws IDMapperException if failed, UnsupportedOperationException if it's not supported by the Driver. 
    6060     */ 
    6161    public boolean xrefExists(Xref xref) throws IDMapperException;