Search in sources :

Example 61 with PartData

use of org.jbei.ice.lib.dto.entry.PartData 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 62 with PartData

use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.

the class SearchControllerTest method testRunSearch.

@Test
public void testRunSearch() throws Exception {
    Account account = AccountCreator.createTestAccount("testRunSearch", false);
    Assert.assertNotNull(account);
    // create entry
    PlasmidData plasmidData = new PlasmidData();
    plasmidData.setCircular(true);
    plasmidData.setPromoters("pTet");
    plasmidData.setOriginOfReplication("oRep");
    PartData partData = new PartData(EntryType.PLASMID);
    partData.setBioSafetyLevel(BioSafetyOption.LEVEL_ONE.ordinal());
    partData.setStatus("Complete");
    partData.setName("testPlasmid");
    partData.setFundingSource("DOE");
    partData.setPrincipalInvestigator("Nathan");
    partData.setPlasmidData(plasmidData);
    Entry entry = InfoToModelFactory.infoToEntry(partData);
    entry = new EntryCreator().createEntry(account, entry, null);
    Assert.assertNotNull(entry);
    Assert.assertTrue(entry.getId() > 0);
    // commit triggers indexing
    HibernateUtil.commitTransaction();
    HibernateUtil.beginTransaction();
    SearchQuery query = new SearchQuery();
    query.setQueryString("testPlasmid");
    SearchResults results = controller.runSearch(account.getEmail(), query);
    Assert.assertNotNull(results);
    Assert.assertEquals(1, results.getResultCount());
    // search for promoters
    query.setQueryString("pTet");
    results = controller.runSearch(account.getEmail(), query);
    Assert.assertNotNull(results);
    Assert.assertEquals(1, results.getResultCount());
    // search email
    query.setQueryString(account.getEmail());
    results = controller.runSearch(account.getEmail(), query);
    Assert.assertNotNull(results);
    Assert.assertEquals(1, results.getResultCount());
    // fake search
    query.setQueryString("FAKE_SEARCH");
    results = controller.runSearch(account.getEmail(), query);
    Assert.assertNotNull(results);
    Assert.assertEquals(0, results.getResultCount());
}
Also used : SearchQuery(org.jbei.ice.lib.dto.search.SearchQuery) Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) PartData(org.jbei.ice.lib.dto.entry.PartData) PlasmidData(org.jbei.ice.lib.dto.entry.PlasmidData) SearchResults(org.jbei.ice.lib.dto.search.SearchResults) Test(org.junit.Test)

Aggregations

PartData (org.jbei.ice.lib.dto.entry.PartData)62 Entry (org.jbei.ice.storage.model.Entry)22 Account (org.jbei.ice.storage.model.Account)18 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)8 Results (org.jbei.ice.lib.dto.common.Results)5 EntryField (org.jbei.ice.lib.dto.entry.EntryField)4 Group (org.jbei.ice.storage.model.Group)4 Strain (org.jbei.ice.storage.model.Strain)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 PermissionException (org.jbei.ice.lib.access.PermissionException)3 SearchResult (org.jbei.ice.lib.dto.search.SearchResult)3 SearchResults (org.jbei.ice.lib.dto.search.SearchResults)3 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)3 GroupController (org.jbei.ice.lib.group.GroupController)3 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)3 Plasmid (org.jbei.ice.storage.model.Plasmid)3 RemotePartner (org.jbei.ice.storage.model.RemotePartner)3