Search in sources :

Example 66 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method addUserAttributeByUserInum_newAttribute_user.

@Test
private void addUserAttributeByUserInum_newAttribute_user() {
    String inumUser = "inumUser";
    String attributeName = "attribute1";
    String attributeValue = "value1";
    User user = spy(getBasicUser("123", "dn123"));
    user.setCustomAttributes(new ArrayList<>());
    when(persistenceEntryManager.find(any(), any(), any())).thenReturn(user);
    doNothing().when(persistenceEntryManager).merge(user);
    User resultUser = userService.addUserAttributeByUserInum(inumUser, attributeName, attributeValue);
    assertNotNull(resultUser);
    assertTrue(resultUser.getCustomAttributes().size() == 1);
    assertEquals(resultUser.getCustomAttributes().get(0).getName(), attributeName);
    assertEquals(resultUser.getCustomAttributes().get(0).getValue(), attributeValue);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 67 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByInum_nullInum_null.

@Test
private void getUserByInum_nullInum_null() {
    User user = userService.getUserByInum(null, null);
    assertNull(user);
}
Also used : User(io.jans.as.common.model.common.User) Test(org.testng.annotations.Test)

Example 68 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByAttributes_twoAttributes_user.

@Test
private void getUserByAttributes_twoAttributes_user() {
    String userId = "123";
    String baseDn = "baseDn";
    List<CustomAttribute> attributes = new ArrayList<>();
    CustomAttribute customAttribute1 = new CustomAttribute("attribute1", "value1");
    CustomAttribute customAttribute2 = new CustomAttribute("attribute2", "value2");
    attributes.add(customAttribute1);
    attributes.add(customAttribute2);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any(), anyInt())).thenReturn(getListBasicOneUser(userId, baseDn));
    User resultUser = userService.getUserByAttributes(attributes, true, null);
    assertNotNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) CustomAttribute(io.jans.orm.model.base.CustomAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 69 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByDn_emptyDn_null.

@Test
private void getUserByDn_emptyDn_null() {
    User user = userService.getUserByDn("", null);
    assertNull(user);
}
Also used : User(io.jans.as.common.model.common.User) Test(org.testng.annotations.Test)

Example 70 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByInum_emptyInum_null.

@Test
private void getUserByInum_emptyInum_null() {
    User user = userService.getUserByInum("", null);
    assertNull(user);
}
Also used : User(io.jans.as.common.model.common.User) Test(org.testng.annotations.Test)

Aggregations

User (io.jans.as.common.model.common.User)95 Test (org.testng.annotations.Test)54 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 CustomObjectAttribute (io.jans.orm.model.base.CustomObjectAttribute)12 Client (io.jans.as.common.model.registration.Client)11 Date (java.util.Date)11 SessionId (io.jans.as.server.model.common.SessionId)9 Scope (io.jans.as.persistence.model.Scope)8 ArrayList (java.util.ArrayList)8 SimpleUser (io.jans.as.common.model.common.SimpleUser)7 WebApplicationException (javax.ws.rs.WebApplicationException)6 OAuth2AuditLog (io.jans.as.server.model.audit.OAuth2AuditLog)5 Response (javax.ws.rs.core.Response)5 JsonWebResponse (io.jans.as.model.token.JsonWebResponse)4 AuthorizationGrant (io.jans.as.server.model.common.AuthorizationGrant)4 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 InvalidJwtException (io.jans.as.model.exception.InvalidJwtException)3 CibaRequestCacheControl (io.jans.as.server.model.common.CibaRequestCacheControl)3 CustomAttribute (io.jans.orm.model.base.CustomAttribute)3