Skip to content

Commit

Permalink
chore: 현재 필요하지 않는 테스트 메서드 주석 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim0914 committed Jan 25, 2024
1 parent 0830d12 commit c899096
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.official.pium.admin.service;

import com.official.pium.petPlant.domain.PetPlant;
import com.official.pium.petPlant.event.notification.NotificationEvent;
import com.official.pium.petPlant.repository.PetPlantRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
Expand Down Expand Up @@ -33,8 +30,8 @@ public class TestService {
// log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
// }

public void sendWaterNotificationAsyncRampTest() {
List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
// public void sendWaterNotificationAsyncRampTest() {
// List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
// List<NotificationEvent> events = petPlants.stream()
// .map(plant -> NotificationEvent.builder()
// .title(plant.getNickname())
Expand All @@ -43,39 +40,39 @@ public void sendWaterNotificationAsyncRampTest() {
// .build()
// ).toList();

for (int i = 0; i < 100; i++) {
PetPlant petPlant = petPlants.get(i);
NotificationEvent event = NotificationEvent.builder()
.title(petPlant.getNickname())
.body("물줘")
.deviceToken(petPlant.getMember().getDeviceToken())
.build();
publisher.publishEvent(event);
}
// for (int i = 0; i < 100; i++) {
// PetPlant petPlant = petPlants.get(i);
// NotificationEvent event = NotificationEvent.builder()
// .title(petPlant.getNickname())
// .body("물줘")
// .deviceToken(petPlant.getMember().getDeviceToken())
// .build();
// publisher.publishEvent(event);
// }

// log.info("비동기 테스트 램프업 시작");
// for (int i = 0; i < 100; i++) {
// NotificationEvent notificationEvent = events.get(i);
// publisher.publishEvent(notificationEvent);
// }
}

public void sendWaterNotificationAsyncTest() {
List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
List<NotificationEvent> events = petPlants.stream()
.map(plant -> NotificationEvent.builder()
.title(plant.getNickname())
.body("(테스트 중) 물을 줄 시간이에요!")
.deviceToken(plant.getMember().getDeviceToken())
.build()
).toList();
// }

int i = 1;
log.info("비동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
for (NotificationEvent event : events) {
log.info(i++ + "번째 알림 이벤트");
publisher.publishEvent(event);
}
log.info("비동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
}
// public void sendWaterNotificationAsyncTest() {
// List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
// List<NotificationEvent> events = petPlants.stream()
// .map(plant -> NotificationEvent.builder()
// .title(plant.getNickname())
// .body("(테스트 중) 물을 줄 시간이에요!")
// .deviceToken(plant.getMember().getDeviceToken())
// .build()
// ).toList();
//
// int i = 1;
// log.info("비동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
// for (NotificationEvent event : events) {
// log.info(i++ + "번째 알림 이벤트");
// publisher.publishEvent(event);
// }
// log.info("비동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.official.pium.admin.service.TestService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -14,15 +12,15 @@ public class TestController {

private final TestService testService;

@GetMapping("/notifications/ramp")
public ResponseEntity<String> notificationRampTest() {
testService.sendWaterNotificationAsyncRampTest();
return ResponseEntity.ok("비동기 알림 기능 테스트 램프업 성공");
}

@GetMapping("/notifications/async")
public ResponseEntity<String> notificationAsyncTest() {
testService.sendWaterNotificationAsyncTest();
return ResponseEntity.ok("비동기 알림 기능 테스트 성공");
}
// @GetMapping("/notifications/ramp")
// public ResponseEntity<String> notificationRampTest() {
// testService.sendWaterNotificationAsyncRampTest();
// return ResponseEntity.ok("비동기 알림 기능 테스트 램프업 성공");
// }
//
// @GetMapping("/notifications/async")
// public ResponseEntity<String> notificationAsyncTest() {
// testService.sendWaterNotificationAsyncTest();
// return ResponseEntity.ok("비동기 알림 기능 테스트 성공");
// }
}

0 comments on commit c899096

Please sign in to comment.