Search in sources :

Example 1 with ChildAbilityDto

use of wooteco.prolog.report.application.dto.ability.ChildAbilityDto 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)1 Response (io.restassured.response.Response)1 Test (org.junit.jupiter.api.Test)1 TokenResponse (wooteco.prolog.login.application.dto.TokenResponse)1 MemberResponse (wooteco.prolog.member.application.dto.MemberResponse)1 AbilityCreateRequest (wooteco.prolog.report.application.dto.ability.AbilityCreateRequest)1 AbilityResponse (wooteco.prolog.report.application.dto.ability.AbilityResponse)1 AbilityUpdateRequest (wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest)1 ChildAbilityDto (wooteco.prolog.report.application.dto.ability.ChildAbilityDto)1 DefaultAbilityCreateRequest (wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest)1 AbilityNotFoundException (wooteco.prolog.report.exception.AbilityNotFoundException)1