use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapClientTest method testFindUser_userFilterIsEmpty.
@Test
public void testFindUser_userFilterIsEmpty() throws NoSuchFieldException {
settings.setLdapUserFilter("");
UserInfo actual = ldapClient.findUser("uname1");
assertNull(actual);
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class KeycloakClientTest method testToUserInfo.
@Test
public void testToUserInfo() {
String username = "username";
String firstName = "fname";
String lastName = "lname";
String email = "email";
String departmentAttrribute = "department";
String departmentValue = "dep";
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(departmentAttrribute, Arrays.asList(departmentValue));
UserRepresentation userRepresentation = mock(UserRepresentation.class);
expect(userRepresentation.getUsername()).andReturn(username);
expect(userRepresentation.getFirstName()).andReturn(firstName);
expect(userRepresentation.getLastName()).andReturn(lastName);
expect(userRepresentation.getEmail()).andReturn(email);
expect(userRepresentation.getAttributes()).andReturn(attributes).times(2);
replay(userRepresentation);
settings.setKeycloakUserDepartmentAttribute(departmentAttrribute);
UserInfo actual = keycloakClient.toUserInfo(userRepresentation);
verify(userRepresentation);
assertEquals(username, actual.getUsername());
assertEquals(firstName, actual.getFirstName());
assertEquals(lastName, actual.getLastName());
assertEquals(email, actual.getEmail());
assertEquals(departmentValue, actual.getDepartment());
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class LdapAdapterTest method testGetEmployees.
@Test
public void testGetEmployees() {
UserInfo user1 = createUserInfo("b_user");
UserInfo user2 = createUserInfo("a_user");
expect(ldapClient.listUsers()).andReturn(Arrays.asList(user2, user1));
expect(workdaysCalendarRepository.findDefaultCalendar(anyObject())).andReturn(null).anyTimes();
replay(ldapClient, workdaysCalendarRepository);
List<Employee> actual = ldapAdapter.getEmployees();
verify(ldapClient);
assertEquals(2, actual.size());
assertEquals(user2.getUsername(), actual.get(0).getUserName());
assertEquals(user1.getUsername(), actual.get(1).getUserName());
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class KeycloakAdapterTest method testCreateEmployee.
@Test
public void testCreateEmployee() {
UserInfo userInfo = new UserInfo("username", "firstname", "lastname", "email", "department");
Employee actual = keycloak.createEmployee(userInfo);
assertEmployeeEqualsUserInfo(actual, userInfo);
}
use of com.artezio.arttime.services.integration.spi.UserInfo in project ART-TIME by Artezio.
the class KeycloakAdapterTest method testFindEmployee.
@Test
public void testFindEmployee() {
UserInfo userInfo1 = new UserInfo("uname1", "a_fname", "a_lname", "em1", "dep1");
UserInfo userInfo2 = new UserInfo("uname2", "b_fname", "b_lname", "em2", "dep2");
UserInfo userInfo3 = new UserInfo("uname3", "c_fname", "a_lname", "em2", "dep2");
expect(keycloakClient.listUsers()).andReturn(Arrays.asList(userInfo3, userInfo1, userInfo2));
replay(keycloakClient);
Employee actual = keycloak.findEmployee("uname2");
verify(keycloakClient);
assertNotNull(actual);
assertEmployeeEqualsUserInfo(actual, userInfo2);
}
Aggregations