use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityTest method nameDuplicateException.
@DisplayName("역량끼리 이름이 같은 경우 예외가 발생한다.")
@Test
void nameDuplicateException() {
// given
String name = "역량";
Ability ability1 = Ability.parent(1L, "역량", "너잘의 3인칭 역량", "파란색", member);
Ability ability2 = Ability.parent(2L, "역량", "아따따뚜겐", "초록색", member);
// when, then
assertThatThrownBy(() -> ability1.validateDuplicateName(Collections.singletonList(ability2))).isExactlyInstanceOf(AbilityNameDuplicateException.class);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method parentAbilities.
@DisplayName("부모 역량만을 조회한다. (자식 정보가 포함되지 않는다.)")
@Test
void parentAbilities() {
// given
Ability parentAbility = abilityRepository.save(Ability.parent("메타버스", "폴리곤 덩어리들", "123456", member));
Ability childAbility = abilityRepository.save(Ability.child("마자용", "마자아아아~용", "123456", parentAbility, member));
HierarchyAbilityResponse expectResponse = new HierarchyAbilityResponse(parentAbility.getId(), parentAbility.getName(), parentAbility.getDescription(), parentAbility.getColor(), parentAbility.isParent(), AbilityResponse.listOf(Collections.singletonList(childAbility)));
// when
List<HierarchyAbilityResponse> responses = abilityService.findParentAbilitiesByMemberId(member.getId());
// then
assertThat(responses).hasSize(1);
assertThat(responses.get(0)).usingRecursiveComparison().isEqualTo(expectResponse);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method deleteParentAbility.
@DisplayName("부모 역량 삭제에 성공하면 조회되지 않는다.")
@Test
void deleteParentAbility() {
// given
Ability ability = abilityRepository.save(Ability.parent("zi존브라운123", "이견 있습니까?", "이견을 피로 물들이는 붉은 색", member));
// when
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).usingRecursiveComparison().isEqualTo(HierarchyAbilityResponse.listOf(Collections.singletonList(ability)));
abilityService.deleteAbility(member.getId(), ability.getId());
// then
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).isEmpty();
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityServiceTest method findAbilitiesByMemberUsername.
@DisplayName("username을 통해 해당 멤버의 역량 목록을 조회한다.")
@Test
void findAbilitiesByMemberUsername() {
// given
Ability ability1 = abilityRepository.save(Ability.parent("나는ZI존브라운이다.", "이견있나?", "피의 붉은 색", member));
Ability ability2 = abilityRepository.save(Ability.parent("나는킹갓브라운이다.", "이견은 없겠지?", "무지개 색", member));
// when
List<HierarchyAbilityResponse> abilityResponses = abilityService.findAbilitiesByMemberUsername(member.getUsername());
// then
assertThat(abilityResponses).usingRecursiveComparison().isEqualTo(HierarchyAbilityResponse.listOf(Arrays.asList(ability1, ability2)));
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method createAbility.
@Transactional
public AbilityResponse createAbility(Long memberId, AbilityCreateRequest request) {
Member member = memberService.findById(memberId);
Ability ability = extractAbility(member, request);
return AbilityResponse.of(abilityRepository.save(ability));
}
Aggregations