Search in sources :

Example 46 with Account

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

the class WebPartnersTest method testAddNewPartner.

@Test
public void testAddNewPartner() throws Exception {
    Account admin = AccountCreator.createTestAccount("WebPartnersTest.testAddNewPartner", true);
    String adminUser = admin.getEmail();
    WebPartners partners = createThisPartnerObject();
    // create registryPartner for add
    RegistryPartner partner = new RegistryPartner();
    partner.setUrl("registry-test20.jbei.org");
    RegistryPartner added = partners.addNewPartner(adminUser, partner);
    Assert.assertNotNull(added);
    Assert.assertEquals(partner.getUrl(), "registry-test20.jbei.org");
    Assert.assertEquals(added.getStatus(), RemotePartnerStatus.APPROVED);
    // try to add the same partner again: list of partners should remain the same
    // (at two since both remote and local are implemented here)
    long size = partners.getPartners().size();
    partners.addNewPartner(adminUser, partner);
    Assert.assertEquals(size, partners.getPartners().size());
}
Also used : Account(org.jbei.ice.storage.model.Account) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) Test(org.junit.Test)

Example 47 with Account

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

the class EntryDAOTest method testGetByUniqueName.

@Test
public void testGetByUniqueName() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetByUniqueName", false);
    PartData data = new PartData(EntryType.PART);
    data.setShortDescription("summary for test");
    String uniqueName = "pTest" + account.getEmail();
    data.setName(uniqueName);
    data.setBioSafetyLevel(1);
    EntryCreator creator = new EntryCreator();
    creator.createPart(account.getEmail(), data);
    List<Entry> entries = entryDAO.getByName("pTest");
    Assert.assertTrue(entries == null || entries.isEmpty());
    entries = entryDAO.getByName(uniqueName);
    Assert.assertNotNull(entries);
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) TestEntryCreator(org.jbei.ice.lib.TestEntryCreator) PartData(org.jbei.ice.lib.dto.entry.PartData) Test(org.junit.Test)

Example 48 with Account

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

the class AccountDAOTest method testGet.

@Test
public void testGet() throws DAOException {
    Assert.assertNull(dao.get(0));
    Account account = createAccountObject("testGet");
    Account saved = dao.create(account);
    Assert.assertNotNull(saved);
    Account ret = dao.get(saved.getId());
    Assert.assertTrue(saved.getEmail().equals(ret.getEmail()));
}
Also used : Account(org.jbei.ice.storage.model.Account)

Example 49 with Account

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

the class AccountDAOTest method createAccountObject.

private Account createAccountObject(String email) {
    Account account = new Account();
    account.setEmail(email);
    account.setFirstName("First");
    account.setLastName("Last");
    account.setInitials("FL");
    account.setInstitution("");
    account.setDescription("");
    account.setIp("127.0.0.1");
    account.setPassword("40ntH@cKm3br0");
    return account;
}
Also used : Account(org.jbei.ice.storage.model.Account)

Example 50 with Account

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

the class AccountDAOTest method testGetAccounts.

@Test
public void testGetAccounts() throws DAOException {
    for (int i = 0; i < 16; i += 1) {
        Account account = createAccountObject("testGetAccounts" + i);
        Assert.assertNotNull(dao.create(account));
    }
    // get all accounts (no filters), 4 at a time
    for (int i = 0; i < 16; i += 4) {
        List<Account> accountList = dao.getAccounts(i, 4, "id", true, null);
        Assert.assertEquals(4, accountList.size());
    }
    // get all accounts, filter by email
    for (int i = 0; i < 16; i += 4) {
        List<Account> accountList = dao.getAccounts(i, 4, "id", true, "testGetAccounts");
        Assert.assertEquals(4, accountList.size());
    }
}
Also used : Account(org.jbei.ice.storage.model.Account)

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