Search in sources :

Example 1 with AbilityNotFoundException

use of wooteco.prolog.report.exception.AbilityNotFoundException 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 AbilityNotFoundException

use of wooteco.prolog.report.exception.AbilityNotFoundException 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 3 with AbilityNotFoundException

use of wooteco.prolog.report.exception.AbilityNotFoundException in project prolog by woowacourse.

the class AbilityServiceTest method childAbilityUpdateSuccess.

@DisplayName("자식역량 정보 수정이 정상적으로 수행되는지 확인한다.")
@Test
void childAbilityUpdateSuccess() {
    // given
    AbilityCreateRequest parentRequest1 = new AbilityCreateRequest("부모1", "부모설명1", "1", null);
    AbilityCreateRequest parentRequest2 = new AbilityCreateRequest("부모2", "부모설명2", "2", null);
    AbilityCreateRequest parentRequest3 = new AbilityCreateRequest("부모3", "부모설명3", "3", null);
    abilityService.createAbility(member.getId(), parentRequest1);
    abilityService.createAbility(member.getId(), parentRequest2);
    abilityService.createAbility(member.getId(), parentRequest3);
    AbilityCreateRequest childRequest1 = new AbilityCreateRequest("자식1", "자식설명1", "1", 1L);
    AbilityCreateRequest childRequest1_2 = new AbilityCreateRequest("자식1_2", "자식설명1_2", "1", 1L);
    AbilityCreateRequest childRequest2 = new AbilityCreateRequest("자식2", "자식설명2", "2", 2L);
    AbilityCreateRequest childRequest3 = new AbilityCreateRequest("자식3", "자식설명3", "3", 3L);
    abilityService.createAbility(member.getId(), childRequest1);
    abilityService.createAbility(member.getId(), childRequest1_2);
    abilityService.createAbility(member.getId(), childRequest2);
    abilityService.createAbility(member.getId(), childRequest3);
    // when
    AbilityUpdateRequest request = new AbilityUpdateRequest(4L, "자식1_1", "자식설명1", "1");
    HierarchyAbilityResponse expectedResponse = new HierarchyAbilityResponse(request.getId(), request.getName(), request.getDescription(), request.getColor(), false, new ArrayList<>());
    abilityService.updateAbility(member.getId(), request.getId(), request);
    List<HierarchyAbilityResponse> abilityResponses = abilityService.findAbilitiesByMemberId(member.getId());
    HierarchyAbilityResponse updatedResponse = abilityResponses.stream().filter(response -> response.getId().equals(request.getId())).findAny().orElseThrow(AbilityNotFoundException::new);
    // then
    assertThat(updatedResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
}
Also used : AbilityCreateRequest(wooteco.prolog.ability.application.dto.AbilityCreateRequest) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) DefaultAbilityNotFoundException(wooteco.prolog.report.exception.DefaultAbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.ability.application.dto.AbilityUpdateRequest) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with AbilityNotFoundException

use of wooteco.prolog.report.exception.AbilityNotFoundException in project prolog by woowacourse.

the class AbilityServiceTest method updateAbilityParentChangeChildrenColors.

@DisplayName("역량 정보를 수정할 때 부모 역량의 경우 자식 역량의 색상이 모두 변경된다.")
@Test
void updateAbilityParentChangeChildrenColors() {
    // given
    AbilityCreateRequest createParentRequest = new AbilityCreateRequest("부모 프로그래밍", "프로그래밍 역량입니다.", "#111111", null);
    abilityService.createAbility(member.getId(), createParentRequest);
    HierarchyAbilityResponse createdParentResponse = abilityService.findParentAbilitiesByMemberId(member.getId()).get(0);
    AbilityCreateRequest createChildRequest = new AbilityCreateRequest("자식 프로그래밍", "부모 프로그래밍의 자식입니다.", createdParentResponse.getColor(), createdParentResponse.getId());
    abilityService.createAbility(member.getId(), createChildRequest);
    String newColor = "#ffffff";
    AbilityUpdateRequest request = new AbilityUpdateRequest(createdParentResponse.getId(), "완전히 새로운 이름", "완전히 새로운건데요?!", newColor);
    // when
    abilityService.updateAbility(member.getId(), request.getId(), request);
    // then
    List<HierarchyAbilityResponse> abilityResponses = abilityService.findAbilitiesByMemberId(member.getId());
    HierarchyAbilityResponse updatedParentResponse = abilityResponses.stream().filter(response -> response.getId().equals(createdParentResponse.getId())).findAny().orElseThrow(AbilityNotFoundException::new);
    AbilityResponse updatedChildResponse = updatedParentResponse.getChildren().get(0);
    assertThat(updatedParentResponse.getColor()).isEqualTo(newColor);
    assertThat(updatedChildResponse.getColor()).isEqualTo(newColor);
}
Also used : AbilityCreateRequest(wooteco.prolog.ability.application.dto.AbilityCreateRequest) AbilityResponse(wooteco.prolog.ability.application.dto.AbilityResponse) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) DefaultAbilityNotFoundException(wooteco.prolog.report.exception.DefaultAbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.ability.application.dto.AbilityUpdateRequest) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with AbilityNotFoundException

use of wooteco.prolog.report.exception.AbilityNotFoundException 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

Test (org.junit.jupiter.api.Test)5 AbilityNotFoundException (wooteco.prolog.report.exception.AbilityNotFoundException)5 ExtractableResponse (io.restassured.response.ExtractableResponse)3 Response (io.restassured.response.Response)3 TokenResponse (wooteco.prolog.login.application.dto.TokenResponse)3 MemberResponse (wooteco.prolog.member.application.dto.MemberResponse)3 AbilityCreateRequest (wooteco.prolog.report.application.dto.ability.AbilityCreateRequest)3 AbilityResponse (wooteco.prolog.report.application.dto.ability.AbilityResponse)3 AbilityUpdateRequest (wooteco.prolog.report.application.dto.ability.AbilityUpdateRequest)3 DefaultAbilityCreateRequest (wooteco.prolog.report.application.dto.ability.DefaultAbilityCreateRequest)3 DisplayName (org.junit.jupiter.api.DisplayName)2 AbilityCreateRequest (wooteco.prolog.ability.application.dto.AbilityCreateRequest)2 AbilityUpdateRequest (wooteco.prolog.ability.application.dto.AbilityUpdateRequest)2 HierarchyAbilityResponse (wooteco.prolog.ability.application.dto.HierarchyAbilityResponse)2 ChildAbilityDto (wooteco.prolog.report.application.dto.ability.ChildAbilityDto)2 DefaultAbilityNotFoundException (wooteco.prolog.report.exception.DefaultAbilityNotFoundException)2 IntegrationTest (wooteco.support.utils.IntegrationTest)2 RestAssured (io.restassured.RestAssured)1 ContentType (io.restassured.http.ContentType)1 List (java.util.List)1