Search in sources :

Example 6 with Strain

use of org.jbei.ice.storage.model.Strain in project ice by JBEI.

the class SampleServiceTest method testGetSamplesByBarcode.

@Test
public void testGetSamplesByBarcode() throws Exception {
    Account account = AccountCreator.createTestAccount("SampleServiceTest.testGetSamplesByBarcode", false);
    String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    PartSample partSample = new PartSample();
    partSample.setLabel("test");
    StorageLocation location = new StorageLocation();
    location.setDisplay("tube");
    location.setType(SampleType.TUBE);
    partSample.setLocation(location);
    partSample = service.createSample(userId, Long.toString(strain.getId()), partSample, null);
    Assert.assertNotNull(partSample);
    List<PartSample> partSamples = service.getSamplesByBarcode(userId, location.getDisplay());
    Assert.assertNotNull(partSamples);
    Assert.assertEquals(1, partSamples.size());
}
Also used : Account(org.jbei.ice.storage.model.Account) PartSample(org.jbei.ice.lib.dto.sample.PartSample) StorageLocation(org.jbei.ice.lib.dto.StorageLocation) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 7 with Strain

use of org.jbei.ice.storage.model.Strain in project ice by JBEI.

the class SampleServiceTest method testCreateSample.

@Test
public void testCreateSample() throws Exception {
    Account account = AccountCreator.createTestAccount("SampleServiceTest.testCreateSample", false);
    String userId = account.getEmail();
    // create 96 strains
    Map<Long, String> idPartNumberMap = new HashMap<>();
    for (int i = 0; i < 96; i += 1) {
        Strain strain = TestEntryCreator.createTestStrain(account);
        Assert.assertNotNull(strain);
        idPartNumberMap.put(strain.getId(), strain.getPartNumber());
    }
    Assert.assertEquals(96, idPartNumberMap.size());
    String mainPlate = "0000000001";
    // create main plate
    createPlateSamples(userId, mainPlate, idPartNumberMap);
    List<Storage> storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(mainPlate, SampleType.PLATE96);
    Assert.assertNotNull(storageList);
    Assert.assertEquals(1, storageList.size());
    // retrieve samples for entries
    int i = 0;
    for (String partNumber : idPartNumberMap.values()) {
        List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
        Assert.assertNotNull(samples);
        Assert.assertTrue(samples.size() == 1);
        verifyMainPlate(samples.get(0), i, mainPlate);
        i += 1;
    }
    // create backup 1
    String backUp1Plate = "0000000002";
    createPlateSamples(userId, backUp1Plate, idPartNumberMap);
    storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(backUp1Plate, SampleType.PLATE96);
    Assert.assertNotNull(storageList);
    Assert.assertEquals(1, storageList.size());
    // retrieve samples for entries
    i = 0;
    for (String partNumber : idPartNumberMap.values()) {
        List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
        Assert.assertNotNull(samples);
        Assert.assertTrue(samples.size() == 2);
        verifyMainPlate(samples.get(0), i, mainPlate, backUp1Plate);
        verifyMainPlate(samples.get(1), i, mainPlate, backUp1Plate);
        i += 1;
    }
    // create backup 2
    String backUp2Plate = "0000000003";
    createPlateSamples(userId, backUp2Plate, idPartNumberMap);
    storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(backUp1Plate, SampleType.PLATE96);
    Assert.assertNotNull(storageList);
    Assert.assertEquals(1, storageList.size());
    // retrieve samples for entries
    i = 0;
    for (String partNumber : idPartNumberMap.values()) {
        List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
        Assert.assertNotNull(samples);
        Assert.assertTrue(samples.size() == 3);
        verifyMainPlate(samples.get(0), i, mainPlate, backUp1Plate, backUp2Plate);
        verifyMainPlate(samples.get(1), i, mainPlate, backUp1Plate, backUp2Plate);
        verifyMainPlate(samples.get(2), i, mainPlate, backUp1Plate, backUp2Plate);
        i += 1;
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) Storage(org.jbei.ice.storage.model.Storage) HashMap(java.util.HashMap) PartSample(org.jbei.ice.lib.dto.sample.PartSample) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 8 with Strain

use of org.jbei.ice.storage.model.Strain in project ice by JBEI.

the class SampleServiceTest method testRetrieveEntrySamples.

@Test
public void testRetrieveEntrySamples() throws Exception {
    Account account = AccountCreator.createTestAccount("SampleServiceTest.testRetrieveEntrySamples", false);
    String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    long entryId = strain.getId();
    List<PartSample> samplesList = service.retrieveEntrySamples(userId, Long.toString(entryId));
    Assert.assertNotNull(samplesList);
    for (PartSample partSample : samplesList) {
        Assert.assertNotNull(partSample.getId());
        Assert.assertNotNull(partSample.getCreationTime());
        Assert.assertNotNull(partSample.getLabel());
        Assert.assertNotNull(partSample.getLocation());
        Assert.assertNotNull(partSample.getDepositor());
        Assert.assertNotNull(partSample.getId());
        Assert.assertNotNull(partSample.isCanEdit());
        StorageLocation location = partSample.getLocation();
        while (location.getChild() != null) {
            location = location.getChild();
            Assert.assertNotNull(location.getType());
            Assert.assertNotNull(location.getId());
            Assert.assertNotNull(location.getDisplay());
            Assert.assertNotNull(location.getName());
        }
        if (partSample.getComments() != null) {
            for (UserComment comment : partSample.getComments()) {
                Assert.assertNotNull(comment.getId());
                Assert.assertNotNull(comment.getMessage());
            }
        }
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) UserComment(org.jbei.ice.lib.dto.comment.UserComment) PartSample(org.jbei.ice.lib.dto.sample.PartSample) StorageLocation(org.jbei.ice.lib.dto.StorageLocation) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 9 with Strain

use of org.jbei.ice.storage.model.Strain in project ice by JBEI.

the class CustomFieldsTest method testGetField.

@Test
public void testGetField() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetField", false);
    Assert.assertNotNull(account);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    CustomField field = new CustomField(0, strain.getId(), "foo1", "bar1");
    long id = fields.createField(userId, strain.getId(), field).getId();
    CustomField created = fields.getField(userId, id);
    Assert.assertEquals(created.getName(), field.getName());
    Assert.assertEquals(created.getValue(), field.getValue());
    Assert.assertEquals(created.getId(), id);
}
Also used : Account(org.jbei.ice.storage.model.Account) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 10 with Strain

use of org.jbei.ice.storage.model.Strain in project ice by JBEI.

the class CustomFieldsTest method testGetPartsByFields.

@Test
public void testGetPartsByFields() throws Exception {
    // create part
    Account account = AccountCreator.createTestAccount("testGetPartsByFields", false);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    // create fields for strain
    long strainId = strain.getId();
    fields.createField(userId, strainId, new CustomField(strainId, "type", "promoter"));
    fields.createField(userId, strainId, new CustomField(strainId, "strength", "weak"));
    // search for strength:weak
    List<CustomField> searchFields = new ArrayList<>();
    searchFields.add(new CustomField("strength", "weak"));
    List<PartData> results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(1, results.size());
    // create additional entry
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Assert.assertNotNull(plasmid);
    long plasmidId = plasmid.getId();
    fields.createField(userId, plasmidId, new CustomField(plasmidId, "type", "promoter"));
    fields.createField(userId, plasmidId, new CustomField(plasmidId, "strength", "strong"));
    searchFields.clear();
    searchFields.add(new CustomField("strength", "strong"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(plasmid.getId(), results.get(0).getId());
    // search for type:promoter
    searchFields.clear();
    searchFields.add(new CustomField("type", "promoter"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(strain.getId() == results.get(0).getId() || results.get(1).getId() == strain.getId());
    // test two
    searchFields.clear();
    searchFields.add(new CustomField(strainId, "type", "promoter"));
    searchFields.add(new CustomField(strainId, "strength", "weak"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertNotNull(results);
    Assert.assertTrue(results.size() == 1);
    Assert.assertEquals(strain.getId(), results.get(0).getId());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) ArrayList(java.util.ArrayList) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Aggregations

Strain (org.jbei.ice.storage.model.Strain)23 Account (org.jbei.ice.storage.model.Account)20 Test (org.junit.Test)19 Plasmid (org.jbei.ice.storage.model.Plasmid)6 PartData (org.jbei.ice.lib.dto.entry.PartData)5 PartSample (org.jbei.ice.lib.dto.sample.PartSample)4 ArrayList (java.util.ArrayList)3 StorageLocation (org.jbei.ice.lib.dto.StorageLocation)3 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)3 HashSet (java.util.HashSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 PermissionsController (org.jbei.ice.lib.access.PermissionsController)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1 UserComment (org.jbei.ice.lib.dto.comment.UserComment)1 PageParameters (org.jbei.ice.lib.dto.common.PageParameters)1 SequenceInfo (org.jbei.ice.lib.dto.entry.SequenceInfo)1 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)1