Search in sources :

Example 16 with Strain

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

the class PermissionDAOTest method makePrivateEntryIds.

public List<Long> makePrivateEntryIds(Account ownerAccount) throws Exception {
    List<Long> entryIds = new ArrayList<>(3);
    for (int i = 0; i < 3; i++) {
        Strain strain = TestEntryCreator.createTestStrain(ownerAccount);
        entryIds.add(strain.getId());
    }
    return entryIds;
}
Also used : ArrayList(java.util.ArrayList) Strain(org.jbei.ice.storage.model.Strain)

Example 17 with Strain

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

the class CustomFieldsTest method testUpdateField.

@Test
public void testUpdateField() throws Exception {
    Account account = AccountCreator.createTestAccount("testUpdateField", false);
    Assert.assertNotNull(account);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    CustomField field = new CustomField(0, strain.getId(), "Afoo2", "Bbar2");
    long id = fields.createField(userId, strain.getId(), field).getId();
    // update
    field.setId(id);
    field.setName("foo2");
    field.setValue("bar2");
    field = fields.updateField(userId, id, field);
    // verify
    CustomField created = fields.getField(userId, id);
    Assert.assertEquals(created.getName(), field.getName());
    Assert.assertEquals(created.getValue(), field.getValue());
    Assert.assertEquals(created.getId(), id);
    // check what is associated with entry
    strain = (Strain) DAOFactory.getEntryDAO().get(strain.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getParameters().size() == 1);
    created = strain.getParameters().get(0).toDataTransferObject();
    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 18 with Strain

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

the class CustomFieldsTest method testDeleteField.

@Test
public void testDeleteField() throws Exception {
    Account account = AccountCreator.createTestAccount("testDeleteField", false);
    Assert.assertNotNull(account);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    CustomField field = new CustomField(strain.getId(), "foo3", "bar3");
    long id = fields.createField(userId, strain.getId(), field).getId();
    // verify custom field creation
    strain = (Strain) DAOFactory.getEntryDAO().get(strain.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getParameters().size() == 1);
    CustomField created = strain.getParameters().get(0).toDataTransferObject();
    Assert.assertEquals(created.getName(), field.getName());
    Assert.assertEquals(created.getValue(), field.getValue());
    Assert.assertEquals(created.getId(), id);
    // delete custom field
    Assert.assertTrue(fields.deleteField(userId, id));
    //verify deletion
    Assert.assertNull(DAOFactory.getParameterDAO().get(id));
    strain = (Strain) DAOFactory.getEntryDAO().get(strain.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getParameters().isEmpty());
}
Also used : Account(org.jbei.ice.storage.model.Account) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 19 with Strain

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

the class EntryCreatorTest method testCreatePart.

@Test
public void testCreatePart() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreatePart", false);
    Assert.assertNotNull(account);
    String userId = account.getEmail();
    // create strain
    PartData strain = new PartData(EntryType.STRAIN);
    StrainData strainData = new StrainData();
    strainData.setGenotypePhenotype("genPhen");
    strainData.setHost("host");
    strain.setStrainData(strainData);
    strain.setOwner("Tester");
    strain.setOwnerEmail("tester");
    strain.setCreator(strain.getOwner());
    strain.setCreatorEmail(strain.getOwnerEmail());
    strain.setBioSafetyLevel(1);
    long id = creator.createPart(userId, strain).getId();
    Strain entry = (Strain) DAOFactory.getEntryDAO().get(id);
    Assert.assertNotNull(entry);
    Assert.assertEquals(entry.getOwnerEmail(), strain.getOwnerEmail());
    Assert.assertEquals(strainData.getGenotypePhenotype(), entry.getGenotypePhenotype());
    Assert.assertEquals(strainData.getHost(), entry.getHost());
    // create arabidopsis seed
    PartData seed = new PartData(EntryType.ARABIDOPSIS);
    ArabidopsisSeedData seedData = new ArabidopsisSeedData();
    seedData.setGeneration(Generation.F3);
    seedData.setPlantType(PlantType.OTHER);
    seedData.setHarvestDate("01/02/2014");
    seed.setBioSafetyLevel(2);
    seed.setArabidopsisSeedData(seedData);
    long seedId = creator.createPart(userId, seed).getId();
    ArabidopsisSeed entrySeed = (ArabidopsisSeed) DAOFactory.getEntryDAO().get(seedId);
    Assert.assertNotNull(entrySeed);
    Assert.assertEquals(seedData.getGeneration(), entrySeed.getGeneration());
    Assert.assertEquals(seedData.getPlantType(), entrySeed.getPlantType());
}
Also used : Account(org.jbei.ice.storage.model.Account) ArabidopsisSeed(org.jbei.ice.storage.model.ArabidopsisSeed) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 20 with Strain

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

the class CustomFieldsTest method testCreateField.

@Test
public void testCreateField() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreateField", false);
    Assert.assertNotNull(account);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    CustomField field = new CustomField(0, strain.getId(), "foo", "bar");
    long id = fields.createField(userId, strain.getId(), field).getId();
    strain = (Strain) DAOFactory.getEntryDAO().get(strain.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getParameters().size() == 1);
    CustomField created = strain.getParameters().get(0).toDataTransferObject();
    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)

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