Search in sources :

Example 31 with Settings

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

the class TrackingSystemProducerTest method testGetTeamTrackingSystem.

@Test
public void testGetTeamTrackingSystem() throws NoSuchFieldException {
    Settings settings = createMock(Settings.class);
    Instance instance = createMock(Instance.class);
    trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).addMockedMethod("findImplementationByName", Instance.class, String.class).createMock();
    setField(trackingSystemProducer, "teamTrackingSystems", instance);
    setField(trackingSystemProducer, "settings", settings);
    TeamTrackingSystem expectedImpl = createMock(TeamTrackingSystem.class);
    expect(trackingSystemProducer.findImplementationByName(instance, "ExpectedImpl")).andReturn(expectedImpl);
    expect(settings.getTeamTrackingSystemName()).andReturn("ExpectedImpl");
    replayAll(instance, settings, expectedImpl, trackingSystemProducer);
    TeamTrackingSystem actual = trackingSystemProducer.getTeamTrackingSystem();
    PowerMock.verifyAll();
    assertEquals(expectedImpl, actual);
}
Also used : Instance(javax.enterprise.inject.Instance) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 32 with Settings

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

the class TrackingSystemProducerTest method testGetEmployeeTrackingSystem.

@Test
public void testGetEmployeeTrackingSystem() throws NoSuchFieldException {
    Settings settings = createMock(Settings.class);
    Instance instance = createMock(Instance.class);
    trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).addMockedMethod("findImplementationByName", Instance.class, String.class).createMock();
    setField(trackingSystemProducer, "employeeTrackingSystems", instance);
    setField(trackingSystemProducer, "settings", settings);
    EmployeeTrackingSystem expectedImpl = createMock(EmployeeTrackingSystem.class);
    expect(trackingSystemProducer.findImplementationByName(instance, "ExpectedImpl")).andReturn(expectedImpl);
    expect(settings.getEmployeeTrackingSystemName()).andReturn("ExpectedImpl");
    replayAll(instance, settings, expectedImpl, trackingSystemProducer);
    EmployeeTrackingSystem actual = trackingSystemProducer.getEmployeeTrackingSystem();
    PowerMock.verifyAll();
    assertEquals(expectedImpl, actual);
}
Also used : Instance(javax.enterprise.inject.Instance) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 33 with Settings

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

the class KeycloakClientTest method setUp.

@Before
public void setUp() throws NoSuchFieldException {
    environmentVariables.set(Setting.Name.KEYCLOAK_CLIENT_ID.name(), KEYCLOAK_CLIENT_ID);
    settings = new Settings(new HashMap<>());
    setField(keycloakClient, "settings", settings);
}
Also used : Settings(com.artezio.arttime.config.Settings) Before(org.junit.Before)

Example 34 with Settings

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

the class EmailSenderTest method testInitSession.

@Test
public void testInitSession() throws NoSuchFieldException, NoSuchMethodException {
    Session session = PowerMock.createMock(Session.class);
    Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setSmtpHostName("smtp.host");
    settings.setSmtpPortNumber("25");
    settings.setSmtpUsername("TestUser");
    settings.setSmtpPassword("123");
    setField(emailSender, "session", session);
    setField(emailSender, "settings", settings);
    Properties properties = new Properties();
    expect(session.getProperties()).andReturn(properties).anyTimes();
    PowerMock.stub(Session.class.getMethod("setPasswordAuthentication", URLName.class, PasswordAuthentication.class));
    session.setPasswordAuthentication(anyObject(), anyObject());
    PowerMock.replay(session);
    emailSender.initSession();
    verify(session);
    assertEquals(settings.getSmtpHostName(), properties.getProperty("mail.smtp.host"));
    assertEquals(settings.getSmtpPortNumber(), properties.getProperty("mail.smtp.port"));
    assertEquals(settings.getSmtpUsername(), properties.getProperty("mail.smtp.user"));
    assertTrue(Boolean.parseBoolean(properties.getProperty("mail.smtp.auth")));
}
Also used : Properties(java.util.Properties) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 35 with Settings

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

the class SynchronizerTest method setUp.

@Before
public void setUp() throws NoSuchFieldException {
    synchronizer = new Synchronizer();
    settings = new Settings(new EnumMap<>(Setting.Name.class));
    mockControl = EasyMock.createControl();
    employeeSynchronizer = mockControl.createMock(EmployeeSynchronizerLocal.class);
    teamSynchronizer = mockControl.createMock(TeamSynchronizer.class);
    projectService = mockControl.createMock(ProjectService.class);
    settingsService = mockControl.createMock(SettingsService.class);
    setField(synchronizer, "employeeSynchronizer", employeeSynchronizer);
    setField(synchronizer, "teamSynchronizer", teamSynchronizer);
    setField(synchronizer, "projectService", projectService);
    setField(synchronizer, "settingsService", settingsService);
    setField(synchronizer, "settings", settings);
}
Also used : Setting(com.artezio.arttime.config.Setting) ProjectService(com.artezio.arttime.services.ProjectService) SettingsService(com.artezio.arttime.services.SettingsService) EnumMap(java.util.EnumMap) Settings(com.artezio.arttime.config.Settings) Before(org.junit.Before)

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