Search in sources :

Example 41 with Account

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

the class UserApiKeysTest method testDeleteKey.

@Test
public void testDeleteKey() throws Exception {
    Account account = AccountCreator.createTestAccount("UserApiKeysTest.testDeleteKey", false);
    UserApiKeys apiKeys = new UserApiKeys(account.getEmail());
    AccessKey accessKey = apiKeys.requestKey("app.test.6");
    Assert.assertNotNull(accessKey);
    Assert.assertNotNull(accessKey.getToken());
    Assert.assertFalse(apiKeys.deleteKey(accessKey.getId(), "secret"));
    Assert.assertTrue(apiKeys.deleteKey(accessKey.getId(), accessKey.getSecret()));
    Results<AccessKey> keys = apiKeys.getKeys(15, 0, "creationTime", true, false);
    Assert.assertEquals(0, keys.getResultCount());
}
Also used : Account(org.jbei.ice.storage.model.Account) AccessKey(org.jbei.ice.lib.dto.access.AccessKey) Test(org.junit.Test)

Example 42 with Account

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

the class AccountControllerTest method testUpdatePassword.

@Test
public void testUpdatePassword() throws Exception {
    Account account = AccountCreator.createTestAccount("testUpdatePassword", false);
    AccountTransfer transfer = account.toDataTransferObject();
    transfer.setPassword("p455W0rd");
    controller.updatePassword(account.getEmail(), transfer.getId(), transfer);
}
Also used : Account(org.jbei.ice.storage.model.Account) Test(org.junit.Test)

Example 43 with Account

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

the class GroupsTest method testUpdate.

//    @Test
//    public void testGetGroupMembers() throws Exception {
//
//    }
//
@Test
public void testUpdate() throws Exception {
    Account account = AccountCreator.createTestAccount("GroupsTest.testUpdate", false);
    // create local test accounts
    Account account1 = AccountCreator.createTestAccount("GroupsTest.testUpdate1", false);
    Account account2 = AccountCreator.createTestAccount("GroupsTest.testUpdate2", false);
    Account account3 = AccountCreator.createTestAccount("GroupsTest.testUpdate3", false);
    // create remote test accounts
    RemotePartner partner = new RemotePartner();
    partner.setUrl("registry-test2.jbei.org");
    partner = DAOFactory.getRemotePartnerDAO().create(partner);
    RemoteUser remoteUser1 = new RemoteUser();
    remoteUser1.setUser(new AccountTransfer("Remote.GroupsTest.testUpdate1", ""));
    remoteUser1.setPartner(partner.toDataTransferObject());
    RemoteUser remoteUser2 = new RemoteUser();
    remoteUser2.setUser(new AccountTransfer("Remote.GroupsTest.testUpdate2", ""));
    remoteUser2.setPartner(partner.toDataTransferObject());
    RemoteUser remoteUser3 = new RemoteUser();
    remoteUser3.setUser(new AccountTransfer("Remote.GroupsTest.testUpdate3", ""));
    remoteUser3.setPartner(partner.toDataTransferObject());
    // create group with account1, account2 and remote1, remote2 as a members
    UserGroup group = new UserGroup();
    group.setLabel("label");
    group.setDescription("description");
    group.getMembers().add(account1.toDataTransferObject());
    group.getMembers().add(account2.toDataTransferObject());
    group.getRemoteMembers().add(remoteUser1);
    group.getRemoteMembers().add(remoteUser2);
    Groups groups = new Groups(account.getEmail());
    UserGroup result = groups.addGroup(group);
    Assert.assertNotNull(result);
    // get members and test
    result = groups.getGroupMembers(result.getId());
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.getMembers().size());
    Assert.assertEquals(2, result.getRemoteMembers().size());
    // update group to account2 as the only local and 1 remote account
    result.getMembers().clear();
    result.getRemoteMembers().clear();
    result.getMembers().add(account3.toDataTransferObject());
    result.getRemoteMembers().add(remoteUser3);
    // update
    result.setLabel("updated label");
    result.setDescription("updated description");
    Assert.assertTrue(groups.update(result.getId(), result));
    // get members and test
    group = groups.getGroupMembers(result.getId());
    Assert.assertEquals("updated label", group.getLabel());
    Assert.assertEquals("updated description", group.getDescription());
    Assert.assertEquals(1, group.getMembers().size());
    Assert.assertEquals(account3.getEmail(), group.getMembers().get(0).getEmail());
    Assert.assertEquals(1, group.getRemoteMembers().size());
    Assert.assertEquals(remoteUser3.getUser().getEmail(), group.getRemoteMembers().get(0).getUser().getEmail());
}
Also used : Account(org.jbei.ice.storage.model.Account) RemoteUser(org.jbei.ice.lib.dto.web.RemoteUser) RemotePartner(org.jbei.ice.storage.model.RemotePartner) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Test(org.junit.Test)

