Search in sources :

Example 1 with AbilityUpdateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest in project prolog by woowacourse.

the class AbilityDocumentation method 역량을_수정한다.

@Test
void 역량을_수정한다() {
    // given
    AbilityCreateRequest 역량_생성_request = new AbilityCreateRequest("역량 이름", "역량 설명", "#000000", null);
    Long 생성된_역량_ID = 상위_역량을_생성하고_response를_반환한다(accessToken, 역량_생성_request).getId();
    String 새로운_이름 = "새로운 이름";
    String 새로운_설명 = "새로운 설명";
    String 새로운_색상 = "#ffffff";
    AbilityUpdateRequest request = new AbilityUpdateRequest(생성된_역량_ID, 새로운_이름, 새로운_설명, 새로운_색상);
    // when
    ExtractableResponse<Response> response = given("abilities/update").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().put("/abilities/" + 생성된_역량_ID).then().log().all().extract();
    // then
    AbilityResponse updatedAbilityResponse = response.jsonPath().getList(".", AbilityResponse.class).stream().filter(ability -> ability.getId().equals(생성된_역량_ID)).findAny().orElseThrow(AbilityNotFoundException::new);
    assertThat(response.statusCode()).isEqualTo(OK.value());
    assertThat(updatedAbilityResponse.getId()).isEqualTo(생성된_역량_ID);
    assertThat(updatedAbilityResponse.getName()).isEqualTo(새로운_이름);
    assertThat(updatedAbilityResponse.getDescription()).isEqualTo(새로운_설명);
    assertThat(updatedAbilityResponse.getColor()).isEqualTo(새로운_색상);
}
Also used : AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) Response(io.restassured.response.Response) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) Test(org.junit.jupiter.api.Test)

Example 2 with AbilityUpdateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest in project prolog by woowacourse.

the class AbilityDocumentation method 역량_수정시_이름이_중복되면_예외가_발생한다.

@Test
void 역량_수정시_이름이_중복되면_예외가_발생한다() {
    // given
    AbilityCreateRequest 역량_생성_request = new AbilityCreateRequest("역량 이름", "역량 설명", "#000000", null);
    AbilityCreateRequest 또_다른_역량_생성_request = new AbilityCreateRequest("또 다른 역량 이름", "또 다른 역량 설명", "#111111", null);
    Long 생성된_역량_ID = 상위_역량을_생성하고_response를_반환한다(accessToken, 역량_생성_request).getId();
    AbilityResponse 생성된_또_다른_역량 = 상위_역량을_생성하고_response를_반환한다(accessToken, 또_다른_역량_생성_request);
    AbilityUpdateRequest request = new AbilityUpdateRequest(생성된_역량_ID, 생성된_또_다른_역량.getName(), "완전히 새로워!", "#999999");
    // when
    ExtractableResponse<Response> response = given("abilities/update-duplicate-name-exception").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().put("/abilities/" + 생성된_역량_ID).then().log().all().extract();
    // then
    assertThat(response.statusCode()).isEqualTo(BAD_REQUEST.value());
    assertThat((int) response.jsonPath().get("code")).isEqualTo(4002);
    assertThat((String) response.jsonPath().get("message")).isEqualTo("중복된 이름의 역량이 존재합니다.");
}
Also used : AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) Response(io.restassured.response.Response) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) Test(org.junit.jupiter.api.Test)

Example 3 with AbilityUpdateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest in project prolog by woowacourse.

the class AbilityDocumentation method 역량_수정시_색상이_중복되면_예외가_발생한다.

