use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class KeycloakAdapterTest method testFindEmployee_noMatch.
@Test
public void testFindEmployee_noMatch() {
UserInfo userInfo1 = new UserInfo("uname1", "a_fname", "a_lname", "em1", "dep1");
UserInfo userInfo3 = new UserInfo("uname3", "c_fname", "a_lname", "em2", "dep2");
expect(keycloakClient.listUsers()).andReturn(Arrays.asList(userInfo3, userInfo1));
replay(keycloakClient);
Employee actual = keycloak.findEmployee("uname2");
verify(keycloakClient);
assertNull(actual);
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapClientTest method testListUsersByGroupCode.
@Test
public void testListUsersByGroupCode() throws NoSuchFieldException {
ldapClient = createMockBuilder(LdapClient.class).addMockedMethod("listUsers", LdapClient.Filter.class).createMock();
setField(ldapClient, "settings", settings);
String codes = "code1";
UserInfo memberOfTeam1 = new UserInfo("uname1", null, null, null, null);
UserInfo memberOfTeam1and2 = new UserInfo("uname1", null, null, null, null);
List<UserInfo> team1users = Arrays.asList(memberOfTeam1, memberOfTeam1and2);
expect(ldapClient.listUsers(anyObject(LdapClient.Filter.class))).andAnswer(() -> {
LdapClient.Filter filter = (LdapClient.Filter) EasyMock.getCurrentArguments()[0];
switch((String) filter.getArgs()[0]) {
case "code1":
return team1users;
default:
return null;
}
}).anyTimes();
replay(ldapClient);
List<UserInfo> actual = ldapClient.listUsers(codes);
assertEquals(2, actual.size());
assertTrue(actual.contains(memberOfTeam1));
assertTrue(actual.contains(memberOfTeam1and2));
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapClientTest method testFindUser_userFilterIsNull.
@Test
public void testFindUser_userFilterIsNull() throws NoSuchFieldException {
settings.setLdapUserFilter(null);
UserInfo actual = ldapClient.findUser("uname1");
assertNull(actual);
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapClientTest method testFindEmployee.
@Test
public void testFindEmployee() throws NoSuchFieldException {
ldapClient = createMockBuilder(LdapClient.class).addMockedMethod("listUsers", LdapClient.Filter.class).createMock();
settings.setLdapUserFilter("LDAP-FILTER");
setField(ldapClient, "settings", settings);
List<UserInfo> users = Arrays.asList(new UserInfo("uname1", "firstname", "lastname", "email", "department"));
expect(ldapClient.listUsers(anyObject(LdapClient.Filter.class))).andReturn(users).anyTimes();
replay(ldapClient);
UserInfo actual = ldapClient.findUser("uname1");
assertNotNull(actual);
assertEquals("uname1", actual.getUsername());
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapClientTest method testFindUser_noResults.
@Test
public void testFindUser_noResults() throws NoSuchFieldException {
ldapClient = createMockBuilder(LdapClient.class).addMockedMethod("listUsers", LdapClient.Filter.class).createMock();
setField(ldapClient, "settings", settings);
settings.setLdapUserFilter("LDAP-FILTER");
expect(ldapClient.listUsers(anyObject(LdapClient.Filter.class))).andReturn(Collections.emptyList()).anyTimes();
replay(ldapClient);
UserInfo actual = ldapClient.findUser("uname1");
assertNull(actual);
}
Aggregations