Search in sources :

Example 61 with User

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

the class UserServiceTest method addDefaultUser_withUidEmptyPersonCustomObject_user.

@Test
private void addDefaultUser_withUidEmptyPersonCustomObject_user() {
    String uid = UUID.randomUUID().toString();
    User user = getBasicUser(uid, "dn123");
    doNothing().when(persistenceEntryManager).persist(any());
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(user));
    when(inumService.generatePeopleInum()).thenReturn(uid);
    userService.setReturnTestListPersonCustomObjectClassList(false);
    User resultUser = userService.addDefaultUser(uid);
    assertNotNull(resultUser);
    assertNotNull(resultUser.getUserId());
    assertEquals(resultUser.getUserId(), uid);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 62 with User

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

the class UserServiceTest method getUniqueUserByAttributes_attributeNamesEmpty_null.

@Test
private void getUniqueUserByAttributes_attributeNamesEmpty_null() {
    List<String> lisAttributes = new ArrayList<>();
    User resultUser = userService.getUniqueUserByAttributes(lisAttributes, null);
    assertNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 63 with User

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

the class UserServiceTest method getUniqueUserByAttributes_exceptionFindEntriesNull_null.

@Test
private void getUniqueUserByAttributes_exceptionFindEntriesNull_null() {
    String attributeName = "attribute1";
    String attributeValue = "value1";
    List<String> lisAttributes = new ArrayList<>();
    lisAttributes.add(attributeName);
    when(persistenceEntryManager.findEntries(any())).thenReturn(null);
    User resultUser = userService.getUniqueUserByAttributes(lisAttributes, attributeValue);
    assertNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 64 with User

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

the class UserServiceTest method addUserAttribute_newAttribute_user.

@Test
private void addUserAttribute_newAttribute_user() {
    String attributeName = "attribute1";
    String attributeValue = "value1";
    User user = spy(getBasicUser("123", "dn123"));
    user.setCustomAttributes(new ArrayList<>());
    Boolean result = userService.addUserAttribute(user, attributeName, attributeValue, null);
    assertTrue(result);
    assertTrue(user.getCustomAttributes().size() == 1);
    assertEquals(user.getCustomAttributes().get(0).getName(), attributeName);
    assertEquals(user.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 65 with User

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

the class UserServiceTest method getUniqueUserByAttributes_attributeNamesSizeOne_null.

@Test
private void getUniqueUserByAttributes_attributeNamesSizeOne_null() {
    String userId = "123";
    String baseDn = "baseDn";
    String attributeName = "attribute1";
    String attributeValue = "value1";
    List<String> lisAttributes = new ArrayList<>();
    lisAttributes.add(attributeName);
    when(persistenceEntryManager.findEntries(any())).thenReturn(getListBasicOneUser(userId, baseDn));
    User resultUser = userService.getUniqueUserByAttributes(lisAttributes, attributeValue);
    assertNotNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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