Changeset 5732


Ignore:
Timestamp:
Sep 12, 2011, 12:57:44 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1615: Add test program in BASE 2.17 that create data that need special handling when updating to BASE 3

  • Added some images to scans.
  • Simulate context related to filtering and sorting on fileType, softwareType, etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.17-stable/src/test/net/sf/basedb/test/roles/ExtraTest.java

    r5702 r5732  
    2929import net.sf.basedb.core.BioMaterial;
    3030import net.sf.basedb.core.BioWell.LockMode;
     31import net.sf.basedb.core.Application;
    3132import net.sf.basedb.core.BioMaterialEvent;
    3233import net.sf.basedb.core.BioMaterialList;
    3334import net.sf.basedb.core.DbControl;
    3435import net.sf.basedb.core.Extract;
     36import net.sf.basedb.core.File;
     37import net.sf.basedb.core.FileType;
     38import net.sf.basedb.core.HardwareType;
    3539import net.sf.basedb.core.Hybridization;
     40import net.sf.basedb.core.Image;
    3641import net.sf.basedb.core.Include;
    3742import net.sf.basedb.core.Item;
     43import net.sf.basedb.core.ItemContext;
    3844import net.sf.basedb.core.ItemParameterType;
    3945import net.sf.basedb.core.ItemQuery;
     
    4248import net.sf.basedb.core.LabeledExtract;
    4349import net.sf.basedb.core.MeasuredBioMaterial;
     50import net.sf.basedb.core.Operator;
    4451import net.sf.basedb.core.Platform;
    4552import net.sf.basedb.core.PluginConfiguration;
    4653import net.sf.basedb.core.PluginDefinition;
    4754import net.sf.basedb.core.Project;
     55import net.sf.basedb.core.PropertyFilter;
     56import net.sf.basedb.core.ProtocolType;
    4857import net.sf.basedb.core.RawBioAssay;
    4958import net.sf.basedb.core.RawDataType;
     
    5160import net.sf.basedb.core.Sample;
    5261import net.sf.basedb.core.Scan;
     62import net.sf.basedb.core.SessionControl;
     63import net.sf.basedb.core.SoftwareType;
     64import net.sf.basedb.core.SystemItems;
    5365import net.sf.basedb.core.Type;
    5466import net.sf.basedb.core.query.Expressions;
    5567import net.sf.basedb.core.query.Hql;
    5668import net.sf.basedb.core.query.Restrictions;
     69import net.sf.basedb.test.FileUtil;
    5770import net.sf.basedb.test.TestUtil;
    5871import net.sf.basedb.util.ArrayIterator;
     
    7487  {
    7588    DbControl dc = null;
     89    SessionControl sc = null;
    7690    TestUtil.write("++Entering extra tests\n");
    7791    try
    7892    {
     93      // Fake that we are using the web client since we want to
     94      // create context settings for the list pages
     95      sc = Application.newSessionControl("net.sf.basedb.clients.web", TestUtil.getLocalIp(), null);
     96      sc.login("extra", "extra", "Running extra test program", false);
     97      dc = sc.newDbControl();
     98     
    7999      // Activate project
    80       TestUtil.login("extra", "extra", false);
    81       dc = TestUtil.getDbControl();
    82100      Project p = Util.findProject(dc, "Project A");
    83       TestUtil.getSessionControl().setActiveProject(p);
     101      sc.setActiveProject(p);
    84102
    85103      // Create annotation types, for Labeled extract, Hybridization and
     
    98116      Platform affymetrix = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
    99117      RawDataType genepix = RawDataTypes.getSafeRawDataType("genepix");
     118      File redFile = FileUtil.uploadFile(dc, "/data", "spots.tif", FileType.IMAGE);
     119      File greenFile = FileUtil.uploadFile(dc, "/data", "test.upload.png", FileType.IMAGE);
    100120     
    101121      // Create biomaterials with no parent items
     
    111131      poolBioMaterial(dc, ple, "Labeled extract A.%h");
    112132     
    113       // Create hyb, scan and raw bioassays
     133      // Create hybs, scans, images and raw bioassays
    114134      Hybridization hyb = UserTest.createHybridization(dc, "Hyb2Channel-3.0", null, false, le, ple);
    115135      Hybridization hyb2 = UserTest.createHybridization(dc, "HybMultiArray-3.0", null, true, le, ple);
    116136      Scan scan = UserTest.createScan(dc, "Scan2Channel-3.0", hyb, null, null);
    117137      Scan scan2 = UserTest.createScan(dc, "ScanMultiArray-3.0", hyb2, null, null);
     138      createImage(dc, "RedImage-3.0", scan, redFile);
     139      createImage(dc, "GreenImage-3.0", scan, greenFile);
    118140      RawBioAssay rba1 = UserTest.createRawBioAssay(dc, generic, genepix, "RawBioAssay-3.0", scan, null);
    119141      RawBioAssay rba2 = UserTest.createRawBioAssay(dc, affymetrix, null, "RawBioAssay[1]-3.0", scan2, null);
     
    143165      createBioMaterialList(dc, "Labeled extracts", le);
    144166     
     167      // Set filter, sort order, etc. on some contexts
     168      TestUtil.write("--Creating context for: PROTOCOL\n");
     169      ItemContext cc = sc.getCurrentContext(Item.PROTOCOL);
     170      cc.setSortProperty("protocolType.name");
     171      cc.setPropertyFilter(new PropertyFilter("protocolType", Operator.IN,
     172        SystemItems.getId(ProtocolType.EXTRACTION) + "|"+SystemItems.getId(ProtocolType.SAMPLING), Type.INT));
     173      TestUtil.write("--Creating context for: PROTOCOLTYPE\n");
     174      cc = sc.getCurrentContext(Item.PROTOCOLTYPE);
     175      cc.setSortProperty("name");
     176      cc.setSetting("base-3.0", "should be gone after update");
     177     
     178      TestUtil.write("--Creating context for: SOFTWARE\n");
     179      cc = sc.getCurrentContext(Item.SOFTWARE);
     180      cc.setSortProperty("softwareType.name");
     181      cc.setPropertyFilter(new PropertyFilter("softwareType", Operator.EQ,
     182          SystemItems.getId(SoftwareType.FEATURE_EXTRACTION) + "", Type.INT));
     183      TestUtil.write("--Creating context for: SOFTWARETYPE\n");
     184      cc = sc.getCurrentContext(Item.SOFTWARETYPE);
     185      cc.setSortProperty("name");
     186      cc.setSetting("base-3.0", "should be gone after update");
     187
     188      TestUtil.write("--Creating context for: HARDWARE\n");
     189      cc = sc.getCurrentContext(Item.HARDWARE);
     190      cc.setSortProperty("hardwareType.name");
     191      cc.setPropertyFilter(new PropertyFilter("hardwareType", Operator.IN,
     192          SystemItems.getId(HardwareType.SCANNER) + "|" + SystemItems.getId(HardwareType.FREEZER), Type.INT));
     193      TestUtil.write("--Creating context for: HARDWARETYPE\n");
     194      cc = sc.getCurrentContext(Item.HARDWARETYPE);
     195      cc.setSortProperty("name");
     196      cc.setSetting("base-3.0", "should be gone after update");
     197
     198      TestUtil.write("--Creating context for: FILE\n");
     199      cc = sc.getCurrentContext(Item.FILE);
     200      cc.setSortProperty("fileType.name");
     201      cc.setPropertyFilter(new PropertyFilter("fileType", Operator.IN,
     202          SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT));
     203      TestUtil.write("--Creating context for: FILETYPE\n");
     204      cc = sc.getCurrentContext(Item.FILETYPE);
     205      cc.setSortProperty("name");
     206      cc.setSetting("base-3.0", "should be gone after update");
     207
     208      TestUtil.write("--Creating context for: MIMETYPE\n");
     209      cc = sc.getCurrentContext(Item.MIMETYPE);
     210      cc.setSortProperty("fileType.name");
     211      cc.setPropertyFilter(new PropertyFilter("fileType", Operator.IN,
     212          SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT));
     213
     214      TestUtil.write("--Creating context for: DATAFILETYPE\n");
     215      cc = sc.getCurrentContext(Item.DATAFILETYPE);
     216      cc.setSortProperty("genericType.name");
     217      cc.setPropertyFilter(new PropertyFilter("genericType", Operator.IN,
     218          SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT));
     219
    145220      dc.commit();
    146       TestUtil.logout();
     221      TestUtil.write("--Logging out\n");
     222      sc.logout();
    147223    }
    148224    catch (Throwable t)
     
    171247      String name, PluginDefinition plugin, BasicItem... parameters)
    172248  {
     249    TestUtil.write("--Creating fake plug-in configuration: " + name + " for plug-in " + plugin.getName() + "\n");
    173250    PluginConfiguration config = plugin.newPluginConfiguration();
    174251    config.setName(name);
     
    186263  public static Job createJob(DbControl dc, String name, BasicItem... parameters)
    187264  {
     265    TestUtil.write("--Creating fake job: " + name + "\n");
    188266    Job job = Job.getNew(dc, null, null, null);
    189267    job.setName(name);
     
    201279    BioMaterial... items)
    202280  {
     281    TestUtil.write("--Creating biomaterial list: " + name + "\n");
    203282    BioMaterialList list = BioMaterialList.getNew(dc, items[0].getType());
    204283    list.setName(name);
     
    211290      String parentNamePattern)
    212291  {
     292    TestUtil.write("--Creating pooled biomaterial: " + bioMaterial.getName() + "\n");
    213293    bioMaterial.setPooled(true);
    214294    BioMaterialEvent event = bioMaterial.getCreationEvent();
     
    237317    }
    238318  }
     319 
     320  /**
     321    Create an image.
     322  */
     323  public static Image createImage(DbControl dc, String name, Scan scan, File file)
     324  {
     325    TestUtil.write("--Creating image: " + name + "\n");
     326    Image img = Image.getNew(dc, scan);
     327    img.setFile(file);
     328    dc.saveItem(img);
     329    return img;
     330  }
     331 
    239332}
Note: See TracChangeset for help on using the changeset viewer.