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());
}
use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.
the class TestEntryCreator method createTestPlasmid.
public static Plasmid createTestPlasmid(Account account) throws Exception {
Plasmid plasmid = new Plasmid();
plasmid.setBackbone("plasmid backone");
plasmid.setOriginOfReplication("None");
plasmid.setBioSafetyLevel(1);
plasmid.setShortDescription("plasmid description");
plasmid.setName("pLasmid");
plasmid = (Plasmid) new EntryCreator().createEntry(account, plasmid, null);
return plasmid;
}
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 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());
}
Aggregations