Example 44 with Account

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

the class GroupsTest method testAddGroup.

//    @Test
//    public void testGet() throws Exception {
//
//    }
//
//    @Test
//    public void testGet1() throws Exception {
//
//    }
//
//    @Test
//    public void testGetMatchingGroups() throws Exception {
//
//    }
@Test
public void testAddGroup() throws Exception {
    Account account = AccountCreator.createTestAccount("GroupsTest.testAddGroup", false);
    String email = account.getEmail();
    UserGroup group = new UserGroup();
    group.setLabel("label");
    group.setDescription("description");
    Account account1 = AccountCreator.createTestAccount("GroupsTest.testAddGroup2", false);
    group.getMembers().add(account1.toDataTransferObject());
    // add remote account
    RemoteUser remoteUser = new RemoteUser();
    AccountTransfer accountTransfer = new AccountTransfer();
    accountTransfer.setEmail("Remote.GroupsTest.testAddGroup3");
    remoteUser.setUser(accountTransfer);
    // create remote partner
    RemotePartner partner = new RemotePartner();
    partner.setUrl("registry-test3.jbei.org");
    partner = DAOFactory.getRemotePartnerDAO().create(partner);
    remoteUser.setPartner(partner.toDataTransferObject());
    group.getRemoteMembers().add(remoteUser);
    Groups groups = new Groups(email);
    UserGroup result = groups.addGroup(group);
    Assert.assertNotNull(result);
    result = groups.getGroupMembers(result.getId());
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.getMembers().size());
    Assert.assertEquals(1, result.getRemoteMembers().size());
}
Also used : Account(org.jbei.ice.storage.model.Account) RemoteUser(org.jbei.ice.lib.dto.web.RemoteUser) RemotePartner(org.jbei.ice.storage.model.RemotePartner) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Test(org.junit.Test)

Example 45 with Account

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

the class TransferredPartsTest method testReceiveTransferredEntry.

@Test
public void testReceiveTransferredEntry() throws Exception {
    Account account = AccountCreator.createTestAccount("testReceivedTransferredEntry", false);
    Strain strain = createStrainObject(account);
    Plasmid plasmid = createPlasmidObject(account);
    // link the two
    PartData strainData = strain.toDataTransferObject();
    PartData plasmidData = plasmid.toDataTransferObject();
    strainData.getLinkedParts().add(plasmidData);
    strainData = parts.receiveTransferredEntry(strainData);
    Assert.assertNotNull(strainData);
    strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getVisibility() == Visibility.TRANSFERRED.getValue());
    plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
    Assert.assertNotNull(plasmid);
    Assert.assertTrue(plasmid.getVisibility() == Visibility.TRANSFERRED.getValue());
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
    // create new plasmid
    Plasmid plasmid2 = createPlasmidObject(account);
    strainData.getLinkedParts().add(plasmid2.toDataTransferObject());
    Assert.assertEquals(2, strainData.getLinkedParts().size());
    // transfer strain (with 2 linked plasmids)
    PartData received = parts.receiveTransferredEntry(strainData);
    Assert.assertNotNull(received);
    // check return
    strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
    Assert.assertNotNull(strain);
    plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
    Assert.assertNotNull(plasmid);
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
    plasmid2 = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(1).getId());
    Assert.assertNotNull(plasmid2);
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid2));
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Strain(org.jbei.ice.storage.model.Strain) 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