test_class.file: modules/flowable-rest/src/test/java/org/flowable/rest/service/api/identity/UserCollectionResourceTest.java
test_class.identifier: UserCollectionResourceTest
test_class.superclass: extends BaseSpringRestTestCase
test_case.body: @Test
      public void testCreateUser() throws Exception {
          try {
              ObjectNode requestNode = objectMapper.createObjectNode();
              requestNode.put("id", "testuser");
              requestNode.put("firstName", "Frederik");
              requestNode.put("lastName", "Heremans");
              requestNode.put("displayName", "Frederik Heremans");
              requestNode.put("password", "test");
              requestNode.put("email", "no-reply@flowable.org");
  
              HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION, "testuser"));
              httpPost.setEntity(new StringEntity(requestNode.toString()));
              CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CREATED);
              JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
              closeResponse(response);
              assertThat(responseNode).isNotNull();
              assertThatJson(responseNode)
                      .when(Option.IGNORING_EXTRA_FIELDS)
                      .isEqualTo("{"
                              + "id: 'testuser',"
                              + "firstName: 'Frederik',"
                              + "lastName: 'Heremans',"
                              + "displayName: 'Frederik Heremans',"
                              + "email: 'no-reply@flowable.org',"
                              + "url: '" + SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, "testuser") + "'"
                              + "}");
  
              User createdUser = identityService.createUserQuery().userId("testuser").singleResult();
              assertThat(createdUser).isNotNull();
              assertThat(createdUser.getFirstName()).isEqualTo("Frederik");
              assertThat(createdUser.getLastName()).isEqualTo("Heremans");
              assertThat(createdUser.getDisplayName()).isEqualTo("Frederik Heremans");
              assertThat(createdUser.getPassword()).isEqualTo("test");
              assertThat(createdUser.getEmail()).isEqualTo("no-reply@flowable.org");
          } finally {
              try {
                  identityService.deleteUser("testuser");
              } catch (Throwable t) {
                  // Ignore, user might not have been created by test
              }
          }
      }
test_case.class_method_signature: UserCollectionResourceTest.testCreateUser()
test_case.full_signature: @Test public void testCreateUser()
test_case.identifier: testCreateUser
test_case.invocations: createObjectNode put put put put put put createRelativeResourceUrl setEntity toString executeRequest readTree getContent getEntity closeResponse isNotNull assertThat isEqualTo when assertThatJson createRelativeResourceUrl singleResult userId createUserQuery isNotNull assertThat isEqualTo assertThat getFirstName isEqualTo assertThat getLastName isEqualTo assertThat getDisplayName isEqualTo assertThat getPassword isEqualTo assertThat getEmail deleteUser
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCreateUser()
focal_class.declarator: properties = new HashMap<>()
focal_class.modifier: protected static
focal_class.original_string: protected static HashMap<String, QueryProperty> properties = new HashMap<>();
focal_class.type: HashMap<String, QueryProperty>
focal_class.var_name: properties
focal_class.declarator: restResponseFactory
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected RestResponseFactory restResponseFactory;
focal_class.type: RestResponseFactory
focal_class.var_name: restResponseFactory
focal_class.declarator: identityService
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected IdentityService identityService;
focal_class.type: IdentityService
focal_class.var_name: identityService
focal_class.declarator: restApiInterceptor
focal_class.modifier: @Autowired(required=false)
      protected
focal_class.original_string: @Autowired(required=false)
      protected BpmnRestApiInterceptor restApiInterceptor;
