Search in sources :

Example 6 with Plasmid

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());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) History(org.jbei.ice.lib.dto.History) Test(org.junit.Test)

Example 7 with Plasmid

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;
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) EntryCreator(org.jbei.ice.lib.entry.EntryCreator)

Example 8 with 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());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 9 with Plasmid

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());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 10 with Plasmid

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());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) Test(org.junit.Test)

Aggregations

Plasmid (org.jbei.ice.storage.model.Plasmid)12 Account (org.jbei.ice.storage.model.Account)10 Test (org.junit.Test)10 Strain (org.jbei.ice.storage.model.Strain)6 PartData (org.jbei.ice.lib.dto.entry.PartData)4 History (org.jbei.ice.lib.dto.History)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1 PermissionsController (org.jbei.ice.lib.access.PermissionsController)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)1 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)1