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;
}
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);
}
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());
}
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());
}
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);
}
Aggregations