From 634a92818775bcbbba52804a4bb35ee5dbac6e30 Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 13:36:15 +0900 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20(#743)=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=ED=95=9C=20=ED=9A=8C=EC=9B=90=EC=9D=98=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=EB=A7=8C=20=EB=B3=B4=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntroller.java => AlarmQueryController.java} | 9 ++++++--- .../controller/AlarmQueryControllerDocs.java | 5 ++++- .../alarm/repository/AlarmRepository.java | 2 +- .../alarm/service/AlarmQueryService.java | 4 ++-- .../controller/AlarmQueryControllerTest.java | 9 ++++++--- .../alarm/service/AlarmQueryServiceTest.java | 18 ++++++++++++------ 6 files changed, 31 insertions(+), 16 deletions(-) rename backend/src/main/java/com/votogether/domain/alarm/controller/{AlarmQueryQueryController.java => AlarmQueryController.java} (77%) diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryQueryController.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java similarity index 77% rename from backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryQueryController.java rename to backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java index 886705223..e90f4f822 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryQueryController.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java @@ -2,6 +2,8 @@ import com.votogether.domain.alarm.dto.response.PostAlarmResponse; import com.votogether.domain.alarm.service.AlarmQueryService; +import com.votogether.domain.member.entity.Member; +import com.votogether.global.jwt.Auth; import jakarta.validation.constraints.PositiveOrZero; import java.util.List; import lombok.RequiredArgsConstructor; @@ -16,15 +18,16 @@ @RequiredArgsConstructor @RequestMapping("/alarms") @RestController -public class AlarmQueryQueryController implements AlarmQueryControllerDocs { +public class AlarmQueryController implements AlarmQueryControllerDocs { private final AlarmQueryService alarmQueryService; @GetMapping("/content") public ResponseEntity> getPostAlarm( - @RequestParam @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page + @RequestParam @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, + @Auth final Member loginMember ) { - final List postAlarmResponses = alarmQueryService.getPostAlarm(page); + final List postAlarmResponses = alarmQueryService.getPostAlarm(page, loginMember); return ResponseEntity.ok(postAlarmResponses); } diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java index 490e2dae2..ebc83959b 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java @@ -1,7 +1,9 @@ package com.votogether.domain.alarm.controller; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; +import com.votogether.domain.member.entity.Member; import com.votogether.global.exception.ExceptionResponse; +import com.votogether.global.jwt.Auth; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -28,7 +30,8 @@ public interface AlarmQueryControllerDocs { ) }) ResponseEntity> getPostAlarm( - @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page + @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, + @Auth final Member loginMember ); } diff --git a/backend/src/main/java/com/votogether/domain/alarm/repository/AlarmRepository.java b/backend/src/main/java/com/votogether/domain/alarm/repository/AlarmRepository.java index 2a0191cbc..3050ce13f 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/repository/AlarmRepository.java +++ b/backend/src/main/java/com/votogether/domain/alarm/repository/AlarmRepository.java @@ -9,7 +9,7 @@ public interface AlarmRepository extends JpaRepository { - Slice findAllByOrderByCreatedAtDesc(final Pageable pageable); + Slice findAllByMemberOrderByCreatedAtDesc(final Member member, final Pageable pageable); List findAllByMember(final Member member); diff --git a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java index 16c93abc9..988fcc841 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java +++ b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java @@ -22,9 +22,9 @@ public class AlarmQueryService { private final AlarmRepository alarmRepository; - public List getPostAlarm(final int page) { + public List getPostAlarm(final int page, final Member member) { final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE); - final Slice alarms = alarmRepository.findAllByOrderByCreatedAtDesc(pageRequest); + final Slice alarms = alarmRepository.findAllByMemberOrderByCreatedAtDesc(member, pageRequest); return getPostAlarmResponses(alarms); } diff --git a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java index 0de5d3564..212cec32e 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java @@ -6,7 +6,9 @@ import com.votogether.domain.alarm.dto.response.PostAlarmDetailResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; import com.votogether.domain.alarm.service.AlarmQueryService; +import com.votogether.domain.member.entity.Member; import com.votogether.test.ControllerTest; +import com.votogether.test.fixtures.MemberFixtures; import io.restassured.common.mapper.TypeRef; import io.restassured.module.mockmvc.RestAssuredMockMvc; import java.time.LocalDateTime; @@ -18,7 +20,7 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpHeaders; -@WebMvcTest(AlarmQueryQueryController.class) +@WebMvcTest(AlarmQueryController.class) class AlarmQueryControllerTest extends ControllerTest { @MockBean @@ -26,7 +28,7 @@ class AlarmQueryControllerTest extends ControllerTest { @BeforeEach void setUp() { - RestAssuredMockMvc.standaloneSetup(new AlarmQueryQueryController(alarmQueryService)); + RestAssuredMockMvc.standaloneSetup(new AlarmQueryController(alarmQueryService)); } @Test @@ -36,11 +38,12 @@ void getPostAlarm() throws Exception { mockingAuthArgumentResolver(); int page = 0; + Member member = MemberFixtures.FEMALE_20.get(); PostAlarmDetailResponse postAlarmDetailResponse = new PostAlarmDetailResponse(1L, "title", "저문"); PostAlarmResponse postAlarmResponse = new PostAlarmResponse(1L, postAlarmDetailResponse, LocalDateTime.now(), false); - given(alarmQueryService.getPostAlarm(page)).willReturn(List.of(postAlarmResponse)); + given(alarmQueryService.getPostAlarm(page, member)).willReturn(List.of(postAlarmResponse)); // when List postAlarmResponses = RestAssuredMockMvc diff --git a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java index 9b2d3fe95..c1b826c8c 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java @@ -1,11 +1,11 @@ -package com.votogether.domain.alarm.entity.service; +package com.votogether.domain.alarm.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; import com.votogether.domain.alarm.dto.response.PostAlarmDetailResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; -import com.votogether.domain.alarm.service.AlarmQueryService; +import com.votogether.domain.alarm.repository.ReportActionAlarmRepository; import com.votogether.domain.member.entity.Member; import com.votogether.domain.post.dto.request.comment.CommentCreateRequest; import com.votogether.domain.post.entity.Post; @@ -33,6 +33,9 @@ class AlarmQueryServiceTest extends ServiceTest { @Autowired PostCommandService postCommandService; + @Autowired + ReportActionAlarmRepository reportActionAlarmRepository; + @Nested @DisplayName("알림 조회는 ") class GetPostAlarm { @@ -51,7 +54,7 @@ void whenCreateComment() { TestTransaction.end(); // when - List postAlarmResponses = alarmQueryService.getPostAlarm(0); + List postAlarmResponses = alarmQueryService.getPostAlarm(0, commentWriter); // then PostAlarmResponse postAlarmResponse = postAlarmResponses.get(0); @@ -78,7 +81,7 @@ void whenPostClosed() throws Exception { Thread.sleep(1000); // when - List postAlarmResponses = alarmQueryService.getPostAlarm(0); + List postAlarmResponses = alarmQueryService.getPostAlarm(0, member); // then PostAlarmResponse postAlarmResponse = postAlarmResponses.get(0); @@ -93,8 +96,11 @@ void whenPostClosed() throws Exception { @Test @DisplayName("어떠한 이벤트도 발생하지 않았다면 빈 리스트가 조회된다.") void getEmptyListWhenNoEventOccurs() { - // given, when - List postAlarmResponses = alarmQueryService.getPostAlarm(0); + // given + Member member = memberTestPersister.builder().save(); + + // when + List postAlarmResponses = alarmQueryService.getPostAlarm(0, member); // then assertThat(postAlarmResponses).hasSize(0); From ca06307aab7b9eca2d1e6d59d2e0634e47f5c6ab Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 13:44:19 +0900 Subject: [PATCH 2/8] =?UTF-8?q?refactor:=20(#743)=20conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AlarmCommandController.java | 44 --------- .../AlarmCommandControllerDocs.java | 23 ----- .../controller/AlarmQueryController.java | 23 ++++- .../controller/AlarmQueryControllerDocs.java | 18 ++++ .../alarm/service/AlarmQueryService.java | 31 ++++++- .../domain/alarm/service/AlarmService.java | 45 ---------- .../AlarmCommandControllerTest.java | 90 ------------------- .../controller/AlarmQueryControllerTest.java | 65 +++++++++++++- .../alarm/service/AlarmQueryServiceTest.java | 71 ++++++++++++++- .../alarm/service/AlarmServiceTest.java | 87 ------------------ 10 files changed, 202 insertions(+), 295 deletions(-) delete mode 100644 backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandController.java delete mode 100644 backend/src/main/java/com/votogether/domain/alarm/service/AlarmService.java delete mode 100644 backend/src/test/java/com/votogether/domain/alarm/controller/AlarmCommandControllerTest.java delete mode 100644 backend/src/test/java/com/votogether/domain/alarm/service/AlarmServiceTest.java diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandController.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandController.java deleted file mode 100644 index dbe841898..000000000 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandController.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.votogether.domain.alarm.controller; - -import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; -import com.votogether.domain.alarm.dto.ReportActionResponse; -import com.votogether.domain.alarm.service.AlarmService; -import com.votogether.domain.member.entity.Member; -import com.votogether.global.jwt.Auth; -import jakarta.validation.constraints.PositiveOrZero; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@Validated -@RequiredArgsConstructor -@RequestMapping("/alarms") -@RestController -public class AlarmCommandController implements AlarmCommandControllerDocs { - - private final AlarmService alarmService; - - @RequestMapping("/report") - public ResponseEntity> getReportActionAlarms( - @RequestParam @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, - @Auth final Member member - ) { - final List response = alarmService.getReportActionAlarms(member, page); - return ResponseEntity.ok(response); - } - - @RequestMapping("/report/{id}") - public ResponseEntity getReportActionAlarm( - @PathVariable("id") final Long reportActionAlarmId, - @Auth final Member member - ) { - final ReportActionResponse response = alarmService.getReportActionAlarm(reportActionAlarmId, member); - return ResponseEntity.ok(response); - } - -} diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java index 73b80eab5..60c3f0457 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java @@ -1,32 +1,9 @@ package com.votogether.domain.alarm.controller; -import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; -import com.votogether.domain.alarm.dto.ReportActionResponse; -import com.votogether.domain.member.entity.Member; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.constraints.PositiveOrZero; -import java.util.List; -import org.springframework.http.ResponseEntity; @Tag(name = "알림", description = "알림 API") public interface AlarmCommandControllerDocs { - @Operation(summary = "신고조치알림 조회", description = "신고조치알림목록을 조회한다.") - @ApiResponse(responseCode = "201", description = "조회 성공") - ResponseEntity> getReportActionAlarms( - @Parameter(description = "현재 페이지 위치", example = "0") - @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, - final Member member - ); - - @Operation(summary = "신고조치알림 상세 조회", description = "신고조치알림를 상세 조회한다.") - @ApiResponse(responseCode = "201", description = "조회 성공") - public ResponseEntity getReportActionAlarm( - @Parameter(description = "신고조치알림 ID", example = "1") final Long reportActionAlarmId, - final Member member - ); } diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java index e90f4f822..d33b4aa79 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryController.java @@ -1,5 +1,7 @@ package com.votogether.domain.alarm.controller; +import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; +import com.votogether.domain.alarm.dto.ReportActionResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; import com.votogether.domain.alarm.service.AlarmQueryService; import com.votogether.domain.member.entity.Member; @@ -10,6 +12,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -27,8 +30,26 @@ public ResponseEntity> getPostAlarm( @RequestParam @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, @Auth final Member loginMember ) { - final List postAlarmResponses = alarmQueryService.getPostAlarm(page, loginMember); + final List postAlarmResponses = alarmQueryService.getPostAlarm(loginMember, page); return ResponseEntity.ok(postAlarmResponses); } + @GetMapping("/report") + public ResponseEntity> getReportActionAlarms( + @RequestParam @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, + @Auth final Member loginMember + ) { + final List response = alarmQueryService.getReportActionAlarms(loginMember, page); + return ResponseEntity.ok(response); + } + + @GetMapping("/report/{id}") + public ResponseEntity getReportActionAlarm( + @PathVariable("id") final Long reportActionAlarmId, + @Auth final Member loginMember + ) { + final ReportActionResponse response = alarmQueryService.getReportActionAlarm(reportActionAlarmId, loginMember); + return ResponseEntity.ok(response); + } + } diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java index ebc83959b..0c8749e55 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java @@ -1,10 +1,13 @@ package com.votogether.domain.alarm.controller; +import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; +import com.votogether.domain.alarm.dto.ReportActionResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; import com.votogether.domain.member.entity.Member; import com.votogether.global.exception.ExceptionResponse; import com.votogether.global.jwt.Auth; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -34,4 +37,19 @@ ResponseEntity> getPostAlarm( @Auth final Member loginMember ); + @Operation(summary = "신고 조치 알림 조회", description = "신고 조치 알림 목록을 조회한다.") + @ApiResponse(responseCode = "201", description = "조회 성공") + ResponseEntity> getReportActionAlarms( + @Parameter(description = "현재 페이지 위치", example = "0") + @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, + final Member member + ); + + @Operation(summary = "신고 조치 알림 상세 조회", description = "신고조치알림를 상세 조회한다.") + @ApiResponse(responseCode = "201", description = "조회 성공") + ResponseEntity getReportActionAlarm( + @Parameter(description = "신고 조치 알림 ID", example = "1") final Long reportActionAlarmId, + final Member member + ); + } diff --git a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java index 988fcc841..767b809d6 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java +++ b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java @@ -1,14 +1,21 @@ package com.votogether.domain.alarm.service; +import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; +import com.votogether.domain.alarm.dto.ReportActionResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; import com.votogether.domain.alarm.entity.Alarm; +import com.votogether.domain.alarm.entity.ReportActionAlarm; import com.votogether.domain.alarm.entity.vo.AlarmType; +import com.votogether.domain.alarm.exception.ReportActionAlarmExceptionType; import com.votogether.domain.alarm.repository.AlarmRepository; +import com.votogether.domain.alarm.repository.ReportActionAlarmRepository; import com.votogether.domain.member.entity.Member; +import com.votogether.global.exception.NotFoundException; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,8 +28,9 @@ public class AlarmQueryService { private static final String NICKNAME_WHEN_POST_CLOSING = ""; private final AlarmRepository alarmRepository; + private final ReportActionAlarmRepository reportActionAlarmRepository; - public List getPostAlarm(final int page, final Member member) { + public List getPostAlarm(final Member member, final int page) { final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE); final Slice alarms = alarmRepository.findAllByMemberOrderByCreatedAtDesc(member, pageRequest); @@ -46,4 +54,25 @@ private String makeNicknameBy(final Alarm alarm) { return member.getNickname(); } + @Transactional(readOnly = true) + public List getReportActionAlarms(final Member member, final int page) { + final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE, + Sort.by(Sort.Direction.DESC, "createdAt")); + final List reportActionAlarms = reportActionAlarmRepository + .findByMember(member, pageRequest); + + return reportActionAlarms.stream() + .map(ReportActionAlarmResponse::from) + .toList(); + } + + @Transactional(readOnly = true) + public ReportActionResponse getReportActionAlarm(final Long reportActionAlarmId, final Member member) { + final ReportActionAlarm reportActionAlarm = reportActionAlarmRepository + .findByIdAndMember(reportActionAlarmId, member) + .orElseThrow(() -> new NotFoundException(ReportActionAlarmExceptionType.NOT_FOUND)); + + return ReportActionResponse.from(reportActionAlarm); + } + } diff --git a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmService.java b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmService.java deleted file mode 100644 index f178cbd33..000000000 --- a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmService.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.votogether.domain.alarm.service; - -import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; -import com.votogether.domain.alarm.dto.ReportActionResponse; -import com.votogether.domain.alarm.entity.ReportActionAlarm; -import com.votogether.domain.alarm.exception.ReportActionAlarmExceptionType; -import com.votogether.domain.alarm.repository.ReportActionAlarmRepository; -import com.votogether.domain.member.entity.Member; -import com.votogether.global.exception.NotFoundException; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@RequiredArgsConstructor -@Service -public class AlarmService { - - private static final int BASIC_PAGE_SIZE = 10; - private final ReportActionAlarmRepository reportActionAlarmRepository; - - @Transactional(readOnly = true) - public List getReportActionAlarms(final Member member, final int page) { - final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE, - Sort.by(Sort.Direction.DESC, "createdAt")); - final List reportActionAlarms = reportActionAlarmRepository - .findByMember(member, pageRequest); - - return reportActionAlarms.stream() - .map(ReportActionAlarmResponse::from) - .toList(); - } - - @Transactional(readOnly = true) - public ReportActionResponse getReportActionAlarm(final Long reportActionAlarmId, final Member member) { - final ReportActionAlarm reportActionAlarm = reportActionAlarmRepository - .findByIdAndMember(reportActionAlarmId, member) - .orElseThrow(() -> new NotFoundException(ReportActionAlarmExceptionType.NOT_FOUND)); - - return ReportActionResponse.from(reportActionAlarm); - } - -} diff --git a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmCommandControllerTest.java b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmCommandControllerTest.java deleted file mode 100644 index f9d8936c1..000000000 --- a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmCommandControllerTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.votogether.domain.alarm.controller; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.BDDMockito.given; - -import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; -import com.votogether.domain.alarm.dto.ReportActionResponse; -import com.votogether.domain.alarm.entity.ReportActionAlarm; -import com.votogether.domain.alarm.service.AlarmService; -import com.votogether.domain.member.entity.Member; -import com.votogether.domain.report.entity.vo.ReportType; -import com.votogether.test.ControllerTest; -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpStatus; - -@WebMvcTest(AlarmCommandControllerTest.class) -class AlarmCommandControllerTest extends ControllerTest { - - @MockBean - AlarmService alarmService; - - @BeforeEach - void setUp() { - RestAssuredMockMvc.standaloneSetup(new AlarmCommandController(alarmService)); - } - - @Test - @DisplayName("신고조치알림목록을 가져온다.") - void getReportAlarmActions() { - // given - ReportActionAlarm reportActionAlarm = ReportActionAlarm.builder() - .reportType(ReportType.POST) - .isChecked(false) - .reasons("광고성, 부적합성") - .target("1") - .build(); - ReportActionAlarmResponse response = ReportActionAlarmResponse.from(reportActionAlarm); - given(alarmService.getReportActionAlarms(any(Member.class), anyInt())) - .willReturn(List.of(response)); - - // when - List results = RestAssuredMockMvc - .when().get("/alarms/report?page=0") - .then().log().all() - .status(HttpStatus.OK) - .extract() - .as(new ParameterizedTypeReference>() { - }.getType()); - - // then - assertThat(results.get(0)).isEqualTo(response); - } - - @Test - @DisplayName("신고조치알림을 상세조회한다.") - void getReportAlarmAction() { - // given - ReportActionAlarm reportActionAlarm = ReportActionAlarm.builder() - .reportType(ReportType.POST) - .isChecked(false) - .target("1") - .reasons("광고성, 부적합성") - .build(); - ReportActionResponse response = ReportActionResponse.from(reportActionAlarm); - given(alarmService.getReportActionAlarm(anyLong(), any(Member.class))) - .willReturn(response); - - // when - ReportActionResponse result = RestAssuredMockMvc - .when().get("/alarms/report/{id}", 1) - .then().log().all() - .status(HttpStatus.OK) - .extract() - .as(ReportActionResponse.class); - - // then - assertThat(result).isEqualTo(response); - } - -} diff --git a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java index 212cec32e..54c7152fb 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java @@ -1,12 +1,20 @@ package com.votogether.domain.alarm.controller; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; +import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; +import com.votogether.domain.alarm.dto.ReportActionResponse; import com.votogether.domain.alarm.dto.response.PostAlarmDetailResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; +import com.votogether.domain.alarm.entity.ReportActionAlarm; import com.votogether.domain.alarm.service.AlarmQueryService; import com.votogether.domain.member.entity.Member; +import com.votogether.domain.report.entity.vo.ReportType; import com.votogether.test.ControllerTest; import com.votogether.test.fixtures.MemberFixtures; import io.restassured.common.mapper.TypeRef; @@ -18,7 +26,9 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; @WebMvcTest(AlarmQueryController.class) class AlarmQueryControllerTest extends ControllerTest { @@ -43,7 +53,7 @@ void getPostAlarm() throws Exception { PostAlarmResponse postAlarmResponse = new PostAlarmResponse(1L, postAlarmDetailResponse, LocalDateTime.now(), false); - given(alarmQueryService.getPostAlarm(page, member)).willReturn(List.of(postAlarmResponse)); + given(alarmQueryService.getPostAlarm(member, page)).willReturn(List.of(postAlarmResponse)); // when List postAlarmResponses = RestAssuredMockMvc @@ -67,4 +77,57 @@ void getPostAlarm() throws Exception { }); } + @Test + @DisplayName("신고조치알림목록을 가져온다.") + void getReportAlarmActions() { + // given + ReportActionAlarm reportActionAlarm = ReportActionAlarm.builder() + .reportType(ReportType.POST) + .isChecked(false) + .reasons("광고성, 부적합성") + .target("1") + .build(); + ReportActionAlarmResponse response = ReportActionAlarmResponse.from(reportActionAlarm); + given(alarmQueryService.getReportActionAlarms(any(Member.class), anyInt())) + .willReturn(List.of(response)); + + // when + List results = RestAssuredMockMvc + .when().get("/alarms/report?page=0") + .then().log().all() + .status(HttpStatus.OK) + .extract() + .as(new ParameterizedTypeReference>() { + }.getType()); + + // then + assertThat(results.get(0)).isEqualTo(response); + } + + @Test + @DisplayName("신고조치알림을 상세조회한다.") + void getReportAlarmAction() { + // given + ReportActionAlarm reportActionAlarm = ReportActionAlarm.builder() + .reportType(ReportType.POST) + .isChecked(false) + .target("1") + .reasons("광고성, 부적합성") + .build(); + ReportActionResponse response = ReportActionResponse.from(reportActionAlarm); + given(alarmQueryService.getReportActionAlarm(anyLong(), any(Member.class))) + .willReturn(response); + + // when + ReportActionResponse result = RestAssuredMockMvc + .when().get("/alarms/report/{id}", 1) + .then().log().all() + .status(HttpStatus.OK) + .extract() + .as(ReportActionResponse.class); + + // then + assertThat(result).isEqualTo(response); + } + } diff --git a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java index c1b826c8c..aece2fc93 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java @@ -3,16 +3,21 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; +import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; +import com.votogether.domain.alarm.dto.ReportActionResponse; import com.votogether.domain.alarm.dto.response.PostAlarmDetailResponse; import com.votogether.domain.alarm.dto.response.PostAlarmResponse; +import com.votogether.domain.alarm.entity.ReportActionAlarm; import com.votogether.domain.alarm.repository.ReportActionAlarmRepository; import com.votogether.domain.member.entity.Member; import com.votogether.domain.post.dto.request.comment.CommentCreateRequest; import com.votogether.domain.post.entity.Post; import com.votogether.domain.post.service.PostCommandService; import com.votogether.domain.post.service.PostCommentService; +import com.votogether.domain.report.entity.vo.ReportType; import com.votogether.test.ServiceTest; import java.util.List; +import java.util.Set; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -54,7 +59,7 @@ void whenCreateComment() { TestTransaction.end(); // when - List postAlarmResponses = alarmQueryService.getPostAlarm(0, commentWriter); + List postAlarmResponses = alarmQueryService.getPostAlarm(commentWriter, 0); // then PostAlarmResponse postAlarmResponse = postAlarmResponses.get(0); @@ -81,7 +86,7 @@ void whenPostClosed() throws Exception { Thread.sleep(1000); // when - List postAlarmResponses = alarmQueryService.getPostAlarm(0, member); + List postAlarmResponses = alarmQueryService.getPostAlarm(member, 0); // then PostAlarmResponse postAlarmResponse = postAlarmResponses.get(0); @@ -100,7 +105,7 @@ void getEmptyListWhenNoEventOccurs() { Member member = memberTestPersister.builder().save(); // when - List postAlarmResponses = alarmQueryService.getPostAlarm(0, member); + List postAlarmResponses = alarmQueryService.getPostAlarm(member, 0); // then assertThat(postAlarmResponses).hasSize(0); @@ -108,4 +113,64 @@ void getEmptyListWhenNoEventOccurs() { } + @Test + @DisplayName("신고 조치 알림 목록을 조회한다.") + void getReportActionAlarms() { + // given + Member member = memberTestPersister.builder().save(); + + ReportActionAlarm reportActionAlarmA = ReportActionAlarm.builder() + .reportType(ReportType.POST) + .member(member) + .isChecked(false) + .reasons("광고성, 부적합성") + .target("1") + .build(); + + reportActionAlarmRepository.save(reportActionAlarmA); + + // when + List reportActionAlarms = alarmQueryService.getReportActionAlarms(member, 0); + + // then + ReportActionAlarmResponse result = reportActionAlarms.get(0); + assertSoftly(softly -> { + softly.assertThat(reportActionAlarms.size()).isEqualTo(1); + softly.assertThat(result.alarmId()).isNotNull(); + softly.assertThat(result.isChecked()).isFalse(); + softly.assertThat(result.detail().reportActionId()).isNotNull(); + softly.assertThat(result.detail().content()).isEqualTo("1"); + softly.assertThat(result.detail().reasons()).containsAll(Set.of("광고성", "부적합성")); + softly.assertThat(result.detail().type()).isEqualTo(ReportType.POST); + }); + } + + @Test + @DisplayName("신고 조치 알림을 상세 조회한다.") + void getReportActionAlarm() { + // given + Member member = memberTestPersister.builder().save(); + + ReportActionAlarm reportActionAlarmA = ReportActionAlarm.builder() + .reportType(ReportType.POST) + .member(member) + .isChecked(false) + .reasons("광고성, 부적합성") + .target("1") + .build(); + + ReportActionAlarm savedReportActionAlarm = reportActionAlarmRepository.save(reportActionAlarmA); + + // when + ReportActionResponse response = alarmQueryService.getReportActionAlarm(savedReportActionAlarm.getId(), member); + + // then + assertSoftly(softly -> { + softly.assertThat(response.reportActionId()).isEqualTo(savedReportActionAlarm.getId()); + softly.assertThat(response.type()).isEqualTo(ReportType.POST); + softly.assertThat(response.content()).isEqualTo("1"); + softly.assertThat(response.reasons()).containsAll(Set.of("광고성", "부적합성")); + }); + } + } diff --git a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmServiceTest.java b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmServiceTest.java deleted file mode 100644 index 23d4e364e..000000000 --- a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmServiceTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.votogether.domain.alarm.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; - -import com.votogether.domain.alarm.dto.ReportActionAlarmResponse; -import com.votogether.domain.alarm.dto.ReportActionResponse; -import com.votogether.domain.alarm.entity.ReportActionAlarm; -import com.votogether.domain.alarm.repository.ReportActionAlarmRepository; -import com.votogether.domain.member.entity.Member; -import com.votogether.domain.report.entity.vo.ReportType; -import com.votogether.test.ServiceTest; -import java.util.List; -import java.util.Set; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; - -class AlarmServiceTest extends ServiceTest { - - @Autowired - AlarmService alarmService; - - @Autowired - ReportActionAlarmRepository reportActionAlarmRepository; - - @Test - @DisplayName("신고조치알림 목록을 조회한다.") - void getReportActionAlarms() { - // given - Member member = memberTestPersister.builder().save(); - - ReportActionAlarm reportActionAlarmA = ReportActionAlarm.builder() - .reportType(ReportType.POST) - .member(member) - .isChecked(false) - .reasons("광고성, 부적합성") - .target("1") - .build(); - - reportActionAlarmRepository.save(reportActionAlarmA); - - // when - List reportActionAlarms = alarmService.getReportActionAlarms(member, 0); - - // then - ReportActionAlarmResponse result = reportActionAlarms.get(0); - assertAll( - () -> assertThat(reportActionAlarms.size()).isEqualTo(1), - () -> assertThat(result.alarmId()).isNotNull(), - () -> assertThat(result.isChecked()).isFalse(), - () -> assertThat(result.detail().reportActionId()).isNotNull(), - () -> assertThat(result.detail().content()).isEqualTo("1"), - () -> assertThat(result.detail().reasons()).containsAll(Set.of("광고성", "부적합성")), - () -> assertThat(result.detail().type()).isEqualTo(ReportType.POST) - ); - } - - @Test - @DisplayName("신고조치알림을 상세 조회한다.") - void getReportActionAlarm() { - // given - Member member = memberTestPersister.builder().save(); - - ReportActionAlarm reportActionAlarmA = ReportActionAlarm.builder() - .reportType(ReportType.POST) - .member(member) - .isChecked(false) - .reasons("광고성, 부적합성") - .target("1") - .build(); - - ReportActionAlarm savedReportActionAlarm = reportActionAlarmRepository.save(reportActionAlarmA); - - // when - ReportActionResponse response = alarmService.getReportActionAlarm(savedReportActionAlarm.getId(), member); - - // then - assertAll( - () -> assertThat(response.reportActionId()).isEqualTo(savedReportActionAlarm.getId()), - () -> assertThat(response.type()).isEqualTo(ReportType.POST), - () -> assertThat(response.content()).isEqualTo("1"), - () -> assertThat(response.reasons()).containsAll(Set.of("광고성", "부적합성")) - ); - } - -} From 239fba59b4b9775380004eca07e61bed019d5566 Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 13:50:59 +0900 Subject: [PATCH 3/8] =?UTF-8?q?refactor:=20(#743)=20=EC=9E=90=EC=8B=A0?= =?UTF-8?q?=EC=9D=98=20=EA=B2=8C=EC=8B=9C=EA=B8=80=EC=97=90=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=EC=9D=84=20=EC=9E=91=EC=84=B1=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=95=8C=EB=A6=BC=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EB=B0=9C=ED=96=89=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/votogether/domain/post/service/PostCommentService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/main/java/com/votogether/domain/post/service/PostCommentService.java b/backend/src/main/java/com/votogether/domain/post/service/PostCommentService.java index 36eac7c16..d831a76f9 100644 --- a/backend/src/main/java/com/votogether/domain/post/service/PostCommentService.java +++ b/backend/src/main/java/com/votogether/domain/post/service/PostCommentService.java @@ -60,6 +60,9 @@ public void createComment( } private void publishAlarmEvent(final Member loginMember, final Post post) { + if (post.isWriter(loginMember)) { + return; + } final PostAlarmEvent postAlarmEvent = new PostAlarmEvent( loginMember, post.getId(), From f1335bb95104aefaa99d48d9026351fc6d7696ee Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 14:07:50 +0900 Subject: [PATCH 4/8] =?UTF-8?q?test:=20(#743)=20=EB=B9=84=EB=8F=99?= =?UTF-8?q?=EA=B8=B0=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=A7=80=EC=97=B0=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/alarm/service/AlarmQueryServiceTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java index aece2fc93..e54075ae0 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmQueryServiceTest.java @@ -47,7 +47,7 @@ class GetPostAlarm { @Test @DisplayName("댓글을 생성할 때 가능하다.") - void whenCreateComment() { + void whenCreateComment() throws Exception { // given Member commentWriter = memberTestPersister.builder().save(); Post post = postTestPersister.postBuilder().save(); @@ -58,6 +58,8 @@ void whenCreateComment() { TestTransaction.flagForCommit(); TestTransaction.end(); + Thread.sleep(1000); + // when List postAlarmResponses = alarmQueryService.getPostAlarm(commentWriter, 0); @@ -135,7 +137,7 @@ void getReportActionAlarms() { // then ReportActionAlarmResponse result = reportActionAlarms.get(0); assertSoftly(softly -> { - softly.assertThat(reportActionAlarms.size()).isEqualTo(1); + softly.assertThat(reportActionAlarms).hasSize(1); softly.assertThat(result.alarmId()).isNotNull(); softly.assertThat(result.isChecked()).isFalse(); softly.assertThat(result.detail().reportActionId()).isNotNull(); From bba0c8ef21029c51b233ac9bb4c7b680924b994c Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 14:13:35 +0900 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20(#743)=20truncate.sql=EC=97=90=20?= =?UTF-8?q?=EC=83=88=EB=A1=9C=20=EC=B6=94=EA=B0=80=EB=90=9C=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/resources/truncate.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/test/resources/truncate.sql b/backend/src/test/resources/truncate.sql index 5e4812509..2eeeeb585 100644 --- a/backend/src/test/resources/truncate.sql +++ b/backend/src/test/resources/truncate.sql @@ -11,5 +11,6 @@ TRUNCATE TABLE post; TRUNCATE TABLE member; TRUNCATE TABLE category; TRUNCATE TABLE alarm; +TRUNCATE TABLE report_action_alarm; SET FOREIGN_KEY_CHECKS = 1; From 5a0b9678634212e13e08bb85d0b5f48abfacea57 Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 14:38:18 +0900 Subject: [PATCH 6/8] =?UTF-8?q?refactor:=20(#743)=20docs=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/controller/AlarmCommandControllerDocs.java | 9 --------- .../alarm/controller/AlarmQueryControllerDocs.java | 6 +++--- 2 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java deleted file mode 100644 index 60c3f0457..000000000 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmCommandControllerDocs.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.votogether.domain.alarm.controller; - -import io.swagger.v3.oas.annotations.tags.Tag; - -@Tag(name = "알림", description = "알림 API") -public interface AlarmCommandControllerDocs { - - -} diff --git a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java index 0c8749e55..3e1e21af0 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java +++ b/backend/src/main/java/com/votogether/domain/alarm/controller/AlarmQueryControllerDocs.java @@ -38,15 +38,15 @@ ResponseEntity> getPostAlarm( ); @Operation(summary = "신고 조치 알림 조회", description = "신고 조치 알림 목록을 조회한다.") - @ApiResponse(responseCode = "201", description = "조회 성공") + @ApiResponse(responseCode = "200", description = "조회 성공") ResponseEntity> getReportActionAlarms( @Parameter(description = "현재 페이지 위치", example = "0") @PositiveOrZero(message = "페이지는 0이상 정수만 가능합니다.") final int page, final Member member ); - @Operation(summary = "신고 조치 알림 상세 조회", description = "신고조치알림를 상세 조회한다.") - @ApiResponse(responseCode = "201", description = "조회 성공") + @Operation(summary = "신고 조치 알림 상세 조회", description = "신고 조치 알림를 상세 조회한다.") + @ApiResponse(responseCode = "200", description = "조회 성공") ResponseEntity getReportActionAlarm( @Parameter(description = "신고 조치 알림 ID", example = "1") final Long reportActionAlarmId, final Member member From 112ef29eef31c6abb62913972248595bbfa61a58 Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 14:48:21 +0900 Subject: [PATCH 7/8] =?UTF-8?q?test:=20(#743)=20=EB=B9=84=EB=8F=99?= =?UTF-8?q?=EA=B8=B0=20=EA=B2=80=EC=A6=9D=20sleep=20=EC=8B=9C=EA=B0=84=201?= =?UTF-8?q?=EC=B4=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../votogether/domain/alarm/service/AlarmEventListenerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmEventListenerTest.java b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmEventListenerTest.java index 7d6582cf8..1f4a84ce7 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/service/AlarmEventListenerTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/service/AlarmEventListenerTest.java @@ -38,7 +38,7 @@ void handlePostAlarmEvent() throws Exception { TestTransaction.flagForCommit(); TestTransaction.end(); - Thread.sleep(1000); + Thread.sleep(2000); // then List alarms = alarmRepository.findAll(); From 85ee935f458319bd0d3a55e79de31a32a718710a Mon Sep 17 00:00:00 2001 From: jeomxon Date: Wed, 18 Oct 2023 15:05:17 +0900 Subject: [PATCH 8/8] =?UTF-8?q?refactor:=20(#743)=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20any()=EB=A5=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../votogether/domain/alarm/service/AlarmQueryService.java | 2 -- .../domain/alarm/controller/AlarmQueryControllerTest.java | 7 ++----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java index 767b809d6..1b96112a2 100644 --- a/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java +++ b/backend/src/main/java/com/votogether/domain/alarm/service/AlarmQueryService.java @@ -54,7 +54,6 @@ private String makeNicknameBy(final Alarm alarm) { return member.getNickname(); } - @Transactional(readOnly = true) public List getReportActionAlarms(final Member member, final int page) { final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE, Sort.by(Sort.Direction.DESC, "createdAt")); @@ -66,7 +65,6 @@ public List getReportActionAlarms(final Member member .toList(); } - @Transactional(readOnly = true) public ReportActionResponse getReportActionAlarm(final Long reportActionAlarmId, final Member member) { final ReportActionAlarm reportActionAlarm = reportActionAlarmRepository .findByIdAndMember(reportActionAlarmId, member) diff --git a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java index 54c7152fb..becdb7049 100644 --- a/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java +++ b/backend/src/test/java/com/votogether/domain/alarm/controller/AlarmQueryControllerTest.java @@ -16,7 +16,6 @@ import com.votogether.domain.member.entity.Member; import com.votogether.domain.report.entity.vo.ReportType; import com.votogether.test.ControllerTest; -import com.votogether.test.fixtures.MemberFixtures; import io.restassured.common.mapper.TypeRef; import io.restassured.module.mockmvc.RestAssuredMockMvc; import java.time.LocalDateTime; @@ -47,19 +46,17 @@ void getPostAlarm() throws Exception { // given mockingAuthArgumentResolver(); - int page = 0; - Member member = MemberFixtures.FEMALE_20.get(); PostAlarmDetailResponse postAlarmDetailResponse = new PostAlarmDetailResponse(1L, "title", "저문"); PostAlarmResponse postAlarmResponse = new PostAlarmResponse(1L, postAlarmDetailResponse, LocalDateTime.now(), false); - given(alarmQueryService.getPostAlarm(member, page)).willReturn(List.of(postAlarmResponse)); + given(alarmQueryService.getPostAlarm(any(Member.class), anyInt())).willReturn(List.of(postAlarmResponse)); // when List postAlarmResponses = RestAssuredMockMvc .given().log().all() .headers(HttpHeaders.AUTHORIZATION, BEARER_TOKEN) - .queryParam("page", page) + .queryParam("page", 0) .when().get("/alarms/content") .then().log().all() .extract()