Search in sources :

Example 61 with Account

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

the class EntryHistoryTest method testDelete.

@Test
public void testDelete() throws Exception {
    Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDelete", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteReader", false);
    EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
    entryHistory.add();
    entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
    Results<History> history = entryHistory.get(20, 0, true, null);
    Assert.assertNotNull(history);
    Assert.assertTrue(entryHistory.delete(history.getData().get(0).getId()));
    history = entryHistory.get(20, 0, true, null);
    Assert.assertEquals(0, history.getResultCount());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) History(org.jbei.ice.lib.dto.History) Test(org.junit.Test)

Example 62 with Account

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

the class EntryHistoryTest method testGet.

@Test
public void testGet() throws Exception {
    Account account = AccountCreator.createTestAccount("EntryHistoryTest.testGet", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testGetReader", false);
    EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
    entryHistory.add();
    entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
    Results<History> history = entryHistory.get(20, 0, true, null);
    Assert.assertNotNull(history);
    Assert.assertEquals(1, history.getResultCount());
    History object = history.getData().get(0);
    Assert.assertEquals(reader.getEmail(), object.getAccount().getEmail());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) History(org.jbei.ice.lib.dto.History) Test(org.junit.Test)

Example 63 with Account

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

the class EntryHistoryTest method testDeleteAll.

@Test
public void testDeleteAll() throws Exception {
    Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAll", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAllReader", false);
    EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
    entryHistory.add();
    entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
    Results<History> history = entryHistory.get(20, 0, true, null);
    Assert.assertNotNull(history);
    Assert.assertEquals(1, entryHistory.deleteAll());
    history = entryHistory.get(20, 0, true, null);
    Assert.assertEquals(0, history.getResultCount());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) History(org.jbei.ice.lib.dto.History) Test(org.junit.Test)

Example 64 with Account

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

the class BulkUploadControllerTest method testDeletePermission.

@Test
public void testDeletePermission() throws Exception {
    Account account = AccountCreator.createTestAccount("testDeletePermission", false);
    BulkUploadInfo info = new BulkUploadInfo();
    info.setAccount(account.toDataTransferObject());
    info.setType(EntryType.PART.toString());
    BulkUploadInfo uploadInfo = controller.create(account.getEmail(), info);
    Assert.assertNotNull(uploadInfo);
    Account accountFriend = AccountCreator.createTestAccount("testDeletePermission2", false);
    long id = uploadInfo.getId();
    AccessPermission permission = new AccessPermission();
    permission.setArticle(AccessPermission.Article.ACCOUNT);
    permission.setArticleId(accountFriend.getId());
    permission.setType(AccessPermission.Type.READ_UPLOAD);
    permission.setTypeId(id);
    permission = controller.addPermission(account.getEmail(), id, permission);
    List<AccessPermission> permissions = controller.getUploadPermissions(account.getEmail(), id);
    Assert.assertNotNull(permissions);
    Assert.assertTrue(permissions.size() == 1);
    //delete
    AccessPermission returnedPermission = permissions.get(0);
    Assert.assertTrue(controller.deletePermission(account.getEmail(), id, returnedPermission.getId()));
    permissions = controller.getUploadPermissions(account.getEmail(), id);
    Assert.assertTrue(permissions.isEmpty());
    // check that the permission record has been deleted
    Assert.assertNull(DAOFactory.getPermissionDAO().get(permission.getId()));
}
Also used : Account(org.jbei.ice.storage.model.Account) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) Test(org.junit.Test)

Example 65 with Account

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

the class FolderDAOTest method testGetFolderSize.

@Test
public void testGetFolderSize() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetFolderSize", false);
    String email = account.getEmail();
    // create test folder
    Folder folder = createFolderObject("testGetFolderSize");
    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.assertEquals(10, dao.getFolderSize(folder.getId(), null, true).intValue());
}
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)

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