Search in sources :

Example 1 with AbilityCreateRequest

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

the class AbilityDocumentation method 상위_역량을_생성한다.

@Test
void 상위_역량을_생성한다() {
    // given
    AbilityCreateRequest request = new AbilityCreateRequest("상위 역량 이름", "상위 역량 설명", "#001122", null);
    // when
    ExtractableResponse<Response> response = given("abilities/create-parent").header(AUTHORIZATION, "Bearer " + accessToken).contentType(ContentType.JSON).body(request).when().post("/abilities").then().log().all().extract();
    // then
    assertThat(response.statusCode()).isEqualTo(OK.value());
}
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) Test(org.junit.jupiter.api.Test)

Example 2 with AbilityCreateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityCreateRequest 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 3 with AbilityCreateRequest

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

the class AbilityDocumentation method 역량_목록을_조회한다.

@Test
void 역량_목록을_조회한다() {
    // given
    AbilityResponse 상위_역량_response1 = 상위_역량을_생성하고_response를_반환한다(accessToken, new AbilityCreateRequest("상위 역량 이름1", "상위 역량 설명1", "#001122", null));
    AbilityResponse 상위_역량_response2 = 상위_역량을_생성하고_response를_반환한다(accessToken, new AbilityCreateRequest("상위 역량 이름2", "상위 역량 설명2", "#ffffff", null));
    역량을_생성한다(accessToken, new AbilityCreateRequest("하위 역량 이름1", "하위 역량 설명1", 상위_역량_response1.getColor(), 상위_역량_response1.getId()));
    역량을_생성한다(accessToken, new AbilityCreateRequest("하위 역량 이름2", "하위 역량 설명2", 상위_역량_response2.getColor(), 상위_역량_response2.getId()));
    // when
    ExtractableResponse<Response> response = given("abilities/read").header(AUTHORIZATION, "Bearer " + accessToken).when().get("/abilities").then().log().all().extract();
    // then
    assertThat(response.statusCode()).isEqualTo(OK.value());
    List<AbilityResponse> abilityResponses = response.jsonPath().getList(".", AbilityResponse.class);
    assertThat(abilityResponses).hasSize(4);
}
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) Test(org.junit.jupiter.api.Test)

Example 4 with AbilityCreateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityCreateRequest 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 5 with AbilityCreateRequest

use of wooteco.prolog.report.application.dto.ability.AbilityCreateRequest 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)

Aggregations

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