@Test
void 역량_수정시_색상이_중복되면_예외가_발생한다() {
    // given
    AbilityCreateRequest 역량_생성_request = new AbilityCreateRequest("역량 이름", "역량 설명", "#000000", null);
    AbilityCreateRequest 또_다른_역량_생성_request = new AbilityCreateRequest("또 다른 역량 이름", "또 다른 역량 설명", "#111111", null);
    Long 생성된_역량_ID = 상위_역량을_생성하고_response를_반환한다(accessToken, 역량_생성_request).getId();
    AbilityResponse 생성된_또_다른_역량 = 상위_역량을_생성하고_response를_반환한다(accessToken, 또_다른_역량_생성_request);
    AbilityUpdateRequest request = new AbilityUpdateRequest(생성된_역량_ID, "완전히 색다른 이름!", "완전히 새로워!", 생성된_또_다른_역량.getColor());
    // when
    ExtractableResponse<Response> response = given("abilities/update-duplicate-color-exception").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().put("/abilities/" + 생성된_역량_ID).then().log().all().extract();
    // then
    assertThat(response.statusCode()).isEqualTo(BAD_REQUEST.value());
    assertThat((int) response.jsonPath().get("code")).isEqualTo(4003);
    assertThat((String) response.jsonPath().get("message")).isEqualTo("중복된 색상의 부모역량이 존재합니다.");
}
Also used : AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) Response(io.restassured.response.Response) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) Test(org.junit.jupiter.api.Test)

Example 4 with AbilityUpdateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest in project prolog by woowacourse.

the class AbilityDocumentation method 하위_역량_수정시_색상_변경이_무시된다.

@Test
void 하위_역량_수정시_색상_변경이_무시된다() {
    // given
    AbilityResponse 생성된_상위_역량 = 상위_역량을_생성하고_response를_반환한다(accessToken, new AbilityCreateRequest("역량 이름", "역량 설명", "#000000", null));
    역량을_생성한다(accessToken, new AbilityCreateRequest("하위 역량 이름", "하위 역량 설명", 생성된_상위_역량.getColor(), 생성된_상위_역량.getId()));
    Long 생성된_하위_역량_ID = 역량_목록을_조회한다(accessToken).jsonPath().getList(".", AbilityResponse.class).stream().filter(response -> response.getName().equals("하위 역량 이름")).findAny().orElseThrow(AbilityNotFoundException::new).getId();
    String 새로운_이름 = "새로운 이름";
    String 새로운_설명 = "새로운 설명";
    String 새로운_색상 = "#ffffff";
    AbilityUpdateRequest request = new AbilityUpdateRequest(생성된_하위_역량_ID, 새로운_이름, 새로운_설명, 새로운_색상);
    // when
    ExtractableResponse<Response> response = given("abilities/update-ignore-child-color").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().put("/abilities/" + 생성된_하위_역량_ID).then().log().all().extract();
    // then
    AbilityResponse updatedAbilityResponse = response.jsonPath().getList(".", AbilityResponse.class).stream().filter(ability -> ability.getId().equals(생성된_하위_역량_ID)).findAny().orElseThrow(AbilityNotFoundException::new);
    assertThat(response.statusCode()).isEqualTo(OK.value());
    assertThat(updatedAbilityResponse.getId()).isEqualTo(생성된_하위_역량_ID);
    assertThat(updatedAbilityResponse.getName()).isEqualTo(새로운_이름);
    assertThat(updatedAbilityResponse.getDescription()).isEqualTo(새로운_설명);
    assertThat(updatedAbilityResponse.getColor()).isEqualTo(생성된_상위_역량.getColor());
    assertThat(updatedAbilityResponse.getColor()).isNotEqualTo(새로운_색상);
}
Also used : AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) BeforeEach(org.junit.jupiter.api.BeforeEach) TokenRequest(wooteco.prolog.login.application.dto.TokenRequest) DefaultAbilityRepository(wooteco.prolog.report.domain.ablity.repository.DefaultAbilityRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MediaType(org.springframework.http.MediaType) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) ContentType(io.restassured.http.ContentType) Autowired(org.springframework.beans.factory.annotation.Autowired) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) ChildAbilityDto(wooteco.prolog.report.application.dto.ability.ChildAbilityDto) GithubResponses(wooteco.prolog.GithubResponses) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) Test(org.junit.jupiter.api.Test) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) HttpStatus(org.springframework.http.HttpStatus) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) List(java.util.List) Response(io.restassured.response.Response) Documentation(wooteco.prolog.Documentation) RestAssured(io.restassured.RestAssured) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) HttpHeaders(org.apache.http.HttpHeaders) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) Response(io.restassured.response.Response) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) Test(org.junit.jupiter.api.Test)

