Skip to content

Commit

Permalink
[test] #44 WebClient 테스트 (#44)
Browse files Browse the repository at this point in the history
* refactor: 필드 주입 대신 생성자 주입으로 변경

* refactor: 개행 및 EOL 추가

* refactor: 서류, 최종 메일 분리 및 비동기 처리

* refactor: 빌더 생성자로 변경

* test: displayName 추가

* fix: 스레드 작업 대기 시간 연장

* feat: 메일 예외 추가

* feat: 메일 병렬처리 추가

* fix: 대기시간 연장

* refactor: 메일 예약, 메일 전송 로직 분리

* fix: 메일 전송 테스트 비활성화

* fix: setter 추가

* feat: 서류 합격 메일 전송

* fix: 템플릿 정구 수

* feat: 메일 전송 비동기, 40개 배치 전송

* feat: 메일 타임아웃 설정

* fix: 비동기 스레드풀 max 변경

* fix: 메일 패키지 변경

* fix: Mail record에서 class로 변경

* fix: batch size 변경

* fix: 메일 수신자 타입 변경

* chore: OkHttp 의존성 추가

* test: webClient 호출 테스트
  • Loading branch information
ay-eonii authored Nov 30, 2024
1 parent 6c88e75 commit 020fbd9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 29 deletions.
60 changes: 31 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.9'
id 'io.spring.dependency-management' version '1.1.2'
id 'java'
id 'org.springframework.boot' version '3.0.9'
id 'io.spring.dependency-management' version '1.1.2'
}

group = 'land'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.1'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.1'

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
implementation 'org.hibernate:hibernate-validator:6.2.0.Final'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
implementation 'org.hibernate:hibernate-validator:6.2.0.Final'

implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'

implementation 'com.google.api-client:google-api-client:1.32.1'
implementation 'com.google.api-client:google-api-client:1.32.1'

testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package land.leets.domain.interview.usecase;

import static org.assertj.core.api.Assertions.*;

import java.io.IOException;
import java.util.UUID;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import land.leets.domain.interview.type.HasInterview;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;

@SpringBootTest
class CreateInterviewImplTest {

MockWebServer server = new MockWebServer();

@Autowired
CreateInterview createInterview;

@Test
void execute_mock() throws InterruptedException, IOException {
server.start(8080);
server.enqueue(new MockResponse().setResponseCode(200));

createInterview.execute(UUID.randomUUID(), HasInterview.CHECK);

RecordedRequest request = server.takeRequest();
assertThat(request.getPath()).isEqualTo("/interview");

server.shutdown();
}
}

0 comments on commit 020fbd9

Please sign in to comment.