Search in sources :

Example 71 with Account

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

the class FolderControllerTest method testCreateNewFolder.

@Test
public void testCreateNewFolder() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreateNewFolder", false);
    String userId = account.getEmail();
    FolderDetails folderDetails = new FolderDetails();
    folderDetails.setName("test");
    FolderDetails folder = controller.createPersonalFolder(userId, folderDetails);
    Assert.assertNotNull(folder);
    Folder f = DAOFactory.getFolderDAO().get(folder.getId());
    Assert.assertNotNull(f);
    Assert.assertEquals("test", f.getName());
}
Also used : Account(org.jbei.ice.storage.model.Account) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 72 with Account

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

the class CollectionEntriesTest method testGetEntries.

@Test
public void testGetEntries() throws Exception {
    Account account = AccountCreator.createTestAccount("CollectionEntriesTest.testGetEntries", false);
    Assert.assertNotNull(account);
    CollectionEntries entries = new CollectionEntries(account.getEmail(), CollectionType.AVAILABLE);
    Results<PartData> results = entries.getEntries(ColumnField.CREATED, true, 0, 10);
    Assert.assertNotNull(results);
}
Also used : Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Test(org.junit.Test)

Example 73 with Account

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

the class GroupControllerTest method testGetMatchingGroups.

@Test
public void testGetMatchingGroups() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetMatchingGroups", false);
    UserGroup g1 = new UserGroup();
    g1.setDescription("desc");
    g1.setLabel("label");
    g1 = controller.createGroup(account.getEmail(), g1);
    Assert.assertNotNull(g1);
    Group group1 = DAOFactory.getGroupDAO().get(g1.getId());
    account.getGroups().add(group1);
    Assert.assertNotNull(group1);
    UserGroup g2 = new UserGroup();
    g2.setDescription("desc");
    g2.setLabel("myg2");
    g2 = controller.createGroup(account.getEmail(), g2);
    Assert.assertNotNull(g2);
    Group group2 = DAOFactory.getGroupDAO().get(g2.getId());
    Assert.assertNotNull(group2);
    account.getGroups().add(group2);
    // save to add groups to account
    DAOFactory.getAccountDAO().create(account);
    Account account2 = AccountCreator.createTestAccount("testGetMatchingGroups2", false);
    UserGroup g3 = new UserGroup();
    g3.setDescription("desc");
    g3.setLabel("myg3");
    Assert.assertNotNull(controller.createGroup(account2.getEmail(), g3));
    List<Group> groups = controller.getMatchingGroups(account.getEmail(), "myg", 10);
    Assert.assertNotNull(groups);
    Assert.assertEquals(1, groups.size());
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 74 with Account

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

the class GroupControllerTest method testGetGroupById.

@Test
public void testGetGroupById() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetGroupById", false);
    UserGroup userGroup1 = new UserGroup();
    userGroup1.setDescription("test1");
    userGroup1.setType(GroupType.PRIVATE);
    userGroup1.setLabel("label1");
    long id = controller.createGroup(account.getEmail(), userGroup1).getId();
    Assert.assertNotNull(controller.getGroupById(account.getEmail(), id));
}
Also used : Account(org.jbei.ice.storage.model.Account) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 75 with Account

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

the class ExperimentsTest method testCreateStudy.

@Test
public void testCreateStudy() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreateStudy", false);
    String userId = account.getEmail();
    String partId = Long.toString(TestEntryCreator.createTestPart(userId));
    Study study = new Study();
    study.setUrl("http://edd-test.jbei.org/foo/bar");
    study.setLabel("test create");
    Experiments experiments = new Experiments(userId, partId);
    Study created = experiments.createOrUpdateStudy(study);
    Assert.assertNotNull(created);
    Assert.assertEquals(created.getUrl(), study.getUrl());
    Assert.assertEquals(created.getLabel(), study.getLabel());
    Assert.assertEquals(created.getOwnerEmail(), userId);
    long createdId = created.getId();
    // update
    study.setLabel("Metabolomic study of the integrated adipic acid-producing Borrelidin Polyketide Synthase (PKS) (JGI constructs Ver. 1.0/ 2.0) S. venezuelae ATCC10712. From 20170206");
    created = experiments.createOrUpdateStudy(study);
    Assert.assertNotNull(created);
    Assert.assertEquals(created.getUrl(), study.getUrl());
    Assert.assertEquals(created.getLabel(), study.getLabel().substring(0, 128));
    Assert.assertEquals(created.getOwnerEmail(), userId);
    List<Study> studies = experiments.getPartStudies();
    Assert.assertNotNull(studies);
    Assert.assertEquals(1, studies.size());
    // test assigning same study to a different entry
    study.setUrl("http://edd-test.jbei.org/foo/bar");
    study.setLabel("test create");
    String partId2 = Long.toString(TestEntryCreator.createTestPart(userId));
    experiments = new Experiments(userId, partId2);
    created = experiments.createOrUpdateStudy(study);
    Assert.assertNotNull(created);
    // should be the same created experiment
    Assert.assertEquals(created.getId(), createdId);
}
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