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);
}
}
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());
}
Aggregations