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(새로운_색상);
}
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(새로운_색상);
}
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);
}
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);
}
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(새로운_색상);
}
Aggregations