From 765690eced20433104816b6ff36c124994117ab8 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Sun, 28 Dec 2025 21:59:37 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat/#51:=20aws=20sdk=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 6aa7bb7..e16016c 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,10 @@ dependencies { //Slack implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.slack.api:slack-api-client:1.43.0' + + //AWS + implementation "software.amazon.awssdk:eventbridge" + implementation platform('software.amazon.awssdk:bom:2.20.83') } tasks.named('test') { From 6553bac93b5242487acdbd353d4778bf7bc82b3b Mon Sep 17 00:00:00 2001 From: tkv00 Date: Sun, 28 Dec 2025 22:00:14 +0900 Subject: [PATCH 02/10] =?UTF-8?q?feat/#51:=20aws=20event=20publisher=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/config/BatchJobListener.java | 8 ++++- .../batch/infra/aws/EventBridgePublisher.java | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java diff --git a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java index 2adc94c..be1d36a 100644 --- a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java +++ b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import store.slackjudge.batch.common.CalculateSnapShotDate; +import store.slackjudge.batch.infra.aws.EventBridgePublisher; import store.slackjudge.batch.infra.slack.SlackNotificationService; import java.time.Duration; @@ -23,6 +24,7 @@ public class BatchJobListener { private final BatchLogger logger; private final SlackNotificationService notificationService; private final CalculateSnapShotDate calculateSnapShotDate; + private final EventBridgePublisher eventBridgePublisher; /*========================== * @@ -57,7 +59,7 @@ public void beforeJob(JobExecution jobExecution) { * @parm jobExecution : Job 실행 중에 발생 정보 저장 객체 * @return * @author kimdoyeon - * @version 1.0.0 + * @version 1.1.0 * @date 25. 12. 17. * ==========================**/ @@ -97,9 +99,13 @@ public void afterJob(JobExecution jobExecution) { //배치 실패 slack 알림 전송 notificationService.notifyBatchFailed(occurredTime, reason); + //배치 살패 시 AWS EventBridge 전송 + eventBridgePublisher.publishBatchSuccessCompleteEvent(String.valueOf(jobExecution.getJobInstance().getInstanceId()),"FAILED"); } else { //배치 성공 slack 알림 전송 notificationService.notifyBatchSuccess(durationMs, total, newUser, updated, failedUser,occurredTime); + //배치 성공 시 AWS EventBridge 전송 + eventBridgePublisher.publishBatchSuccessCompleteEvent(String.valueOf(jobExecution.getJobInstance().getInstanceId()),"SUCCESS"); } } } diff --git a/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java new file mode 100644 index 0000000..7ab424c --- /dev/null +++ b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java @@ -0,0 +1,30 @@ +package store.slackjudge.batch.infra.aws; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import software.amazon.awssdk.services.eventbridge.EventBridgeClient; +import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; +import software.amazon.awssdk.services.eventbridge.model.PutEventsRequest; +import software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry; + +@Service +@RequiredArgsConstructor +public class EventBridgePublisher { + private final EventBridgeClient bridgeClientBuilder = + EventBridgeClient.builder().build(); + + public void publishBatchSuccessCompleteEvent(String jobId,String status){ + PutEventsRequestEntry eventsRequestEntry=PutEventsRequestEntry.builder() + .source("com.slackJudge.batch") + .detailType("Batch Finished") + .detail("{\"jobId\":\""+jobId+"\",\"status\":\""+status+"\"}") + .build(); + + PutEventsRequest request=PutEventsRequest.builder() + .entries(eventsRequestEntry) + .build(); + + bridgeClientBuilder.putEvents(request); + } + +} From a4ada9a7718a98d5fad401425c107f25f70d7659 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 17:44:20 +0900 Subject: [PATCH 03/10] =?UTF-8?q?chore/#51:=20aws=20event=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/batch.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/resources/batch.yml b/src/main/resources/batch.yml index cebdcfd..0a7d059 100644 --- a/src/main/resources/batch.yml +++ b/src/main/resources/batch.yml @@ -4,4 +4,9 @@ spring: initialize-schema: always job: enabled: false - name: 'SlackJudge Batch Worker #1' \ No newline at end of file + name: 'SlackJudge Batch Worker #1' + +aws: + eventbridge: + source: com.slackJudge.batch + detail-type: Batch Finished \ No newline at end of file From 4ec1dc998bc7d4569d6f7b8fa2ea42587fc38e08 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 17:45:13 +0900 Subject: [PATCH 04/10] =?UTF-8?q?fix/#51:=20aws=20EventBridge=20Test=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slackjudge/batch/SlackJudgeBatchRunner.java | 2 ++ .../store/slackjudge/batch/config/BatchConfig.java | 2 ++ .../slackjudge/batch/config/BatchJobListener.java | 12 ++++++++---- .../slackjudge/batch/SlackjudgeApplicationTests.java | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/store/slackjudge/batch/SlackJudgeBatchRunner.java b/src/main/java/store/slackjudge/batch/SlackJudgeBatchRunner.java index 4c177ec..7294d88 100644 --- a/src/main/java/store/slackjudge/batch/SlackJudgeBatchRunner.java +++ b/src/main/java/store/slackjudge/batch/SlackJudgeBatchRunner.java @@ -7,6 +7,7 @@ import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import store.slackjudge.batch.common.CalculateSnapShotDate; @@ -16,6 +17,7 @@ @Slf4j @Component @RequiredArgsConstructor +@Profile("!test") public class SlackJudgeBatchRunner implements CommandLineRunner { private final JobLauncher jobLauncher; private final Job slackJudgeBatch; diff --git a/src/main/java/store/slackjudge/batch/config/BatchConfig.java b/src/main/java/store/slackjudge/batch/config/BatchConfig.java index ffdaba4..9ced0c6 100644 --- a/src/main/java/store/slackjudge/batch/config/BatchConfig.java +++ b/src/main/java/store/slackjudge/batch/config/BatchConfig.java @@ -8,11 +8,13 @@ import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.transaction.PlatformTransactionManager; import store.slackjudge.batch.tasklet.*; @Configuration @RequiredArgsConstructor +@Profile("!test") public class BatchConfig { private final LoadAllUsersTasklet loadAllUsersTasklet; diff --git a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java index be1d36a..b0f673c 100644 --- a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java +++ b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java @@ -6,6 +6,7 @@ import org.springframework.batch.core.annotation.BeforeJob; import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import store.slackjudge.batch.common.CalculateSnapShotDate; import store.slackjudge.batch.infra.aws.EventBridgePublisher; @@ -17,6 +18,7 @@ @Component @RequiredArgsConstructor +@Profile("!test") public class BatchJobListener { @Value("${spring.batch.name}") private String jobName; @@ -90,6 +92,7 @@ public void afterJob(JobExecution jobExecution) { ); LocalDateTime occurredTime=calculateSnapShotDate.now(); + String status=""; //배치 종료 slack 알림 추가 if (jobExecution.getStatus().isUnsuccessful()) { //fail 예외 객체 없으면 기본 값 => Batch failed 출력 @@ -99,13 +102,14 @@ public void afterJob(JobExecution jobExecution) { //배치 실패 slack 알림 전송 notificationService.notifyBatchFailed(occurredTime, reason); - //배치 살패 시 AWS EventBridge 전송 - eventBridgePublisher.publishBatchSuccessCompleteEvent(String.valueOf(jobExecution.getJobInstance().getInstanceId()),"FAILED"); + status="FAILED"; } else { //배치 성공 slack 알림 전송 notificationService.notifyBatchSuccess(durationMs, total, newUser, updated, failedUser,occurredTime); - //배치 성공 시 AWS EventBridge 전송 - eventBridgePublisher.publishBatchSuccessCompleteEvent(String.valueOf(jobExecution.getJobInstance().getInstanceId()),"SUCCESS"); + status="SUCCESS"; } + + //배치 종료 시 AWS EventBridge 전송 + eventBridgePublisher.publishBatchSuccessCompleteEvent(String.valueOf(jobExecution.getJobInstance().getInstanceId()),status); } } diff --git a/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java b/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java index 80e7581..6058d23 100644 --- a/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java +++ b/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java @@ -3,6 +3,8 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.bean.override.mockito.MockitoBean; +import store.slackjudge.batch.infra.aws.EventBridgePublisher; @SpringBootTest @ActiveProfiles("test") From 91764943977651803633e8243a7569eaff64ed5f Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 17:46:57 +0900 Subject: [PATCH 05/10] =?UTF-8?q?fix/#51:=20=EC=9D=91=EB=8B=B5=20json=20dt?= =?UTF-8?q?o=20=EC=A7=81=EB=A0=AC=ED=99=94=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/config/EventBridgeConfig.java | 15 +++++++ .../batch/infra/aws/BatchEventDetail.java | 9 ++++ .../batch/infra/aws/EventBridgePublisher.java | 41 +++++++++++++------ 3 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java create mode 100644 src/main/java/store/slackjudge/batch/infra/aws/BatchEventDetail.java diff --git a/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java b/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java new file mode 100644 index 0000000..167b931 --- /dev/null +++ b/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java @@ -0,0 +1,15 @@ +package store.slackjudge.batch.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import software.amazon.awssdk.services.eventbridge.EventBridgeClient; + +@Configuration +@Profile("!test") +public class EventBridgeConfig { + @Bean + public EventBridgeClient eventBridgeClient(){ + return EventBridgeClient.builder().build(); + } +} diff --git a/src/main/java/store/slackjudge/batch/infra/aws/BatchEventDetail.java b/src/main/java/store/slackjudge/batch/infra/aws/BatchEventDetail.java new file mode 100644 index 0000000..b835858 --- /dev/null +++ b/src/main/java/store/slackjudge/batch/infra/aws/BatchEventDetail.java @@ -0,0 +1,9 @@ +package store.slackjudge.batch.infra.aws; + +import java.io.Serializable; + +public record BatchEventDetail( + String jobId, + String status +) implements Serializable { +} diff --git a/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java index 7ab424c..0420823 100644 --- a/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java +++ b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java @@ -1,6 +1,10 @@ package store.slackjudge.batch.infra.aws; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.eventbridge.EventBridgeClient; import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; @@ -9,22 +13,35 @@ @Service @RequiredArgsConstructor +@Profile("!test") public class EventBridgePublisher { - private final EventBridgeClient bridgeClientBuilder = - EventBridgeClient.builder().build(); + private final EventBridgeClient bridgeClientBuilder; + private final ObjectMapper mapper; - public void publishBatchSuccessCompleteEvent(String jobId,String status){ - PutEventsRequestEntry eventsRequestEntry=PutEventsRequestEntry.builder() - .source("com.slackJudge.batch") - .detailType("Batch Finished") - .detail("{\"jobId\":\""+jobId+"\",\"status\":\""+status+"\"}") - .build(); + @Value("${aws.eventbridge.source}") + private String source; - PutEventsRequest request=PutEventsRequest.builder() - .entries(eventsRequestEntry) - .build(); + @Value("${aws.eventbridge.detail-type}") + private String detailType; + + public void publishBatchSuccessCompleteEvent(String jobId, String status) { + try { + String detail = mapper.writeValueAsString(new BatchEventDetail(jobId, status)); + PutEventsRequestEntry eventsRequestEntry = PutEventsRequestEntry.builder() + .source(source) + .detailType(detailType) + .detail(detail) + .build(); + + PutEventsRequest request = PutEventsRequest.builder() + .entries(eventsRequestEntry) + .build(); + + bridgeClientBuilder.putEvents(request); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } - bridgeClientBuilder.putEvents(request); } } From 83b47821bd052150ed4b00f3633ba95d2250b6fd Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 21:50:05 +0900 Subject: [PATCH 06/10] =?UTF-8?q?chore/#51:=20mongodb=20test=20container?= =?UTF-8?q?=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index e16016c..7edd1d2 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,8 @@ dependencies { testImplementation "org.testcontainers:junit-jupiter" // JUnit 5 연동 testImplementation 'org.testcontainers:jdbc' testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:4.11.0' + testImplementation "org.testcontainers:mongodb" + //Slack implementation 'org.springframework.boot:spring-boot-starter-web' From cacd8ca0a2b43b247907031f240b33230d410f1f Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 21:50:45 +0900 Subject: [PATCH 07/10] =?UTF-8?q?fix/#51:=20test=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=98=88=EC=99=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/store/slackjudge/batch/config/BatchConfig.java | 1 - .../java/store/slackjudge/batch/config/BatchJobListener.java | 1 - .../java/store/slackjudge/batch/config/EventBridgeConfig.java | 1 - .../store/slackjudge/batch/infra/aws/EventBridgePublisher.java | 1 - 4 files changed, 4 deletions(-) diff --git a/src/main/java/store/slackjudge/batch/config/BatchConfig.java b/src/main/java/store/slackjudge/batch/config/BatchConfig.java index 9ced0c6..6306003 100644 --- a/src/main/java/store/slackjudge/batch/config/BatchConfig.java +++ b/src/main/java/store/slackjudge/batch/config/BatchConfig.java @@ -14,7 +14,6 @@ @Configuration @RequiredArgsConstructor -@Profile("!test") public class BatchConfig { private final LoadAllUsersTasklet loadAllUsersTasklet; diff --git a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java index b0f673c..c21d63a 100644 --- a/src/main/java/store/slackjudge/batch/config/BatchJobListener.java +++ b/src/main/java/store/slackjudge/batch/config/BatchJobListener.java @@ -18,7 +18,6 @@ @Component @RequiredArgsConstructor -@Profile("!test") public class BatchJobListener { @Value("${spring.batch.name}") private String jobName; diff --git a/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java b/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java index 167b931..00e6e6e 100644 --- a/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java +++ b/src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java @@ -6,7 +6,6 @@ import software.amazon.awssdk.services.eventbridge.EventBridgeClient; @Configuration -@Profile("!test") public class EventBridgeConfig { @Bean public EventBridgeClient eventBridgeClient(){ diff --git a/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java index 0420823..265d278 100644 --- a/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java +++ b/src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java @@ -13,7 +13,6 @@ @Service @RequiredArgsConstructor -@Profile("!test") public class EventBridgePublisher { private final EventBridgeClient bridgeClientBuilder; private final ObjectMapper mapper; From 538e208532ab8707badc2b488c310e99f5ec86da Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 21:51:08 +0900 Subject: [PATCH 08/10] =?UTF-8?q?test/#51:=20mongo=20test=20container=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slackjudge/batch/MongoContainer.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/store/slackjudge/batch/MongoContainer.java diff --git a/src/test/java/store/slackjudge/batch/MongoContainer.java b/src/test/java/store/slackjudge/batch/MongoContainer.java new file mode 100644 index 0000000..5b829c8 --- /dev/null +++ b/src/test/java/store/slackjudge/batch/MongoContainer.java @@ -0,0 +1,24 @@ +package store.slackjudge.batch; + +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +@ActiveProfiles("test") +public class MongoContainer { + @Container + static final MongoDBContainer mongo=new MongoDBContainer("mongo:6.0") + .withReuse(true); + + @DynamicPropertySource + static void mongoProperties(DynamicPropertyRegistry registry){ + registry.add( + "spring.data.mongodb.uri", + mongo::getReplicaSetUrl + ); + } +} From 3a3de8cf4ec78680ce872a3a653242cc87ff23ac Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 22:03:54 +0900 Subject: [PATCH 09/10] =?UTF-8?q?remove/#51:=20applicationTest=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradlew | 0 .../batch/SlackjudgeApplicationTests.java | 17 ----------------- src/test/resources/application-test.yml | 5 +++++ 3 files changed, 5 insertions(+), 17 deletions(-) mode change 100644 => 100755 gradlew delete mode 100644 src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java b/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java deleted file mode 100644 index 6058d23..0000000 --- a/src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package store.slackjudge.batch; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -import store.slackjudge.batch.infra.aws.EventBridgePublisher; - -@SpringBootTest -@ActiveProfiles("test") -class SlackjudgeApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index df73f85..68030b9 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -50,3 +50,8 @@ slack: logging: level: root: WARN + +aws: + eventbridge: + enabled: false + region: ap-northeast-2 From a63d92b1e439b11c2a782d837d3fa3c50ab80864 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 29 Dec 2025 22:14:23 +0900 Subject: [PATCH 10/10] =?UTF-8?q?test/#51:=20UserSolvedSnapShotRepositoryT?= =?UTF-8?q?est=20MongoContainer=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserSolvedSnapShotRepositoryTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/store/slackjudge/batch/infra/mongo/repository/UserSolvedSnapShotRepositoryTest.java b/src/test/java/store/slackjudge/batch/infra/mongo/repository/UserSolvedSnapShotRepositoryTest.java index 9aaf110..ec5c27d 100644 --- a/src/test/java/store/slackjudge/batch/infra/mongo/repository/UserSolvedSnapShotRepositoryTest.java +++ b/src/test/java/store/slackjudge/batch/infra/mongo/repository/UserSolvedSnapShotRepositoryTest.java @@ -6,12 +6,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; +import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.testcontainers.containers.MongoDBContainer; +import store.slackjudge.batch.MongoContainer; import store.slackjudge.batch.SlackjudgeApplication; import store.slackjudge.batch.infra.mongo.document.SnapShotId; import store.slackjudge.batch.infra.mongo.document.UserSolvedSnapShotDocument; @@ -26,10 +30,9 @@ @ContextConfiguration(classes = SlackjudgeApplication.class) @DataMongoTest -@ExtendWith(SpringExtension.class) -@DirtiesContext +@Import(MongoAutoConfiguration.class) @ActiveProfiles("test") -class UserSolvedSnapShotRepositoryTest { +class UserSolvedSnapShotRepositoryTest extends MongoContainer { @Autowired private UserSolvedSnapShotRepository repository;