Search in sources :

Example 1 with StudylogRequest

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

the class StudylogDocumentation method 스터디로그를_생성한다.

@Test
void 스터디로그를_생성한다() {
    // given
    StudylogRequest studylog = createStudylogRequest1();
    List<StudylogRequest> studylogRequest = Arrays.asList(studylog);
    // when
    ExtractableResponse<Response> createResponse = given("studylog/create").header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()).body(studylogRequest).contentType(MediaType.APPLICATION_JSON_VALUE).when().post("/studylogs").then().log().all().extract();
    // then
    assertThat(createResponse.statusCode()).isEqualTo(HttpStatus.CREATED.value());
    assertThat(createResponse.header("Location")).isNotNull();
}
Also used : StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) MissionResponse(wooteco.prolog.studylog.application.dto.MissionResponse) LevelResponse(wooteco.prolog.studylog.application.dto.LevelResponse) ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) StudylogsResponse(wooteco.prolog.studylog.application.dto.StudylogsResponse) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest) Test(org.junit.jupiter.api.Test)

Example 2 with StudylogRequest

use of wooteco.prolog.studylog.application.dto.StudylogRequest 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 3 with StudylogRequest

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

the class StudylogStepDefinitions method 세션과미션포함한스터디로그를작성하면.

// @Given("스터디로그를 작성하고")
// @When("스터디로그를 작성하면")
// public void 스터디로그를작성하면() {
// context.invokeHttpPostWithToken("/studylogs", STUDYLOG1.getStudylogRequest());
// }
@Given("스터디로그를 작성하고")
@When("스터디로그를 작성하면")
public void 세션과미션포함한스터디로그를작성하면() {
    StudylogRequest studylogRequest = new StudylogRequest("[자바][옵셔널] 학습log 제출합니다.", "옵셔널은 NPE를 배제하기 위해 만들어진 자바8에 추가된 라이브러리입니다. \n " + "다양한 메소드를 호출하여 원하는 대로 활용할 수 있습니다", 1L, 1L, Lists.newArrayList(new TagRequest(TAG1.getTagName()), new TagRequest(TAG2.getTagName())));
    context.invokeHttpPostWithToken("/studylogs", studylogRequest);
    if (context.response.statusCode() == HttpStatus.CREATED.value()) {
        context.storage.put("studylog", context.response.as(StudylogResponse.class));
    }
}
Also used : TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest) When(io.cucumber.java.en.When) Given(io.cucumber.java.en.Given)

Example 4 with StudylogRequest

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

the class MemberDocumentation method createStudylogRequest.

private List<StudylogRequest> createStudylogRequest(int size) {
    List<StudylogRequest> studylogRequests = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        String title = "뭐라도 스터디로그가 있어야하니까";
        String content = "SPA 방식으로 앱을 구현하였음.\n" + "router 를 구현 하여 이용함.\n";
        Long sessionId = 세션_등록함(new SessionRequest("세션" + i));
        Long missionId = 미션_등록함(new MissionRequest(String.format("세션%d 미션", i), sessionId));
        List<TagRequest> tags = Arrays.asList(new TagRequest(String.format("%d번 태그", i)));
        studylogRequests.add(new StudylogRequest(title, content, missionId, tags));
    }
    return studylogRequests;
}
Also used : MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) ArrayList(java.util.ArrayList) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest)

Example 5 with StudylogRequest

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

the class StudylogRssFeedDocumentation method studylogRequest1.

private StudylogRequest studylogRequest1() {
    Long sessionId = 세션_등록함(new SessionRequest("세션 1"));
    Long missionId = 미션_등록함(new MissionRequest("세션 1 - 어떤 미션", sessionId));
    return new StudylogRequest("어떤 타이틀", "어떤 내용", missionId, Arrays.asList(new TagRequest("어떤 태그 1"), new TagRequest("어떤 태그 2")));
}
Also used : MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest)

Aggregations

StudylogRequest (wooteco.prolog.studylog.application.dto.StudylogRequest)15 TagRequest (wooteco.prolog.studylog.application.dto.TagRequest)11 MissionRequest (wooteco.prolog.session.application.dto.MissionRequest)9 SessionRequest (wooteco.prolog.session.application.dto.SessionRequest)9 StudylogResponse (wooteco.prolog.studylog.application.dto.StudylogResponse)7 Test (org.junit.jupiter.api.Test)5 ExtractableResponse (io.restassured.response.ExtractableResponse)3 Response (io.restassured.response.Response)3 Given (io.cucumber.java.en.Given)2 When (io.cucumber.java.en.When)2 DisplayName (org.junit.jupiter.api.DisplayName)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MissionResponse (wooteco.prolog.session.application.dto.MissionResponse)2 SessionResponse (wooteco.prolog.session.application.dto.SessionResponse)2 CalendarStudylogResponse (wooteco.prolog.studylog.application.dto.CalendarStudylogResponse)2 StudylogsResponse (wooteco.prolog.studylog.application.dto.StudylogsResponse)2 IntegrationTest (wooteco.support.utils.IntegrationTest)2 ArrayList (java.util.ArrayList)1 LevelResponse (wooteco.prolog.studylog.application.dto.LevelResponse)1 MissionResponse (wooteco.prolog.studylog.application.dto.MissionResponse)1