use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class SelectionMarkerDAOTest method testGetMatchingSelectionMarkers.
@Test
public void testGetMatchingSelectionMarkers() throws Exception {
String email = "testGetMatchingSelectionMarkers";
Account account = AccountCreator.createTestAccount(email, false);
Assert.assertNotNull(account);
Strain strain = new Strain();
strain.setName("sTrain");
strain.setBioSafetyLevel(BioSafetyOption.LEVEL_ONE.ordinal());
strain.setShortDescription("test strain");
SelectionMarker marker = new SelectionMarker();
marker.setName("xkcd");
SelectionMarker marker2 = new SelectionMarker();
marker2.setName("test");
Set<SelectionMarker> markerSet = new HashSet<>();
markerSet.add(marker);
markerSet.add(marker2);
strain.setSelectionMarkers(markerSet);
EntryCreator creator = new EntryCreator();
strain = (Strain) creator.createEntry(account, strain, null);
Assert.assertNotNull(strain);
Assert.assertEquals(2, strain.getSelectionMarkers().size());
List<String> results = dao.getMatchingSelectionMarkers("xkcd", 5);
Assert.assertEquals(1, results.size());
List<String> res = dao.getMatchingSelectionMarkers("tes", 5);
Assert.assertEquals(1, res.size());
Assert.assertEquals("test", res.get(0));
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderDAOTest method testRemoveFolderEntries.
@Test
public void testRemoveFolderEntries() throws Exception {
Account account = AccountCreator.createTestAccount("testRemoveFolderEntries", false);
String email = account.getEmail();
// create test folder
Folder folder = createFolderObject("testRemoveFolderEntries");
folder = dao.create(folder);
Assert.assertNotNull(folder);
List<Entry> entries = new ArrayList<>();
EntryCreator creator = new EntryCreator();
// create 10 entries
for (int i = 0; i < 10; i += 1) {
Part part = new Part();
part.setName("name" + i);
part.setOwnerEmail(email);
part.setAlias("alias" + i);
part.setShortDescription("short description");
Entry entry = creator.createEntry(account, part, null);
entries.add(entry);
}
// add entries to folder
folder = dao.addFolderContents(folder, entries);
// remove entries from folder
List<Long> entriesToRemove = new ArrayList<>();
entriesToRemove.add(entries.get(2).getId());
entriesToRemove.add(entries.get(8).getId());
entriesToRemove.add(entries.get(1).getId());
entriesToRemove.add(entries.get(3).getId());
dao.removeFolderEntries(folder, entriesToRemove);
folder = dao.get(folder.getId());
Assert.assertNotNull(folder);
Assert.assertEquals(6, folder.getContents().size());
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderDAOTest method testRetrieveFolderContents.
@Test
public void testRetrieveFolderContents() throws Exception {
Account account = AccountCreator.createTestAccount("FolderDAOTest.testRetrieveFolderContents", false);
String email = account.getEmail();
Folder folder = createFolderObject(email);
folder = dao.create(folder);
Assert.assertNotNull(folder);
// add entries to folder
EntryCreator creator = new EntryCreator();
List<Entry> entries = new ArrayList<>();
for (int i = 1; i <= 9; i += 1) {
Part part = new Part();
part.setName("name" + i);
part.setOwnerEmail(email);
part.setAlias("alias" + i);
part.setShortDescription("short description");
Entry entry = creator.createEntry(account, part, null);
entries.add(entry);
}
// add to folder
folder = dao.addFolderContents(folder, entries);
Assert.assertNotNull(folder);
List<Entry> result = dao.retrieveFolderContents(folder.getId(), new PageParameters(0, 15, ColumnField.NAME, true, null), false);
Assert.assertNotNull(result);
for (int i = 1; i <= 9; i += 1) {
Entry entry = result.get(i - 1);
Assert.assertEquals(entry.getName(), "name" + i);
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderDAOTest method testAddFolderContents.
@Test
public void testAddFolderContents() throws Exception {
Account account = AccountCreator.createTestAccount("testAddFolderContents", false);
String email = account.getEmail();
// create test folder
Folder folder = createFolderObject("testAddFolderContents");
folder = dao.create(folder);
Assert.assertNotNull(folder);
List<Entry> entries = new ArrayList<>();
EntryCreator creator = new EntryCreator();
// create 10 entries
for (int i = 0; i < 10; i += 1) {
Part part = new Part();
part.setName("name" + i);
part.setOwnerEmail(email);
part.setAlias("alias" + i);
part.setShortDescription("short description");
Entry entry = creator.createEntry(account, part, null);
entries.add(entry);
}
// add entries to folder
folder = dao.addFolderContents(folder, entries);
Assert.assertNotNull(folder);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class EntryDAOTest method testGetEntrySummary.
@Test
public void testGetEntrySummary() throws Exception {
Account account = AccountCreator.createTestAccount("testGetEntrySummary", false);
long id = TestEntryCreator.createTestPart(account.getEmail());
String summary = entryDAO.getEntrySummary(id);
Assert.assertEquals("summary for test", summary);
}
Aggregations