Search in sources :

Example 11 with Plasmid

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

Example 12 with Plasmid

use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.

the class TransferredPartsTest method createPlasmidObject.

private Plasmid createPlasmidObject(Account owner) {
    Plasmid plasmid = new Plasmid();
    plasmid.setBackbone("plasmid backone");
    plasmid.setOriginOfReplication("None");
    plasmid.setBioSafetyLevel(1);
    plasmid.setShortDescription("plasmid description");
    plasmid.setName("pLasmid");
    plasmid.setOwner(owner.getFullName());
    plasmid.setOwnerEmail(owner.getEmail());
    plasmid.setCreator(plasmid.getOwner());
    plasmid.setCreatorEmail(plasmid.getOwnerEmail());
    plasmid.setCreationTime(new Date());
    return plasmid;
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Date(java.util.Date)

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