Created
March 13, 2020 06:57
-
-
Save pbenoit-palo/c001b10f49245913ca36803291ec6ce1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void should_find_user_by_phone_with_corrected_field_and_date_of_birth_individual_user() { | |
String token = getJwtToken("0707070707"); | |
User response = | |
given() | |
.header("Authorization", "Bearer " + token) | |
.pathParam("phone", "0707070707") | |
.contentType("application/json") | |
.when().get("/api/v1/users/{phone}") | |
.then() | |
.statusCode(200) | |
.extract().response().as(User.class); | |
// assertions here | |
assertThat(response.getRoles().get(0)).isEqualTo("individual"); | |
assertThat(response.getEmail()).isEqualTo("individual1@foo.com"); | |
assertThat(response.getFirstName()).isEqualTo("Individual"); | |
assertThat(response.getLastName()).isEqualTo("Number 1"); | |
assertThat(response.getMobile()).isEqualTo("0707070707"); | |
assertThat(response.getPassword()).isEqualTo(null); | |
assertThat(response.getDateOfBirth()).isEqualTo("1994-12-17T17:40:42.815+07:00"); | |
} | |
@Test | |
public void should_fail_to_find_user_by_phone_number_when_user_with_given_mobile_phone_not_exist() { | |
String token = getJwtToken("0909090909"); | |
ApiErrorMessage response = | |
given() | |
.header("Authorization", "Bearer " + token) | |
.pathParam("phone", "0505050505") | |
.contentType("application/json") | |
.when().get("/api/v1/users/{phone}") | |
.then() | |
.statusCode(404) | |
.extract().response().as(ApiErrorMessage.class); | |
assertThat(response.getCode()).isEqualTo(ApiErrorMessage.ApiError.API_NOT_FOUND); | |
assertThat(response.getMessage()).isEqualTo("The user with phone [0505050505] does not exist."); | |
assertThat(response.getDetails().get(0).getCode()).isEqualTo(ApiErrorMessage.ApiError.API_NOT_FOUND); | |
assertThat(response.getDetails().get(0).getField()).isEqualTo("login"); | |
assertThat(response.getDetails().get(0).getValue()).isEqualTo("0505050505"); | |
assertThat(response.getDetails().get(0).getMessage()).isEqualTo("The user with phone [0505050505] does not exist."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment