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());
}
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(새로운_색상);
}
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);
}
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("중복된 이름의 역량이 존재합니다.");
}
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("중복된 색상의 부모역량이 존재합니다.");
}
Aggregations