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