Changeset 5072


Ignore:
Timestamp:
Aug 21, 2009, 9:07:59 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #108: Logging the change history of an item

Added some more tests to the test program.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/test/TestChangeHistory.java

    r5039 r5072  
    3535import net.sf.basedb.core.ItemResultList;
    3636import net.sf.basedb.core.ProgressReporter;
     37import net.sf.basedb.core.Type;
    3738import net.sf.basedb.core.User;
    3839import net.sf.basedb.core.log.LogManagerFactory;
     
    6566    int bioSourceId = TestBioSource.test_create("Biosource 1", false);
    6667    int sampleId = TestSample.test_create(bioSourceId, "Sample 1", false);
     68    int annotationTypeId = TestAnnotationType.test_create("change", Type.INT, 0, null, null, Item.SAMPLE, 1, null, false);
     69    TestAnnotation.test_annotatate(Item.SAMPLE, sampleId, annotationTypeId, 0, 1);
     70    TestAnnotation.test_annotatate(Item.SAMPLE, sampleId, annotationTypeId, 0, 2);
     71    TestAnnotation.test_remove_annotation(Item.SAMPLE, sampleId, annotationTypeId);
    6772    int extractId = TestExtract.test_create(sampleId, false);
    6873    TestExtract.test_delete(extractId);
    6974   
    7075    test_list_by_item(Item.BIOSOURCE, bioSourceId, 1);
    71     test_list_by_user(TestUtil.getSessionControl().getLoggedInUserId(), since, 4);
     76    test_list_by_item(Item.SAMPLE, sampleId, 6);
     77    /*
     78      Total change log events:
     79      4 CREATE (biosource, sample, annotationtype, extract)
     80      5 UPDATE (when adding, updating and removing the annotation from the sample)
     81      1 DELETE (extract)
     82    */
     83    test_list_by_user(TestUtil.getSessionControl().getLoggedInUserId(), since, 10);
    7284   
    7385    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     
    7587    TestSample.test_delete(sampleId);
    7688    TestBioSource.test_delete(bioSourceId);
    77     test_delete_stray(6);
     89    TestAnnotationType.test_delete(annotationTypeId);
     90    test_delete_stray(13);
    7891    set_log_manager(old);
    7992    write("++Testing change history "+(ok ? "OK" : "Failed")+"\n");
     
    98111        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
    99112      }
    100       write("--List history of item OK ("+l.size()+")");
     113      write("--List history of " + item + " OK ("+l.size()+")");
    101114    }
    102115    catch (Throwable ex)
    103116    {
    104       write("--List history of item FAILED");
     117      write("--List history of " + itemType + "[id=" + itemId + "] FAILED");
    105118      ex.printStackTrace();
    106119      ok = false;
     
    160173    throws BaseException
    161174  {
    162     BasicItem item = null;
    163     try
    164     {
    165       item = c.getItem(null);
     175    String item = null;
     176    try
     177    {
     178      BasicItem b = c.getItem(null);
     179      item = b.toString();
    166180    }
    167181    catch (ItemNotFoundException ex)
    168     {}
     182    {
     183      item = c.getItemType() + "[id=" + c.getItemId() + "; not found]";
     184    }
    169185    if (!TestUtil.getSilent()) System.out.println(i+":\t"+c.getId()+"\t"+c.getTime()+"\t"+
    170186      c.getChangeType() + "\t" + item + "\t" + c.getChangeInfo()+"\t"+c.getUser(null));
Note: See TracChangeset for help on using the changeset viewer.