use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class EntryLinksTest method testAddLink.
@Test
public void testAddLink() throws Exception {
Account account = AccountCreator.createTestAccount("testAddLink", false);
String userId = account.getEmail();
Account differentAccount = AccountCreator.createTestAccount("testAddLink2", false);
//create strain and plasmid
Strain strain = TestEntryCreator.createTestStrain(account);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(differentAccount);
// give each account read permissions
AccessPermission accessPermission = new AccessPermission(AccessPermission.Article.ACCOUNT, account.getId(), AccessPermission.Type.READ_ENTRY, plasmid.getId(), "");
PermissionsController permissionsController = new PermissionsController();
Assert.assertNotNull(permissionsController.addPermission(differentAccount.getEmail(), accessPermission));
accessPermission = new AccessPermission(AccessPermission.Article.ACCOUNT, differentAccount.getId(), AccessPermission.Type.READ_ENTRY, strain.getId(), "");
Assert.assertNotNull(permissionsController.addPermission(account.getEmail(), accessPermission));
// add plasmid links to strain
EntryLinks entryLinks = new EntryLinks(userId, Long.toString(strain.getId()));
// attempt to add as a parent (expected to fail)
Assert.assertFalse(entryLinks.addLink(plasmid.toDataTransferObject(), LinkType.PARENT));
// now add as a child
Assert.assertTrue(entryLinks.addLink(plasmid.toDataTransferObject(), LinkType.CHILD));
// add second plasmid
Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
Assert.assertTrue(entryLinks.addLink(plasmid2.toDataTransferObject(), LinkType.CHILD));
}
use of org.jbei.ice.storage.model.Account 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());
}
use of org.jbei.ice.storage.model.Account 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;
}
}
use of org.jbei.ice.storage.model.Account 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());
}
}
}
}
use of org.jbei.ice.storage.model.Account 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);
}
Aggregations