use of wooteco.prolog.ability.application.dto.AbilityCreateRequest 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.ability.application.dto.AbilityCreateRequest in project prolog by woowacourse.
the class AbilityServiceTest method createAbilityNameDuplicateException.
@DisplayName("역량을 생성할 때 기존에 존재하는 역량과 이름이 같은 경우 예외가 발생한다.")
@Test
void createAbilityNameDuplicateException() {
// given
String name = "zi존브라운123";
AbilityCreateRequest request1 = new AbilityCreateRequest(name, "이견 있습니까?", "이견을 피로 물들이는 붉은 색", null);
abilityService.createAbility(member.getId(), request1);
// when, then
AbilityCreateRequest request2 = new AbilityCreateRequest(name, "없어용", "침묵의 검은 색", null);
assertThatThrownBy(() -> abilityService.createAbility(member.getId(), request2)).isExactlyInstanceOf(AbilityNameDuplicateException.class);
}
use of wooteco.prolog.ability.application.dto.AbilityCreateRequest 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.ability.application.dto.AbilityCreateRequest in project prolog by woowacourse.
the class AbilityServiceTest method createParentAbilityColorDuplicateException.
@DisplayName("부모 역량을 생성할 때 기존에 존재하는 다른 역량들과 색상이 같은 경우 예외가 발생한다.")
@Test
void createParentAbilityColorDuplicateException() {
// given
String color = "이견을 피로 물들이는 붉은 색";
AbilityCreateRequest request1 = new AbilityCreateRequest("zi존브라운123", "이견 있습니까?", color, null);
abilityService.createAbility(member.getId(), request1);
// when, then
AbilityCreateRequest request2 = new AbilityCreateRequest("그냥막구현해", "없어용", color, null);
assertThatThrownBy(() -> abilityService.createAbility(member.getId(), request2)).isExactlyInstanceOf(AbilityParentColorDuplicateException.class);
}
use of wooteco.prolog.ability.application.dto.AbilityCreateRequest in project prolog by woowacourse.
the class AbilityServiceTest method createAbilityException.
@DisplayName("역량을 생성 할 때 부모역량 ID와 일치하는 역량이 없으면 예외가 발생한다.")
@Test
void createAbilityException() {
// given
AbilityCreateRequest abilityCreateRequest = new AbilityCreateRequest("zi존브라운123", "이견 있습니까?", "이견을 피로 물들이는 붉은 색", Long.MAX_VALUE);
// when, then
assertThatThrownBy(() -> abilityService.createAbility(member.getId(), abilityCreateRequest)).isExactlyInstanceOf(AbilityNotFoundException.class);
}
Aggregations