Search in sources :

Example 36 with Account

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

the class PreferencesControllerTest method testCreatePreference.

@Test
public void testCreatePreference() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreatePreference", false);
    Preference preference = controller.createPreference(account, "foo", "bar");
    Assert.assertNotNull(preference);
    preference = controller.createPreference(account, "bar", "foo");
    Assert.assertNotNull(preference);
}
Also used : Account(org.jbei.ice.storage.model.Account) Preference(org.jbei.ice.storage.model.Preference) Test(org.junit.Test)

Example 37 with Account

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

the class PreferencesControllerTest method testRetrieveAccountPreferences.

@Test
public void testRetrieveAccountPreferences() throws Exception {
    Account account = AccountCreator.createTestAccount("testRetrieveAccountPreferences", false);
    ArrayList<PreferenceKey> keys = new ArrayList<>(Arrays.asList(PreferenceKey.values()));
    HashMap<PreferenceKey, String> preferences = controller.retrieveAccountPreferences(account, keys);
    Assert.assertNotNull(preferences);
    Assert.assertEquals(0, preferences.size());
    Preference preference = controller.createPreference(account, PreferenceKey.FUNDING_SOURCE.name(), "JBEI");
    Assert.assertNotNull(preference);
    preferences = controller.retrieveAccountPreferences(account, keys);
    Assert.assertNotNull(preference);
    Assert.assertEquals(1, preferences.size());
    Assert.assertTrue(preferences.containsKey(PreferenceKey.FUNDING_SOURCE));
    Assert.assertTrue(preferences.get(PreferenceKey.FUNDING_SOURCE).equals("JBEI"));
    preference = controller.createPreference(account, PreferenceKey.PRINCIPAL_INVESTIGATOR.name(), "PI");
    Assert.assertNotNull(preference);
    preferences = controller.retrieveAccountPreferences(account, keys);
    Assert.assertNotNull(preference);
    Assert.assertEquals(2, preferences.size());
    Assert.assertTrue(preferences.containsKey(PreferenceKey.FUNDING_SOURCE));
    Assert.assertTrue(preferences.get(PreferenceKey.FUNDING_SOURCE).equals("JBEI"));
    Assert.assertTrue(preferences.containsKey(PreferenceKey.PRINCIPAL_INVESTIGATOR));
    Assert.assertTrue(preferences.get(PreferenceKey.PRINCIPAL_INVESTIGATOR).equals("PI"));
}
Also used : Account(org.jbei.ice.storage.model.Account) Preference(org.jbei.ice.storage.model.Preference) ArrayList(java.util.ArrayList) PreferenceKey(org.jbei.ice.lib.dto.user.PreferenceKey) Test(org.junit.Test)

Example 38 with Account

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

the class TestEntryCreator method createTestAccountAndStrain.

public static Strain createTestAccountAndStrain(String userId) throws Exception {
    Account account = AccountCreator.createTestAccount(userId, false);
    Assert.assertNotNull(account);
    Strain strain = new Strain();
    strain.setName("sTrain");
    strain.setBioSafetyLevel(BioSafetyOption.LEVEL_ONE.ordinal());
    strain.setShortDescription("test strain");
    strain = (Strain) new EntryCreator().createEntry(account, strain, null);
    return strain;
}
Also used : Account(org.jbei.ice.storage.model.Account) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Strain(org.jbei.ice.storage.model.Strain)

Example 39 with Account

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

the class UserApiKeysTest method testRequestKey.

@Test
public void testRequestKey() throws Exception {
    Account account = AccountCreator.createTestAccount("UserApiKeysTest.testRequestKey", false);
    UserApiKeys apiKeys = new UserApiKeys(account.getEmail());
    AccessKey accessKey = apiKeys.requestKey("app.test");
    Assert.assertNotNull(accessKey);
    Assert.assertNotNull(accessKey.getToken());
    AccessKey accessKey2 = apiKeys.requestKey("app.test2");
    Assert.assertNotNull(accessKey2);
    Assert.assertNotNull(accessKey2.getToken());
    Assert.assertNotEquals(accessKey.getToken(), accessKey2.getToken());
}
Also used : Account(org.jbei.ice.storage.model.Account) AccessKey(org.jbei.ice.lib.dto.access.AccessKey) Test(org.junit.Test)

Example 40 with Account

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

the class BulkEntryCreatorTest method testCreateEntry.

@Test
public void testCreateEntry() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreateEntry", false);
    long uploadId = creator.createBulkUpload(account.getEmail(), EntryType.PLASMID);
    PartData partData = new PartData(EntryType.PLASMID);
    partData.setShortDescription("test summary");
    partData.setName("plasmid");
    partData.setBioSafetyLevel(1);
    partData = creator.createEntry(account.getEmail(), uploadId, partData);
    Assert.assertNotNull(partData);
}
Also used : Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData)

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