Search in sources :

Example 1 with Setting

use of com.artezio.arttime.config.Setting 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 2 with Setting

use of com.artezio.arttime.config.Setting 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)

Example 3 with Setting

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

the class SettingsServiceTest method testUpdateSettings.

@Test
public void testUpdateSettings() {
    Setting setting1 = new Setting(Setting.Name.LDAP_BIND_CREDENTIALS, "old_value1");
    Setting setting2 = new Setting(Setting.Name.SMTP_HOST_NAME, "old_value2");
    entityManager.persist(setting1);
    entityManager.persist(setting2);
    entityManager.flush();
    Settings settings = settingsService.getSettings();
    settings.setLdapBindCredentials("new_value");
    settings.setSmtpHostName(null);
    settingsService.update(settings);
    Settings newSettings = settingsService.getSettings();
    assertTrue(newSettings.getLdapBindCredentials().equals("new_value"));
    assertNull(newSettings.getSmtpHostName());
}
Also used : Setting(com.artezio.arttime.config.Setting) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Aggregations

Setting (com.artezio.arttime.config.Setting)3 Settings (com.artezio.arttime.config.Settings)3 Test (org.junit.Test)3 DefaultPasswordService (org.apache.shiro.authc.credential.DefaultPasswordService)1