Search in sources :

Example 11 with Settings

use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.

the class IniWebEnvironmentTest method testGetGroupRolesMap_ifEmptyGroups.

@Test
public void testGetGroupRolesMap_ifEmptyGroups() {
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setExecRoleMemberOf(null);
    settings.setIntegrationClientGroups(null);
    Map<String, String> actual = iniWebEnvironment.getGroupRolesMap(settings);
    assertTrue(actual.isEmpty());
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with Settings

use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.

the class SettingsServiceTest method testUpdateAdminPassword.

@Test
public void testUpdateAdminPassword() {
    Setting passwordSetting = new Setting(Setting.Name.ADMIN_PASSWORD, "old_password");
    entityManager.persist(passwordSetting);
    Settings settings = settingsService.getSettings();
    DefaultPasswordService defaultPasswordService = new DefaultPasswordService();
    Settings actual = settingsService.update(settings, "new_password");
    assertNotNull(actual.getAdminPassword());
    assertNotEquals("new_password", actual.getAdminPassword());
    assertTrue(defaultPasswordService.passwordsMatch("new_password", actual.getAdminPassword()));
}
Also used : DefaultPasswordService(org.apache.shiro.authc.credential.DefaultPasswordService) Setting(com.artezio.arttime.config.Setting) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Example 13 with Settings

use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.

the class SettingsServiceTest method testGetSettings_ifNotExists.

@Test
public void testGetSettings_ifNotExists() {
    Settings actual = settingsService.getSettings();
    assertNotNull(actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Example 14 with Settings

use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.

the class SchedulerTest method testActualizeSettings_timeoutHasChanged.

@Test
public void testActualizeSettings_timeoutHasChanged() throws NoSuchFieldException {
    scheduler = createMockBuilder(Scheduler.class).addMockedMethod("createIntervalTimer").createMock();
    settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setTimerHoursInterval(200);
    settings.setTimerMinutesInterval(500);
    Settings newSettings = new Settings(new EnumMap<>(Setting.Name.class));
    newSettings.setTimerHoursInterval(777);
    newSettings.setTimerMinutesInterval(333);
    setField(scheduler, "settings", settings);
    setField(scheduler, "settingsService", settingsService);
    expect(settingsService.getSettings()).andReturn(newSettings);
    scheduler.createIntervalTimer();
    expectLastCall().once();
    replay(settingsService, scheduler);
    scheduler.actualizeSettings();
    verify(settingsService, scheduler);
}
Also used : Setting(com.artezio.arttime.config.Setting) EnumMap(java.util.EnumMap) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Example 15 with Settings

use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.

the class SettingsServiceTest method testGetSettings.

@Test
public void testGetSettings() {
    Setting setting1 = new Setting(Setting.Name.APPLICATION_BASE_URL, "abc");
    Setting setting2 = new Setting(Setting.Name.HELP_PAGE_URL, null);
    entityManager.persist(setting1);
    entityManager.persist(setting2);
    entityManager.flush();
    System.out.println("+++++++++++++++++++++++++++++++++++++++++++++");
    Settings actual = settingsService.getSettings();
    settingsService.getSettings();
    settingsService.getSettings();
    settingsService.getSettings();
    settingsService.getSettings();
    settingsService.getSettings();
    settingsService.getSettings();
    System.out.println("+++++++++++++++++++++++++++++++++++++++++++++");
    assertNotNull(actual);
    assertTrue(actual.getValuesBySettingNames().containsKey(Setting.Name.APPLICATION_BASE_URL));
    assertTrue(actual.getValuesBySettingNames().containsKey(Setting.Name.HELP_PAGE_URL));
    assertEquals(setting1.getValue(), actual.getValuesBySettingNames().get(setting1.getName()));
    assertEquals(setting2.getValue(), actual.getValuesBySettingNames().get(setting2.getName()));
}
Also used : Setting(com.artezio.arttime.config.Setting) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Aggregations

Settings (com.artezio.arttime.config.Settings)40 Test (org.junit.Test)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 Setting (com.artezio.arttime.config.Setting)9 EnumMap (java.util.EnumMap)5 Before (org.junit.Before)5 SimpleAccount (org.apache.shiro.authc.SimpleAccount)4 Instance (javax.enterprise.inject.Instance)3 Properties (java.util.Properties)2 URLName (javax.mail.URLName)2 ApplicationSettings (com.artezio.arttime.config.ApplicationSettings)1 Employee (com.artezio.arttime.datamodel.Employee)1 ProjectService (com.artezio.arttime.services.ProjectService)1 SettingsService (com.artezio.arttime.services.SettingsService)1 UserInfo (com.artezio.arttime.services.integration.spi.UserInfo)1 Duration (java.time.Duration)1 java.util (java.util)1 HashMap (java.util.HashMap)1 Timer (javax.ejb.Timer)1 TimerConfig (javax.ejb.TimerConfig)1