Search in sources :

Example 6 with Settings

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

the class AdminRealmTest method testGetSettings.

@Test
public void testGetSettings() {
    PowerMock.mockStatic(CDIUtils.class);
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
    expect(settingsService.getSettings()).andReturn(settings);
    PowerMock.replayAll(CDIUtils.class, settingsService);
    Settings actual = adminRealm.getSettings();
    PowerMock.verifyAll();
    assertSame(settings, actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with Settings

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

the class AdminSetupControlFilterTest method testGetSettings.

@Test
public void testGetSettings() {
    PowerMock.mockStatic(CDIUtils.class);
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
    expect(settingsService.getSettings()).andReturn(settings);
    PowerMock.replayAll(CDIUtils.class, settingsService);
    Settings actual = filter.getSettings();
    PowerMock.verifyAll();
    assertSame(settings, actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with Settings

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

the class AdminSetupControlFilterTest method testOnAccessDenied_ifAdminSettingsNotRequired_andNotRequestSetupPage.

@Test
public void testOnAccessDenied_ifAdminSettingsNotRequired_andNotRequestSetupPage() throws Exception {
    filter = createMockBuilder(AdminSetupControlFilter.class).addMockedMethod("isSetupPageRequest", ServletRequest.class).createMock();
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setAdminUsername("admin");
    settings.setAdminPassword("pass");
    PowerMock.mockStatic(CDIUtils.class);
    expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
    expect(settingsService.getSettings()).andReturn(settings);
    expect(filter.isSetupPageRequest(request)).andReturn(false);
    PowerMock.replayAll(CDIUtils.class, settingsService, filter);
    boolean actual = filter.onAccessDenied(request, response);
    PowerMock.verifyAll();
    assertFalse(actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with Settings

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

the class AdminSetupControlFilterTest method testIsAccessAllowed_ifRequestNotSetupPage.

@Test
public void testIsAccessAllowed_ifRequestNotSetupPage() {
    filter = createMockBuilder(AdminSetupControlFilter.class).addMockedMethod("isSetupPageRequest", ServletRequest.class).createMock();
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setAdminUsername(null);
    PowerMock.mockStatic(CDIUtils.class);
    expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
    expect(settingsService.getSettings()).andReturn(settings);
    expect(filter.isSetupPageRequest(request)).andReturn(false);
    PowerMock.replayAll(CDIUtils.class, settingsService, filter);
    boolean actual = filter.isAccessAllowed(request, response, null);
    PowerMock.verifyAll();
    assertFalse(actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with Settings

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

the class AdminSetupControlFilterTest method testIsAccessAllowed_ifRequestSetupPage.

@Test
public void testIsAccessAllowed_ifRequestSetupPage() {
    filter = createMockBuilder(AdminSetupControlFilter.class).addMockedMethod("isSetupPageRequest", ServletRequest.class).createMock();
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setAdminUsername(null);
    PowerMock.mockStatic(CDIUtils.class);
    expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
    expect(settingsService.getSettings()).andReturn(settings);
    expect(filter.isSetupPageRequest(request)).andReturn(true);
    PowerMock.replayAll(CDIUtils.class, settingsService, filter);
    boolean actual = filter.isAccessAllowed(request, response, null);
    PowerMock.verifyAll();
    assertTrue(actual);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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