use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class EntryHistoryTest method testAdd.
@Test
public void testAdd() throws Exception {
Account account = AccountCreator.createTestAccount("EntryHistoryTest.testAdd", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testAddReader", false);
EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
Assert.assertTrue(entryHistory.add());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class EntryLinksTest method testGetParents.
@Test
public void testGetParents() throws Exception {
Account account = AccountCreator.createTestAccount("testGetParents", false);
String userId = account.getEmail();
// add plasmid links to strain
Strain strain = TestEntryCreator.createTestStrain(account);
EntryLinks entryLinks = new EntryLinks(userId, Long.toString(strain.getId()));
Assert.assertEquals(0, entryLinks.getParents().size());
// attempt to add as a parent (expected to fail)
Plasmid plasmid1 = TestEntryCreator.createTestPlasmid(account);
Assert.assertFalse(entryLinks.addLink(plasmid1.toDataTransferObject(), LinkType.PARENT));
// now add as a child
Assert.assertTrue(entryLinks.addLink(plasmid1.toDataTransferObject(), LinkType.CHILD));
// add second plasmid
Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
Assert.assertTrue(entryLinks.addLink(plasmid2.toDataTransferObject(), LinkType.CHILD));
List<PartData> children = entryLinks.getChildren();
Assert.assertEquals(2, children.size());
EntryLinks plasmidLinks = new EntryLinks(userId, Long.toString(plasmid1.getId()));
Assert.assertEquals(1, plasmidLinks.getParents().size());
EntryLinks plasmid2Links = new EntryLinks(userId, Long.toString(plasmid2.getId()));
Assert.assertEquals(1, plasmid2Links.getParents().size());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class EntryLinksTest method testGetChildren.
@Test
public void testGetChildren() throws Exception {
Account account = AccountCreator.createTestAccount("testGetChildren", false);
String userId = account.getEmail();
// create alternate account
Account account2 = AccountCreator.createTestAccount("testGetChildren2", true);
// add plasmid links to strain
Strain strain = TestEntryCreator.createTestStrain(account);
EntryLinks entryLinks = new EntryLinks(userId, Long.toString(strain.getId()));
Assert.assertEquals(0, entryLinks.getChildren().size());
// attempt to add as a parent (expected to fail)
Plasmid plasmid1 = TestEntryCreator.createTestPlasmid(account);
Assert.assertFalse(entryLinks.addLink(plasmid1.toDataTransferObject(), LinkType.PARENT));
// now add as a child
Assert.assertTrue(entryLinks.addLink(plasmid1.toDataTransferObject(), LinkType.CHILD));
// add second plasmid
Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
Assert.assertTrue(entryLinks.addLink(plasmid2.toDataTransferObject(), LinkType.CHILD));
List<PartData> children = entryLinks.getChildren();
Assert.assertEquals(2, children.size());
// create plasmid for alternate account
Strain alternateStrain = TestEntryCreator.createTestStrain(account2);
// add as child to account's strain
EntryLinks alternateLinks = new EntryLinks(account2.getEmail(), Long.toString(strain.getId()));
Assert.assertTrue(alternateLinks.addLink(alternateStrain.toDataTransferObject(), LinkType.CHILD));
// account2 should see three children (since it is an admin)
Assert.assertEquals(3, alternateLinks.getChildren().size());
// but account should still see 2 since it does not have read permissions on account2's entry
Assert.assertEquals(2, entryLinks.getChildren().size());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class RemoteTransferTest method testGetPartsForTransfer.
@Test
public void testGetPartsForTransfer() throws Exception {
EntryDAO dao = DAOFactory.getEntryDAO();
Account account = AccountCreator.createTestAccount("testGetPartsForTransfer", false);
Strain strain = TestEntryCreator.createTestStrain(account);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
strain.getLinkedEntries().add(plasmid);
DAOFactory.getEntryDAO().update(strain);
strain = (Strain) DAOFactory.getEntryDAO().get(strain.getId());
Assert.assertTrue(strain.getLinkedEntries().size() == 1);
Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
strain.getLinkedEntries().add(plasmid2);
dao.update(strain);
Plasmid plasmid3 = TestEntryCreator.createTestPlasmid(account);
Strain strain2 = TestEntryCreator.createTestStrain(account);
strain2.getLinkedEntries().add(plasmid2);
strain2.getLinkedEntries().add(plasmid3);
dao.update(strain2);
ArrayList<Long> ids = new ArrayList<>();
ids.add(plasmid.getId());
ids.add(plasmid2.getId());
ids.add(plasmid3.getId());
ids.add(strain.getId());
ids.add(strain2.getId());
List<PartData> data = transfer.getPartsForTransfer(ids);
TransferredParts parts = new TransferredParts();
Assert.assertEquals(data.size(), 2);
for (PartData datum : data) {
// both should have 2 linked entries with 1 in common
Assert.assertEquals(datum.getLinkedParts().size(), 2);
// transfer
datum.setRecordId("");
PartData transferred = parts.receiveTransferredEntry(datum);
Assert.assertNotNull(transferred);
}
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class SequenceDAOTest method testSequenceString.
@Test
public void testSequenceString() throws Exception {
Account account = AccountCreator.createTestAccount("SequenceDAOTest.testSequenceString", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Assert.assertNotNull(plasmid);
// parse sequence and associate with plasmid
FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
Sequence sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
Assert.assertNotNull(sequence);
sequence.setEntry(plasmid);
sequence = sequenceDAO.create(sequence);
Assert.assertNotNull(sequence);
// get
Optional<String> result = sequenceDAO.getSequenceString(plasmid);
Assert.assertTrue(result.isPresent());
Assert.assertEquals(result.get(), dnaSequence.getSequence());
}
Aggregations