use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityTest method colorDuplicateException.
@DisplayName("서로 다른 역량끼리 색상이 같은 경우 예외가 발생한다.")
@Test
void colorDuplicateException() {
// given
String color = "색상";
Ability ability1 = Ability.parent(1L, "역량1", "너잘의 3인칭 역량", color, member);
Ability ability2 = Ability.parent(2L, "역량2", "아따따뚜겐", color, member);
// when, then
assertThatThrownBy(() -> ability1.validateDuplicateColor(Collections.singletonList(ability2))).isExactlyInstanceOf(AbilityParentColorDuplicateException.class);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityTest method parametersForIsParent.
private static Stream<Arguments> parametersForIsParent() {
Member member = mock(Member.class);
Ability parent = Ability.parent(1L, "Language", "discription", "red", member);
return Stream.of(Arguments.of(parent, true), Arguments.of(Ability.child(2L, "Language", "discription", "red", parent, member), false));
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method updateAbilityChildCanNotChangeColor.
@DisplayName("역량 정보를 수정할 때 자식 역량의 경우 색상이 변경되지 않는다.")
@Test
void updateAbilityChildCanNotChangeColor() {
// given
String legacyColor = "#111111";
AbilityCreateRequest createParentRequest1 = new AbilityCreateRequest("부모 프로그래밍", "프로그래밍 역량입니다.", legacyColor, null);
abilityService.createAbility(member.getId(), createParentRequest1);
HierarchyAbilityResponse createdParentResponse = abilityService.findParentAbilitiesByMemberId(member.getId()).get(0);
AbilityCreateRequest createChildRequest1 = new AbilityCreateRequest("자식 프로그래밍", "부모 프로그래밍의 자식입니다.", createdParentResponse.getColor(), createdParentResponse.getId());
abilityService.createAbility(member.getId(), createChildRequest1);
AbilityResponse childAbilityDto = abilityService.findParentAbilitiesByMemberId(member.getId()).get(0).getChildren().get(0);
String newColor = "#ffffff";
String newName = "완전히 새로운 이름";
String newDescription = "완전히 새로운건데요?!";
AbilityUpdateRequest request = new AbilityUpdateRequest(childAbilityDto.getId(), newName, newDescription, newColor);
// when
abilityService.updateAbility(member.getId(), request.getId(), request);
// then
Ability ability = abilityService.findAbilityById(childAbilityDto.getId());
assertThat(ability.getName()).isEqualTo(newName);
assertThat(ability.getDescription()).isEqualTo(newDescription);
assertThat(ability.getColor()).isEqualTo(legacyColor);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method deleteParentAbilityAndChildrenAbilities.
// 스펙이 변경되어 Disabled 처리함
@Disabled
@DisplayName("부모 역량 삭제에 성공하면 부모의 자역 역량도 모두 삭제된다.")
@Test
void deleteParentAbilityAndChildrenAbilities() {
// given
Ability parentAbility = abilityRepository.save(Ability.parent("브라운", "파파 브라운", "갈색", member));
Ability childAbility1 = abilityRepository.save(Ability.child("현구막", "썬 현구막", "갈색", parentAbility, member));
Ability childAbility2 = abilityRepository.save(Ability.child("서니", "도터 서니", "갈색", parentAbility, member));
// when
assertThat(abilityRepository.findAll()).containsExactly(parentAbility, childAbility1, childAbility2);
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).hasSize(3);
abilityService.deleteAbility(member.getId(), parentAbility.getId());
// then
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).isEmpty();
assertThat(abilityRepository.findById(parentAbility.getId())).isNotPresent();
assertThat(abilityRepository.findById(childAbility1.getId())).isNotPresent();
assertThat(abilityRepository.findById(childAbility2.getId())).isNotPresent();
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method deleteChildAbility.
@DisplayName("자식 역량 삭제에 성공하면 부모 역량과 관계가 끊어진다.")
@Test
void deleteChildAbility() {
// given
Ability parentAbility = abilityRepository.save(Ability.parent("zi존브라운123", "이견 있습니까?", "이견을 피로 물들이는 붉은 색", member));
Ability childAbility = abilityRepository.save(Ability.child("손너잘", "내안으어두미", "이견을 피로 물들이는 붉은 색", parentAbility, member));
// when
assertThat(parentAbility.getChildren()).containsExactly(childAbility);
abilityService.deleteAbility(member.getId(), childAbility.getId());
List<HierarchyAbilityResponse> abilityResponses = abilityService.findAbilitiesByMemberId(member.getId());
List<Long> abilityIds = abilityResponses.stream().map(HierarchyAbilityResponse::getId).collect(Collectors.toList());
// then
assertThat(abilityIds).containsExactly(parentAbility.getId());
}
Aggregations