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