Changeset 3774


Ignore:
Timestamp:
Sep 25, 2007, 9:35:09 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #782: Create test case that calls AnnotationSet?.getAllInheritedAnnotations()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4-stable/src/test/TestAnnotation.java

    r3679 r3774  
    2626
    2727import net.sf.basedb.core.*;
     28import net.sf.basedb.core.query.Hql;
     29import net.sf.basedb.core.query.Orders;
    2830
    2931import java.util.Date;
     
    8183    // Test: list inherited annotations and annotation sets
    8284    test_list_inherited_annotations(rawBioAssayId, 2);
     85    test_list_allinherited_annotations(rawBioAssayId, 9);
    8386    test_list_inherited_annotationsets(rawBioAssayId, 1);
    8487    test_list_inheriting_annotationsets(arrayDesignId, 1);
     
    342345    }
    343346  }
     347 
     348  static void test_list_allinherited_annotations(int rawBioAssayId, int expectedResults)
     349  {
     350    if (rawBioAssayId == 0) return;
     351    DbControl dc = null;
     352    try
     353    {
     354      dc = TestUtil.getDbControl();
     355      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     356      ItemQuery<Annotation> query = rba.getAnnotationSet().getAllInheritedAnnotations();
     357      query.join(Hql.innerJoin(null, "annotationType", "at", true));
     358      query.order(Orders.asc(Hql.property("at", "name")));
     359      List<Annotation> l = query.list(dc);
     360      for (int i = 0; i<l.size(); i++)
     361      {
     362        write_item(i, l.get(i));
     363      }
     364      if (expectedResults >= 0 && expectedResults != l.size())
     365      {
     366        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     367      }
     368      write("--List all inherited annotations OK ("+l.size()+")");
     369    }
     370    catch (Throwable ex)
     371    {
     372      write("--List all inherited annotations FAILED");
     373      ex.printStackTrace();
     374      ok = false;
     375    }
     376    finally
     377    {
     378      if (dc != null) dc.close();
     379    }
     380  }
    344381
    345382  static void test_list_inherited_annotationsets(int rawBioAssayId, int expectedResults)
Note: See TracChangeset for help on using the changeset viewer.