Search in sources :

Example 91 with Account

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));
}
Also used : Account(org.jbei.ice.storage.model.Account) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) SelectionMarker(org.jbei.ice.storage.model.SelectionMarker) Strain(org.jbei.ice.storage.model.Strain) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 92 with Account

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());
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 93 with Account

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);
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) PageParameters(org.jbei.ice.lib.dto.common.PageParameters) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 94 with Account

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 95 with Account

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

Aggregations

Account (org.jbei.ice.storage.model.Account)153 Test (org.junit.Test)71 Group (org.jbei.ice.storage.model.Group)24 Entry (org.jbei.ice.storage.model.Entry)21 Strain (org.jbei.ice.storage.model.Strain)20 PartData (org.jbei.ice.lib.dto.entry.PartData)18 Folder (org.jbei.ice.storage.model.Folder)18 ArrayList (java.util.ArrayList)16 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)16 PermissionException (org.jbei.ice.lib.access.PermissionException)11 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)10 Plasmid (org.jbei.ice.storage.model.Plasmid)10 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)8 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)8 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)8 DAOException (org.jbei.ice.storage.DAOException)8 RemotePartner (org.jbei.ice.storage.model.RemotePartner)8 HibernateException (org.hibernate.HibernateException)7 HashSet (java.util.HashSet)6 Part (org.jbei.ice.storage.model.Part)6