Search in sources :

Example 1 with HierarchyAbilityResponse

use of wooteco.prolog.ability.application.dto.HierarchyAbilityResponse 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);
}
Also used : DefaultAbility(wooteco.prolog.ability.domain.DefaultAbility) Ability(wooteco.prolog.ability.domain.Ability) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with HierarchyAbilityResponse

use of wooteco.prolog.ability.application.dto.HierarchyAbilityResponse 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);
}
Also used : AbilityCreateRequest(wooteco.prolog.ability.application.dto.AbilityCreateRequest) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) DefaultAbilityNotFoundException(wooteco.prolog.report.exception.DefaultAbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.ability.application.dto.AbilityUpdateRequest) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with HierarchyAbilityResponse

use of wooteco.prolog.ability.application.dto.HierarchyAbilityResponse 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);
}
Also used : AbilityCreateRequest(wooteco.prolog.ability.application.dto.AbilityCreateRequest) AbilityResponse(wooteco.prolog.ability.application.dto.AbilityResponse) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) AbilityNotFoundException(wooteco.prolog.report.exception.AbilityNotFoundException) DefaultAbilityNotFoundException(wooteco.prolog.report.exception.DefaultAbilityNotFoundException) AbilityUpdateRequest(wooteco.prolog.ability.application.dto.AbilityUpdateRequest) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with HierarchyAbilityResponse

use of wooteco.prolog.ability.application.dto.HierarchyAbilityResponse 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)));
}
Also used : DefaultAbility(wooteco.prolog.ability.domain.DefaultAbility) Ability(wooteco.prolog.ability.domain.Ability) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with HierarchyAbilityResponse

use of wooteco.prolog.ability.application.dto.HierarchyAbilityResponse in project prolog by woowacourse.

the class StudylogAbilityStepDefinitions method 역량에학습로그를맵핑하면.

@When("{string} 학습로그에 {string} 역량을 맵핑하(면)(고)")
public void 역량에학습로그를맵핑하면(String studylogName, String abilityName) {
    HierarchyAbilityResponse ability = (HierarchyAbilityResponse) context.storage.get(abilityName);
    StudylogResponse studylog = (StudylogResponse) context.storage.get(studylogName);
    StudylogAbilityRequest requestBody = new StudylogAbilityRequest(Lists.newArrayList(ability.getId()));
    context.invokeHttpPutWithToken("/studylogs/" + studylog.getId() + "/abilities", requestBody);
}
Also used : HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) AbilityStudylogResponse(wooteco.prolog.ability.application.dto.AbilityStudylogResponse) StudylogAbilityRequest(wooteco.prolog.ability.application.dto.StudylogAbilityRequest) When(io.cucumber.java.en.When)

Aggregations

HierarchyAbilityResponse (wooteco.prolog.ability.application.dto.HierarchyAbilityResponse)13 DisplayName (org.junit.jupiter.api.DisplayName)8 Test (org.junit.jupiter.api.Test)8 IntegrationTest (wooteco.support.utils.IntegrationTest)8 AbilityCreateRequest (wooteco.prolog.ability.application.dto.AbilityCreateRequest)5 AbilityUpdateRequest (wooteco.prolog.ability.application.dto.AbilityUpdateRequest)5 Ability (wooteco.prolog.ability.domain.Ability)4 DefaultAbility (wooteco.prolog.ability.domain.DefaultAbility)4 Then (io.cucumber.java.en.Then)2 When (io.cucumber.java.en.When)2 AbilityResponse (wooteco.prolog.ability.application.dto.AbilityResponse)2 AbilityStudylogResponse (wooteco.prolog.ability.application.dto.AbilityStudylogResponse)2 StudylogAbilityRequest (wooteco.prolog.ability.application.dto.StudylogAbilityRequest)2 AbilityNotFoundException (wooteco.prolog.report.exception.AbilityNotFoundException)2 DefaultAbilityNotFoundException (wooteco.prolog.report.exception.DefaultAbilityNotFoundException)2 StudylogResponse (wooteco.prolog.studylog.application.dto.StudylogResponse)2 Transactional (org.springframework.transaction.annotation.Transactional)1 StudylogAbility (wooteco.prolog.ability.domain.StudylogAbility)1 Report (wooteco.prolog.report.domain.Report)1 ReportAbility (wooteco.prolog.report.domain.ReportAbility)1