test_class.file: modules/flowable-rest/src/test/java/org/flowable/rest/service/api/identity/UserInfoResourceTest.java
test_class.identifier: UserInfoResourceTest
test_class.superclass: extends BaseSpringRestTestCase
test_case.body: @Test
      public void testCreateUserInfoExceptions() throws Exception {
          User savedUser = null;
          try {
              User newUser = identityService.newUser("testuser");
              newUser.setFirstName("Fred");
              newUser.setLastName("McDonald");
              newUser.setEmail("no-reply@flowable.org");
              identityService.saveUser(newUser);
              savedUser = newUser;
  
              // Test creating without value
              ObjectNode requestNode = objectMapper.createObjectNode();
              requestNode.put("key", "key1");
  
              HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, "testuser"));
              httpPost.setEntity(new StringEntity(requestNode.toString()));
              closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
  
              // Test creating without key
              requestNode = objectMapper.createObjectNode();
              requestNode.put("value", "The value");
  
              httpPost.setEntity(new StringEntity(requestNode.toString()));
              closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
  
              // Test creating an already existing info
              identityService.setUserInfo(newUser.getId(), "key1", "The value");
              requestNode = objectMapper.createObjectNode();
              requestNode.put("key", "key1");
              requestNode.put("value", "The value");
  
              httpPost.setEntity(new StringEntity(requestNode.toString()));
              closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
  
              // Test creating info for unexisting user
              httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, "unexistinguser"));
              httpPost.setEntity(new StringEntity(requestNode.toString()));
              closeResponse(executeRequest(httpPost, HttpStatus.SC_NOT_FOUND));
  
          } finally {
  
              // Delete user after test passes or fails
              if (savedUser != null) {
                  identityService.deleteUser(savedUser.getId());
              }
          }
      }
test_case.class_method_signature: UserInfoResourceTest.testCreateUserInfoExceptions()
test_case.full_signature: @Test public void testCreateUserInfoExceptions()
test_case.identifier: testCreateUserInfoExceptions
test_case.invocations: newUser setFirstName setLastName setEmail saveUser createObjectNode put createRelativeResourceUrl setEntity toString closeResponse executeRequest createObjectNode put setEntity toString closeResponse executeRequest setUserInfo getId createObjectNode put put setEntity toString closeResponse executeRequest createRelativeResourceUrl setEntity toString closeResponse executeRequest deleteUser getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCreateUserInfoExceptions()
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.file: modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserInfoResource.java
focal_class.identifier: UserInfoResource
focal_class.class_method_signature: UserInfoResource.getUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletRequest request)
focal_class.full_signature: @ApiOperation(value = "Get a user’s info", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the user has info for the given key."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does ot have info for the given key. Status description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public UserInfoResponse getUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletRequest request)
focal_class.identifier: getUserInfo
focal_class.modifiers: @ApiOperation(value = "Get a user’s info", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the user has info for the given key."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does ot have info for the given key. Status description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public
focal_class.parameters: (@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletRequest request)
focal_class.return: UserInfoResponse
focal_class.signature: UserInfoResponse getUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletRequest request)
focal_class.class_method_signature: UserInfoResource.setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_class.full_signature: @ApiOperation(value = "Update a user’s info", tags = { "Users" }, nickname = "updateUserInfo") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the info has been updated."), @ApiResponse(code = 400, message = "Indicates the value was missing from the request body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @PutMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public UserInfoResponse setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_class.identifier: setUserInfo
focal_class.modifiers: @ApiOperation(value = "Update a user’s info", tags = { "Users" }, nickname = "updateUserInfo") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the info has been updated."), @ApiResponse(code = 400, message = "Indicates the value was missing from the request body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @PutMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public
focal_class.parameters: (@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_class.return: UserInfoResponse
focal_class.signature: UserInfoResponse setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_class.class_method_signature: UserInfoResource.deleteUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletResponse response)
focal_class.full_signature: @ApiOperation(value = "Delete a user’s info", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the user was found and the info for the given key has been deleted. Response body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @DeleteMapping("/identity/users/{userId}/info/{key}") public void deleteUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletResponse response)
focal_class.identifier: deleteUserInfo
focal_class.modifiers: @ApiOperation(value = "Delete a user’s info", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the user was found and the info for the given key has been deleted. Response body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @DeleteMapping("/identity/users/{userId}/info/{key}") public
focal_class.parameters: (@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletResponse response)
focal_class.return: void
focal_class.signature: void deleteUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, HttpServletResponse response)
focal_class.class_method_signature: UserInfoResource.getValidKeyFromRequest(User user, String key)
focal_class.full_signature: protected String getValidKeyFromRequest(User user, String key)
focal_class.identifier: getValidKeyFromRequest
focal_class.modifiers: protected
focal_class.parameters: (User user, String key)
focal_class.return: String
focal_class.signature: String getValidKeyFromRequest(User user, String key)
focal_class.superclass: extends BaseUserResource
focal_method.body: @ApiOperation(value = "Update a user’s info", tags = { "Users" }, nickname = "updateUserInfo")
      @ApiResponses(value = {
              @ApiResponse(code = 200, message = "Indicates the user was found and the info has been updated."),
              @ApiResponse(code = 400, message = "Indicates the value was missing from the request body."),
              @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.")
      })
      @PutMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json")
      public UserInfoResponse setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request) {
  
          User user = getUserFromRequest(userId);
          String validKey = getValidKeyFromRequest(user, key);
  
          if (userRequest.getValue() == null) {
              throw new FlowableIllegalArgumentException("The value cannot be null.");
          }
  
          if (userRequest.getKey() == null || validKey.equals(userRequest.getKey())) {
              identityService.setUserInfo(user.getId(), key, userRequest.getValue());
          } else {
              throw new FlowableIllegalArgumentException("Key provided in request body does not match the key in the resource URL.");
          }
  
          return restResponseFactory.createUserInfoResponse(key, userRequest.getValue(), user.getId());
      }
focal_method.class_method_signature: UserInfoResource.setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_method.full_signature: @ApiOperation(value = "Update a user’s info", tags = { "Users" }, nickname = "updateUserInfo") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the info has been updated."), @ApiResponse(code = 400, message = "Indicates the value was missing from the request body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @PutMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public UserInfoResponse setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_method.identifier: setUserInfo
focal_method.invocations: getUserFromRequest getValidKeyFromRequest getValue getKey equals getKey setUserInfo getId getValue createUserInfoResponse getValue getId
focal_method.modifiers: @ApiOperation(value = "Update a user’s info", tags = { "Users" }, nickname = "updateUserInfo") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and the info has been updated."), @ApiResponse(code = 400, message = "Indicates the value was missing from the request body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have info for the given key. Status description contains additional information about the error.") }) @PutMapping(value = "/identity/users/{userId}/info/{key}", produces = "application/json") public
focal_method.parameters: (@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)
focal_method.return: UserInfoResponse
focal_method.signature: UserInfoResponse setUserInfo(@ApiParam(name = "userId") @PathVariable("userId") String userId, @ApiParam(name = "key") @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request)