Search in sources :

Example 1 with TagResponse

use of wooteco.prolog.studylog.application.dto.TagResponse in project prolog by woowacourse.

the class TagDocumentation method 태그_목록을_조회한다.

@Test
void 태그_목록을_조회한다() {
    // given
    String title = "SPA";
    String content = "SPA 방식으로 앱을 구현하였음.\n" + "router 를 구현 하여 이용함.\n";
    Long sessionId = 세션_등록함(new SessionRequest("세션1"));
    Long missionId = 미션_등록함(new MissionRequest("세션1 - 지하철 노선도 미션", sessionId));
    List<TagRequest> tags = Arrays.asList(new TagRequest("자바"), new TagRequest("파이썬"));
    StudylogRequest studylogRequest = new StudylogRequest(title, content, missionId, tags);
    List<StudylogRequest> params = Arrays.asList(studylogRequest);
    RestAssured.given().header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()).body(params).contentType(MediaType.APPLICATION_JSON_VALUE).when().post("/posts").then().log().all();
    // when
    ExtractableResponse<Response> response = given("tag/list").when().get("/tags").then().log().all().extract();
    // then
    List<TagResponse> tagResponses = response.jsonPath().getList(".", TagResponse.class);
    List<String> tagNames = tagResponses.stream().map(TagResponse::getName).collect(Collectors.toList());
    List<String> expectedNames = tags.stream().map(TagRequest::getName).collect(Collectors.toList());
    assertThat(tagNames).usingRecursiveComparison().isEqualTo(expectedNames);
}
Also used : TagResponse(wooteco.prolog.studylog.application.dto.TagResponse) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest) MissionResponse(wooteco.prolog.session.application.dto.MissionResponse) SessionResponse(wooteco.prolog.session.application.dto.SessionResponse) TagResponse(wooteco.prolog.studylog.application.dto.TagResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest) Test(org.junit.jupiter.api.Test)

Example 2 with TagResponse

use of wooteco.prolog.studylog.application.dto.TagResponse in project prolog by woowacourse.

the class FilterController method showAll.

@GetMapping
public ResponseEntity<FilterResponse> showAll() {
    List<LevelResponse> levelResponses = levelService.findAll();
    List<MissionResponse> missionResponses = missionService.findAll();
    List<TagResponse> tagResponses = tagService.findTagsIncludedInStudylogs();
    List<MemberResponse> memberResponses = memberService.findAll();
    return ResponseEntity.ok().body(new FilterResponse(levelResponses, missionResponses, tagResponses, memberResponses));
}
Also used : MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) MissionResponse(wooteco.prolog.studylog.application.dto.MissionResponse) TagResponse(wooteco.prolog.studylog.application.dto.TagResponse) FilterResponse(wooteco.prolog.studylog.application.dto.FilterResponse) LevelResponse(wooteco.prolog.studylog.application.dto.LevelResponse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with TagResponse

use of wooteco.prolog.studylog.application.dto.TagResponse in project prolog by woowacourse.

the class TagServiceTest method onlyNewTagSaveTest.

@DisplayName("기존에 저장되어있는 태그가 있을 때, 신규건만 저장되는지 확인")
@Test
void onlyNewTagSaveTest() {
    // given
    tagService.findOrCreate(tagRequests);
    List<TagRequest> newTagRequests = Arrays.asList(new TagRequest("새로운태그1"), new TagRequest("새로운태그2"), new TagRequest("새로운태그3"));
    // when
    List<TagRequest> addedTagRequest = tagRequests;
    // 신규 건수 3건 추가, 총 8건
    addedTagRequest.addAll(newTagRequests);
    tagService.findOrCreate(addedTagRequest);
    List<TagResponse> expectedResults = tagService.findAll();
    // then
    List<String> givenNames = getNamesFromTagRequest(addedTagRequest);
    List<String> expectedNames = getNamesFromTagResponse(expectedResults);
    assertThat(expectedResults.size()).isEqualTo(// 중복된 것은 insert되지 않고 8개만 입력되는지 확인
    addedTagRequest.size());
    assertThat(givenNames).containsExactlyElementsOf(expectedNames);
}
Also used : TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) TagResponse(wooteco.prolog.studylog.application.dto.TagResponse) Test(org.junit.jupiter.api.Test) IntegrationTest(wooteco.support.utils.IntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TagResponse (wooteco.prolog.studylog.application.dto.TagResponse)3 Test (org.junit.jupiter.api.Test)2 TagRequest (wooteco.prolog.studylog.application.dto.TagRequest)2 ExtractableResponse (io.restassured.response.ExtractableResponse)1 Response (io.restassured.response.Response)1 DisplayName (org.junit.jupiter.api.DisplayName)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 MemberResponse (wooteco.prolog.member.application.dto.MemberResponse)1 MissionRequest (wooteco.prolog.session.application.dto.MissionRequest)1 MissionResponse (wooteco.prolog.session.application.dto.MissionResponse)1 SessionRequest (wooteco.prolog.session.application.dto.SessionRequest)1 SessionResponse (wooteco.prolog.session.application.dto.SessionResponse)1 FilterResponse (wooteco.prolog.studylog.application.dto.FilterResponse)1 LevelResponse (wooteco.prolog.studylog.application.dto.LevelResponse)1 MissionResponse (wooteco.prolog.studylog.application.dto.MissionResponse)1 StudylogRequest (wooteco.prolog.studylog.application.dto.StudylogRequest)1 IntegrationTest (wooteco.support.utils.IntegrationTest)1