Search in sources :

Example 21 with Ability

use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.

the class AbilityService method updateAbility.

@Transactional
public void updateAbility(Long memberId, Long abilityId, AbilityUpdateRequest request) {
    Ability ability = findAbilityByIdAndMemberId(abilityId, memberId);
    List<Ability> abilities = new ArrayList<>(findByMemberId(memberId));
    // 수정할 대상은 중복 검증을 하지 않는다.
    abilities.remove(ability);
    request.toEntity().validateDuplicateName(abilities);
    if (ability.isParent()) {
        request.toEntity().validateDuplicateColor(abilities, ability);
    }
    ability.update(request.toEntity());
}
Also used : DefaultAbility(wooteco.prolog.ability.domain.DefaultAbility) Ability(wooteco.prolog.ability.domain.Ability) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Ability (wooteco.prolog.ability.domain.Ability)21 DefaultAbility (wooteco.prolog.ability.domain.DefaultAbility)14 DisplayName (org.junit.jupiter.api.DisplayName)11 Test (org.junit.jupiter.api.Test)11 Member (wooteco.prolog.member.domain.Member)7 IntegrationTest (wooteco.support.utils.IntegrationTest)6 Transactional (org.springframework.transaction.annotation.Transactional)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 HierarchyAbilityResponse (wooteco.prolog.ability.application.dto.HierarchyAbilityResponse)4 AbilityResponse (wooteco.prolog.ability.application.dto.AbilityResponse)2 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Disabled (org.junit.jupiter.api.Disabled)1 EventListener (org.springframework.context.event.EventListener)1 Page (org.springframework.data.domain.Page)1 Pageable (org.springframework.data.domain.Pageable)1 Service (org.springframework.stereotype.Service)1