use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class IniWebEnvironmentTest method testAddLdapProperties.
@Test
public void testAddLdapProperties() throws NoSuchFieldException {
Ini ini = new Ini();
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setLdapPrincipalUsername("username");
settings.setLdapBindCredentials("password");
settings.setLdapServerHost("localhost");
settings.setLdapServerPort("356");
settings.setLdapPrincipalSuffix("@company.com");
settings.setExecRoleMemberOf("EXEC_GROUP");
settings.setLdapUserContextDN("DC=MyCompany,DC=local");
settings.setLdapCommonNameAttribute("CN");
setField(iniWebEnvironment, "ini", ini);
setField(iniWebEnvironment, "settingsService", settingsService);
expect(settingsService.getSettings()).andReturn(settings);
replay(settingsService);
iniWebEnvironment.addLdapProperties(ini);
verify(settingsService);
assertEquals("com.artezio.arttime.security.auth.ActiveDirectoryRealm", ini.getSectionProperty("main", "ldapRealm"));
assertEquals("ldap://localhost:356", ini.getSectionProperty("main", "ldapRealm.url"));
assertEquals("username", ini.getSectionProperty("main", "ldapRealm.systemUsername"));
assertEquals("password", ini.getSectionProperty("main", "ldapRealm.systemPassword"));
assertEquals("DC=MyCompany,DC=local", ini.getSectionProperty("main", "ldapRealm.searchBase"));
assertEquals("@company.com", ini.getSectionProperty("main", "ldapRealm.principalSuffix"));
assertEquals("\"CN=EXEC_GROUP,DC=MyCompany,DC=local\":\"exec\"", ini.getSectionProperty("main", "ldapRealm.groupRolesMap"));
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class MailingEngineTest method testSendMail_byRecipientId.
@Test
public void testSendMail_byRecipientId() throws Exception {
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setSmtpUsername("smtpUser");
setField(mailingEngine, "settings", settings);
Employee employee = new Employee("smtpUser");
employee.setEmail("smtpUser@mail.com");
PowerMock.mockStatic(Transport.class);
expect(employeeService.findEmployee("smtpUser")).andReturn(employee);
Transport.send(anyObject(MimeMessage.class));
PowerMock.replayAll(Transport.class, employeeService);
mailingEngine.send("recipient@mail.com", new Mail());
PowerMock.verifyAll();
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class MailingEngineTest 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(mailingEngine, "session", session);
setField(mailingEngine, "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);
mailingEngine.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")));
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class SchedulerTest method testActualizeSettings_timeoutHasNotChanged.
@Test
public void testActualizeSettings_timeoutHasNotChanged() throws NoSuchFieldException {
settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setTimerHoursInterval(200);
settings.setTimerMinutesInterval(500);
setField(scheduler, "settings", settings);
expect(settingsService.getSettings()).andReturn(settings);
replay(settingsService);
scheduler.actualizeSettings();
verify(settingsService);
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class SchedulerTest method testTimeout.
@Test
public void testTimeout() throws NoSuchFieldException {
synchronizer = createMockBuilder(Synchronizer.class).addMockedMethod("synchronize").createMock();
setField(scheduler, "synchronizer", synchronizer);
setField(scheduler, "settingsService", settingsService);
Settings actual = new Settings(new EnumMap<>(Setting.Name.class));
expect(settingsService.getSettings()).andReturn(actual);
synchronizer.synchronize();
expectLastCall().once();
replay(synchronizer, settingsService);
scheduler.timeout();
verify(synchronizer, settingsService);
}
Aggregations