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