focal_class.type: BpmnRestApiInterceptor
focal_class.var_name: restApiInterceptor
focal_class.file: modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java
focal_class.identifier: UserCollectionResource
focal_class.class_method_signature: UserCollectionResource.getUsers(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request)
focal_class.full_signature: @ApiOperation(value = "List users", nickname = "listUsers", tags = { "Users" }) @ApiImplicitParams({ @ApiImplicitParam(name = "id", dataType = "string", value = "Only return group with the given id", paramType = "query"), @ApiImplicitParam(name = "firstName", dataType = "string", value = "Only return users with the given firstname", paramType = "query"), @ApiImplicitParam(name = "lastName", dataType = "string", value = "Only return users with the given lastname", paramType = "query"), @ApiImplicitParam(name = "displayName", dataType = "string", value = "Only return users with the given displayName", paramType = "query"), @ApiImplicitParam(name = "email", dataType = "string", value = "Only return users with the given email", paramType = "query"), @ApiImplicitParam(name = "firstNameLike", dataType = "string", value = "Only return userswith a firstname like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "lastNameLike", dataType = "string", value = "Only return users with a lastname like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "displayNameLike", dataType = "string", value = "Only return users with a displayName like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "emailLike", dataType = "string", value = "Only return users with an email like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "memberOfGroup", dataType = "string", value = "Only return users which are a member of the given group.", paramType = "query"), @ApiImplicitParam(name = "tenantId", dataType = "string", value = "Only return users which are a members of the given tenant.", paramType = "query"), @ApiImplicitParam(name = "potentialStarter", dataType = "string", value = "Only return users which members are potential starters for a process-definition with the given id.", paramType = "query"), @ApiImplicitParam(name = "sort", dataType = "string", value = "Property to sort on, to be used together with the order.", allowableValues = "id,firstName,lastname,email,displayName", paramType = "query"), }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the group exists and is returned.") }) @GetMapping(value = "/identity/users", produces = "application/json") public DataResponse<UserResponse> getUsers(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request)
focal_class.identifier: getUsers
focal_class.modifiers: @ApiOperation(value = "List users", nickname = "listUsers", tags = { "Users" }) @ApiImplicitParams({ @ApiImplicitParam(name = "id", dataType = "string", value = "Only return group with the given id", paramType = "query"), @ApiImplicitParam(name = "firstName", dataType = "string", value = "Only return users with the given firstname", paramType = "query"), @ApiImplicitParam(name = "lastName", dataType = "string", value = "Only return users with the given lastname", paramType = "query"), @ApiImplicitParam(name = "displayName", dataType = "string", value = "Only return users with the given displayName", paramType = "query"), @ApiImplicitParam(name = "email", dataType = "string", value = "Only return users with the given email", paramType = "query"), @ApiImplicitParam(name = "firstNameLike", dataType = "string", value = "Only return userswith a firstname like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "lastNameLike", dataType = "string", value = "Only return users with a lastname like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "displayNameLike", dataType = "string", value = "Only return users with a displayName like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "emailLike", dataType = "string", value = "Only return users with an email like the given value. Use % as wildcard-character.", paramType = "query"), @ApiImplicitParam(name = "memberOfGroup", dataType = "string", value = "Only return users which are a member of the given group.", paramType = "query"), @ApiImplicitParam(name = "tenantId", dataType = "string", value = "Only return users which are a members of the given tenant.", paramType = "query"), @ApiImplicitParam(name = "potentialStarter", dataType = "string", value = "Only return users which members are potential starters for a process-definition with the given id.", paramType = "query"), @ApiImplicitParam(name = "sort", dataType = "string", value = "Property to sort on, to be used together with the order.", allowableValues = "id,firstName,lastname,email,displayName", paramType = "query"), }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the group exists and is returned.") }) @GetMapping(value = "/identity/users", produces = "application/json") public
focal_class.parameters: (@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request)
focal_class.return: DataResponse<UserResponse>
focal_class.signature: DataResponse<UserResponse> getUsers(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request)
focal_class.class_method_signature: UserCollectionResource.createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature: @ApiOperation(value = "Create a user", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the user was created."), @ApiResponse(code = 400, message = "Indicates the id of the user was missing.") }) @PostMapping(value = "/identity/users", produces = "application/json") public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: createUser
focal_class.modifiers: @ApiOperation(value = "Create a user", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the user was created."), @ApiResponse(code = 400, message = "Indicates the id of the user was missing.") }) @PostMapping(value = "/identity/users", produces = "application/json") public
focal_class.parameters: (@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_class.return: UserResponse
focal_class.signature: UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_method.body: @ApiOperation(value = "Create a user", tags = { "Users" })
      @ApiResponses(value = {
              @ApiResponse(code = 201, message = "Indicates the user was created."),
              @ApiResponse(code = 400, message = "Indicates the id of the user was missing.")
  
      })
      @PostMapping(value = "/identity/users", produces = "application/json")
      public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response) {
          if (userRequest.getId() == null) {
              throw new FlowableIllegalArgumentException("Id cannot be null.");
          }
          
          if (restApiInterceptor != null) {
              restApiInterceptor.createUser(userRequest);
          }
  
          // Check if a user with the given ID already exists so we return a CONFLICT
          if (identityService.createUserQuery().userId(userRequest.getId()).count() > 0) {
              throw new FlowableConflictException("A user with id '" + userRequest.getId() + "' already exists.");
          }
  
          User created = identityService.newUser(userRequest.getId());
          created.setEmail(userRequest.getEmail());
          created.setFirstName(userRequest.getFirstName());
          created.setLastName(userRequest.getLastName());
          created.setDisplayName(userRequest.getDisplayName());
          created.setPassword(userRequest.getPassword());
          created.setTenantId(userRequest.getTenantId());
          identityService.saveUser(created);
  
          response.setStatus(HttpStatus.CREATED.value());
  
          return restResponseFactory.createUserResponse(created, true);
      }
focal_method.class_method_signature: UserCollectionResource.createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_method.full_signature: @ApiOperation(value = "Create a user", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the user was created."), @ApiResponse(code = 400, message = "Indicates the id of the user was missing.") }) @PostMapping(value = "/identity/users", produces = "application/json") public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_method.identifier: createUser
focal_method.invocations: getId createUser count userId createUserQuery getId getId newUser getId setEmail getEmail setFirstName getFirstName setLastName getLastName setDisplayName getDisplayName setPassword getPassword setTenantId getTenantId saveUser setStatus value createUserResponse
focal_method.modifiers: @ApiOperation(value = "Create a user", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the user was created."), @ApiResponse(code = 400, message = "Indicates the id of the user was missing.") }) @PostMapping(value = "/identity/users", produces = "application/json") public
focal_method.parameters: (@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)
focal_method.return: UserResponse
focal_method.signature: UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response)