Search in sources :

Example 1 with User

use of com.baeldung.petstore.client.model.User in project tutorials by eugenp.

the class UserApiTest method updateUserTest.

/**
 * Updated user
 *
 * This can only be done by the logged in user.
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void updateUserTest() {
    String username = null;
    User body = null;
    api.updateUser(username, body);
// TODO: test validations
}
Also used : User(com.baeldung.petstore.client.model.User) Test(org.junit.Test)

Example 2 with User

use of com.baeldung.petstore.client.model.User in project tutorials by eugenp.

the class UserApi method getUserByName.

/**
 * Get user by user name
 *
 * <p><b>200</b> - successful operation
 * <p><b>400</b> - Invalid username supplied
 * <p><b>404</b> - User not found
 * @param username The name that needs to be fetched. Use user1 for testing.
 * @return User
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public User getUserByName(String username) throws RestClientException {
    Object postBody = null;
    // verify the required parameter 'username' is set
    if (username == null) {
        throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling getUserByName");
    }
    // create path and map variables
    final Map<String, Object> uriVariables = new HashMap<String, Object>();
    uriVariables.put("username", username);
    String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString();
    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
    final String[] accepts = { "application/xml", "application/json" };
    final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
    final String[] contentTypes = {};
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
    String[] authNames = new String[] {};
    ParameterizedTypeReference<User> returnType = new ParameterizedTypeReference<User>() {
    };
    return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) User(com.baeldung.petstore.client.model.User) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) MediaType(org.springframework.http.MediaType)

Example 3 with User

use of com.baeldung.petstore.client.model.User in project tutorials by eugenp.

the class UserApiTest method getUserByNameTest.

/**
 * Get user by user name
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void getUserByNameTest() {
    String username = null;
    User response = api.getUserByName(username);
// TODO: test validations
}
Also used : User(com.baeldung.petstore.client.model.User) Test(org.junit.Test)

Example 4 with User

use of com.baeldung.petstore.client.model.User in project tutorials by eugenp.

the class UserApiTest method createUserTest.

/**
 * Create user
 *
 * This can only be done by the logged in user.
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void createUserTest() {
    User body = null;
    api.createUser(body);
// TODO: test validations
}
Also used : User(com.baeldung.petstore.client.model.User) Test(org.junit.Test)

Aggregations

User (com.baeldung.petstore.client.model.User)4 Test (org.junit.Test)3 HashMap (java.util.HashMap)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 HttpHeaders (org.springframework.http.HttpHeaders)1 MediaType (org.springframework.http.MediaType)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1