use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class AnnotationsTest method testCurate.
@Test
public void testCurate() throws Exception {
Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Assert.assertNotNull(plasmid);
SequenceDAO sequenceDAO = new SequenceDAO();
Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
PartSequence partSequence = new PartSequence(account.getEmail(), plasmid.getRecordId());
partSequence.save(dnaSequence);
SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
Assert.assertEquals(1, sequenceFeatures.size());
Feature feature = sequenceFeatures.get(0).getFeature();
DNAFeature dnaFeature = feature.toDataTransferObject();
Curation curation = new Curation();
curation.setExclude(true);
dnaFeature.setCuration(curation);
List<DNAFeature> features = new ArrayList<>();
features.add(dnaFeature);
Annotations annotations = new Annotations(account.getEmail());
annotations.curate(features);
sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
feature = sequenceFeatures.get(0).getFeature();
Assert.assertTrue(feature.getCuration().isExclude());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class TransferredPartsTest method testReceiveTransferredEntry.
@Test
public void testReceiveTransferredEntry() throws Exception {
Account account = AccountCreator.createTestAccount("testReceivedTransferredEntry", false);
Strain strain = createStrainObject(account);
Plasmid plasmid = createPlasmidObject(account);
// link the two
PartData strainData = strain.toDataTransferObject();
PartData plasmidData = plasmid.toDataTransferObject();
strainData.getLinkedParts().add(plasmidData);
strainData = parts.receiveTransferredEntry(strainData);
Assert.assertNotNull(strainData);
strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
Assert.assertNotNull(strain);
Assert.assertTrue(strain.getVisibility() == Visibility.TRANSFERRED.getValue());
plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
Assert.assertNotNull(plasmid);
Assert.assertTrue(plasmid.getVisibility() == Visibility.TRANSFERRED.getValue());
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
// create new plasmid
Plasmid plasmid2 = createPlasmidObject(account);
strainData.getLinkedParts().add(plasmid2.toDataTransferObject());
Assert.assertEquals(2, strainData.getLinkedParts().size());
// transfer strain (with 2 linked plasmids)
PartData received = parts.receiveTransferredEntry(strainData);
Assert.assertNotNull(received);
// check return
strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
Assert.assertNotNull(strain);
plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
Assert.assertNotNull(plasmid);
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
plasmid2 = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(1).getId());
Assert.assertNotNull(plasmid2);
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid2));
}
use of org.jbei.ice.storage.model.Plasmid 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.Plasmid 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.assertEquals(1, results.size());
Assert.assertEquals(strain.getId(), results.get(0).getId());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class EntryHistoryTest method testDeleteAll.
@Test
public void testDeleteAll() throws Exception {
Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAll", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAllReader", false);
EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
entryHistory.add();
entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
Results<History> history = entryHistory.get(20, 0, true, null);
Assert.assertNotNull(history);
Assert.assertEquals(1, entryHistory.deleteAll());
history = entryHistory.get(20, 0, true, null);
Assert.assertEquals(0, history.getResultCount());
}
Aggregations