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);
}
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);
}
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);
}
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)));
}
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);
}
Aggregations