Search in sources :

Example 1 with ReportResponse

use of wooteco.prolog.report.application.dto.report.response.ReportResponse in project prolog by woowacourse.

the class ReportStepDefinitions method 리포트가수정된다.

@Then("리포트가 수정된다")
public void 리포트가수정된다() {
    int status = context.response.statusCode();
    assertThat(status).isEqualTo(200);
    ReportResponse reportResponse = context.response.as(ReportResponse.class);
    ReportRequest reportRequest = (ReportRequest) context.storage.get("reportRequest");
    ReportResponse expected = new ReportResponse(reportRequest.getId(), reportRequest.getTitle(), reportRequest.getDescription(), LocalDateTime.now(), LocalDateTime.now(), new GraphResponse(Arrays.asList(new GraphAbilityResponse(3L, "디자인", "blue", 2L, 1.0, true), new GraphAbilityResponse(1L, "프로그래밍", "red", 2L, 0.0, false))), Arrays.asList(new StudylogResponse(reportRequest.getStudylogs().get(0).getId(), LocalDateTime.now(), LocalDateTime.now(), "[자바][옵셔널] 학습log 제출합니다.", Arrays.asList(new StudylogAbilityResponse(3L, "디자인", "blue", true)))), true);
    assertThat(reportResponse).usingRecursiveComparison().ignoringFields("studylogs.createAt", "studylogs.updateAt", "createdAt", "updatedAt").isEqualTo(expected);
}
Also used : ReportResponse(wooteco.prolog.report.application.dto.report.response.ReportResponse) StudylogAbilityResponse(wooteco.prolog.report.application.dto.report.response.studylogs.StudylogAbilityResponse) GraphResponse(wooteco.prolog.report.application.dto.report.response.ability_graph.GraphResponse) ReportRequest(wooteco.prolog.report.application.dto.report.request.ReportRequest) GraphAbilityResponse(wooteco.prolog.report.application.dto.report.response.ability_graph.GraphAbilityResponse) StudylogResponse(wooteco.prolog.report.application.dto.report.response.studylogs.StudylogResponse) Then(io.cucumber.java.en.Then)

Example 2 with ReportResponse

use of wooteco.prolog.report.application.dto.report.response.ReportResponse in project prolog by woowacourse.

the class ReportDocumentation method 레포트를업데이트한다.

@Test
void 레포트를업데이트한다() {
    final ReportResponse reportResponse = 리포트조회(1L);
    final ReportRequest changedReport = 리포트변경(reportResponse);
    given("reports/update").contentType(ContentType.JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + 로그인(GithubResponses.티케)).body(changedReport).when().put("/reports/{reportId}", 1).then().statusCode(HttpStatus.OK.value()).extract();
}
Also used : ReportResponse(wooteco.prolog.report.application.dto.report.response.ReportResponse) ReportRequest(wooteco.prolog.report.application.dto.report.request.ReportRequest) Test(org.junit.jupiter.api.Test)

Example 3 with ReportResponse

use of wooteco.prolog.report.application.dto.report.response.ReportResponse in project prolog by woowacourse.

the class ReportServiceTest method createReport.

@Test
void createReport() throws IOException {
    Member member = createMember();
    setAbilities(member);
    setStudylogs(member);
    ReportRequest reportRequest = createRequest("jsons/report_post_request.json");
    ReportResponse reportResponse = reportService.createReport(reportRequest, new LoginMember(member.getId(), Authority.MEMBER));
    assertThat(reportResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*id", ".*updateAt", ".*createAt", ".*createdAt", ".*updatedAt").isEqualTo(expected("jsons/report_post_response.json"));
}
Also used : ReportResponse(wooteco.prolog.report.application.dto.report.response.ReportResponse) LoginMember(wooteco.prolog.login.ui.LoginMember) ReportRequest(wooteco.prolog.report.application.dto.report.request.ReportRequest) LoginMember(wooteco.prolog.login.ui.LoginMember) Member(wooteco.prolog.member.domain.Member) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with ReportResponse

use of wooteco.prolog.report.application.dto.report.response.ReportResponse in project prolog by woowacourse.

the class ReportStepDefinitions method 대표리포트생성날짜순으로정렬되어반환된다.

@Then("대표리포트, 생성날짜 순으로 정렬되어 반환된다")
public void 대표리포트생성날짜순으로정렬되어반환된다() {
    ReportPageableResponse pageableResponse = context.response.as(new TypeRef<ReportPageableResponse>() {
    });
    List<ReportResponse> response = pageableResponse.getReports();
    List<Long> ids = response.stream().map(ReportResponse::getId).collect(toList());
    List<Long> expected = response.stream().sorted(comparing(ReportResponse::isRepresent).thenComparing(ReportResponse::getCreatedAt).reversed()).map(ReportResponse::getId).collect(toList());
    assertThat(ids).containsExactlyElementsOf(expected);
}
Also used : ReportResponse(wooteco.prolog.report.application.dto.report.response.ReportResponse) ReportPageableResponse(wooteco.prolog.report.application.dto.report.response.ReportPageableResponse) SimpleReportPageableResponse(wooteco.prolog.report.application.dto.report.response.SimpleReportPageableResponse) Then(io.cucumber.java.en.Then)

Example 5 with ReportResponse

use of wooteco.prolog.report.application.dto.report.response.ReportResponse in project prolog by woowacourse.

the class ReportServiceTest method updateReport.

@Test
void updateReport() throws IOException {
    Member member = createMember();
    setAbilities(member);
    setStudylogs(member);
    ReportRequest request = createRequest("jsons/report_post_request.json");
    reportService.createReport(request, new LoginMember(member.getId(), Authority.MEMBER));
    ReportRequest updateRequest = createRequest("jsons/report_put_request.json");
    ReportResponse reportResponse = reportService.updateReport(1L, updateRequest, new LoginMember(member.getId(), Authority.MEMBER));
    assertThat(reportResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*id", ".*updateAt", ".*createAt", ".*createdAt", ".*updatedAt").isEqualTo(expected("jsons/report_put_response.json"));
}
Also used : ReportResponse(wooteco.prolog.report.application.dto.report.response.ReportResponse) LoginMember(wooteco.prolog.login.ui.LoginMember) ReportRequest(wooteco.prolog.report.application.dto.report.request.ReportRequest) LoginMember(wooteco.prolog.login.ui.LoginMember) Member(wooteco.prolog.member.domain.Member) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ReportResponse (wooteco.prolog.report.application.dto.report.response.ReportResponse)6 ReportRequest (wooteco.prolog.report.application.dto.report.request.ReportRequest)5 Test (org.junit.jupiter.api.Test)4 Then (io.cucumber.java.en.Then)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 LoginMember (wooteco.prolog.login.ui.LoginMember)2 Member (wooteco.prolog.member.domain.Member)2 ReportPageableResponse (wooteco.prolog.report.application.dto.report.response.ReportPageableResponse)1 SimpleReportPageableResponse (wooteco.prolog.report.application.dto.report.response.SimpleReportPageableResponse)1 GraphAbilityResponse (wooteco.prolog.report.application.dto.report.response.ability_graph.GraphAbilityResponse)1 GraphResponse (wooteco.prolog.report.application.dto.report.response.ability_graph.GraphResponse)1 StudylogAbilityResponse (wooteco.prolog.report.application.dto.report.response.studylogs.StudylogAbilityResponse)1 StudylogResponse (wooteco.prolog.report.application.dto.report.response.studylogs.StudylogResponse)1