Example 5 with AbilityUpdateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest in project prolog by woowacourse.

the class AbilityDocumentation method 상위_역량_수정시_하위_역량의_색이_모두_변경된다.

@Test
void 상위_역량_수정시_하위_역량의_색이_모두_변경된다() {
    // given
    AbilityResponse 생성된_상위_역량 = 상위_역량을_생성하고_response를_반환한다(accessToken, new AbilityCreateRequest("역량 이름", "역량 설명", "#000000", null));
    역량을_생성한다(accessToken, new AbilityCreateRequest("하위 역량 이름", "하위 역량 설명", 생성된_상위_역량.getColor(), 생성된_상위_역량.getId()));
    String 새로운_이름 = "새로운 이름";
    String 새로운_설명 = "새로운 설명";
    String 새로운_색상 = "#ffffff";
    AbilityUpdateRequest request = new AbilityUpdateRequest(생성된_상위_역량.getId(), 새로운_이름, 새로운_설명, 새로운_색상);
    // when
    ExtractableResponse<Response> response = given("abilities/update-with-children-color").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().put("/abilities/" + 생성된_상위_역량.getId()).then().log().all().extract();
    // then
    AbilityResponse updatedAbilityResponse = response.jsonPath().getList(".", AbilityResponse.class).stream().filter(ability -> ability.getId().equals(생성된_상위_역량.getId())).findAny().orElseThrow(AbilityNotFoundException::new);
    ChildAbilityDto childAbilityResponse = updatedAbilityResponse.getChildren().get(0);
    assertThat(response.statusCode()).isEqualTo(OK.value());
    assertThat(updatedAbilityResponse.getId()).isEqualTo(생성된_상위_역량.getId());
    assertThat(updatedAbilityResponse.getName()).isEqualTo(새로운_이름);
    assertThat(updatedAbilityResponse.getDescription()).isEqualTo(새로운_설명);
    assertThat(updatedAbilityResponse.getColor()).isEqualTo(새로운_색상);
    assertThat(childAbilityResponse.getColor()).isEqualTo(새로운_색상);
}
Also used : AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) AbilityCreateRequest(wooteco.prolog.report.application.dto.ability.AbilityCreateRequest) DefaultAbilityCreateRequest(wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest) TokenResponse(wooteco.prolog.login.application.dto.TokenResponse) AbilityResponse(wooteco.prolog.report.application.dto.ability.AbilityResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) Response(io.restassured.response.Response) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest) ChildAbilityDto(wooteco.prolog.report.application.dto.ability.ChildAbilityDto) Test(org.junit.jupiter.api.Test)

Aggregations

ExtractableResponse (io.restassured.response.ExtractableResponse)5 Response (io.restassured.response.Response)5 Test (org.junit.jupiter.api.Test)5 TokenResponse (wooteco.prolog.login.application.dto.TokenResponse)5 MemberResponse (wooteco.prolog.member.application.dto.MemberResponse)5 AbilityCreateRequest (wooteco.prolog.report.application.dto.ability.AbilityCreateRequest)5 AbilityResponse (wooteco.prolog.report.application.dto.ability.AbilityResponse)5 AbilityUpdateRequest (wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest)5 DefaultAbilityCreateRequest (wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest)5 AbilityNotFoundException (wooteco.prolog.report.exception.AbilityNotFoundException)3 ChildAbilityDto (wooteco.prolog.report.application.dto.ability.ChildAbilityDto)2 RestAssured (io.restassured.RestAssured)1 ContentType (io.restassured.http.ContentType)1 List (java.util.List)1 HttpHeaders (org.apache.http.HttpHeaders)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 HttpStatus (org.springframework.http.HttpStatus)1 MediaType (org.springframework.http.MediaType)1