Compare commits
6 Commits
feature/Mo
...
feature/ve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a14020dfb5 | ||
|
|
975e03b7bd | ||
|
|
657c9e7f7d | ||
|
|
c5b779fda7 | ||
|
|
b7057cfc73 | ||
|
|
42a00d20d0 |
12
server/Dockerfile
Normal file
12
server/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM openjdk:11-jre-slim
|
||||
|
||||
ENV APP_HOME=/usr/app/
|
||||
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
COPY build/libs/server-0.0.1-SNAPSHOT.jar application.jar
|
||||
|
||||
EXPOSE 8443
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["java", "-jar", "application.jar"]
|
||||
@@ -1,7 +1,13 @@
|
||||
import Dependencies.AnnotationProcessorLib
|
||||
import Dependencies.DependencyManagementLib
|
||||
import Dependencies.ModuleLib
|
||||
import Dependencies.RuntimeOnlyLib
|
||||
import Dependencies.TestLib
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("org.springframework.boot") version "2.6.7"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
id("org.springframework.boot") version Versions.SPRING_BOOT_STARTER
|
||||
id("io.spring.dependency-management") version Versions.SPRING_DEPENDENCY_MANAGEMENT
|
||||
}
|
||||
|
||||
group = "com.ticketing"
|
||||
@@ -23,48 +29,50 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
extra["springCloudVersion"] = "2021.0.3"
|
||||
extra["springCloudVersion"] = Versions.SPRING_CLOUD
|
||||
|
||||
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-validation")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||
implementation("org.projectlombok:lombok:1.18.24")
|
||||
implementation("io.springfox:springfox-boot-starter:3.0.0")
|
||||
implementation("io.springfox:springfox-swagger-ui:3.0.0")
|
||||
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4")
|
||||
implementation("com.lmax:disruptor:3.4.4")
|
||||
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
|
||||
implementation("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-redis")
|
||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||
implementation ("org.springframework.cloud:spring-cloud-starter-config")
|
||||
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_DATA_JPA)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_SECURITY)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_VALIDATION)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_WEB)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_ACTUATOR)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_LOG4J2)
|
||||
implementation(Dependencies.LOMBOK)
|
||||
implementation(Dependencies.SPRING_FOX_STARTER)
|
||||
implementation(Dependencies.SWAGGER)
|
||||
implementation(Dependencies.JASYPT_SPRING_BOOT_STARTER)
|
||||
implementation(Dependencies.DISRUPTOR)
|
||||
implementation(Dependencies.JJWT)
|
||||
implementation(Dependencies.JSON_SIMPLE)
|
||||
implementation(Dependencies.SPRING_BOOT_STARTER_REDIS)
|
||||
implementation(Dependencies.JSR350)
|
||||
implementation(Dependencies.SPRING_CLOUD_STARTER)
|
||||
implementation(Dependencies.SPRING_CLOUD_FEIGN)
|
||||
implementation(Dependencies.MICROMETER_CORE)
|
||||
implementation(Dependencies.MICROMETER_REGISTRY_PROMETHEUS)
|
||||
|
||||
modules {
|
||||
module("org.springframework.boot:spring-boot-starter-logging") {
|
||||
replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
|
||||
module(ModuleLib.SPRING_BOOT_STARTER_LOGGING) {
|
||||
replacedBy(ModuleLib.SPRING_BOOT_STARTER_LOG4J2, "Use Log4j2 instead of Logback")
|
||||
}
|
||||
}
|
||||
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
runtimeOnly("mysql:mysql-connector-java")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
compileOnly(Dependencies.LOMBOK)
|
||||
runtimeOnly(RuntimeOnlyLib.MYSQL)
|
||||
runtimeOnly(RuntimeOnlyLib.JJWT_IMPL)
|
||||
runtimeOnly(RuntimeOnlyLib.JJWT_JACKSON)
|
||||
annotationProcessor(Dependencies.LOMBOK)
|
||||
annotationProcessor(AnnotationProcessorLib.SPRING_BOOT_PROCESSOR)
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
testImplementation(TestLib.JUPITER)
|
||||
testImplementation(TestLib.SPRING_BOOT_STARTER)
|
||||
testImplementation(TestLib.SPRING_SECURITY)
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
|
||||
mavenBom(DependencyManagementLib.SPRING_CLOUD)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
server/buildSrc/build.gradle.kts
Normal file
8
server/buildSrc/build.gradle.kts
Normal file
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
}
|
||||
56
server/buildSrc/src/main/kotlin/Dependencies.kt
Normal file
56
server/buildSrc/src/main/kotlin/Dependencies.kt
Normal file
@@ -0,0 +1,56 @@
|
||||
object Dependencies {
|
||||
|
||||
const val SPRING_BOOT_STARTER_DATA_JPA = "org.springframework.boot:spring-boot-starter-data-jpa:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_SECURITY = "org.springframework.boot:spring-boot-starter-security:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_VALIDATION = "org.springframework.boot:spring-boot-starter-validation:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_WEB = "org.springframework.boot:spring-boot-starter-web:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_ACTUATOR = "org.springframework.boot:spring-boot-starter-actuator:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_LOG4J2 = "org.springframework.boot:spring-boot-starter-log4j2:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_BOOT_STARTER_REDIS = "org.springframework.boot:spring-boot-starter-data-redis:${Versions.SPRING_BOOT_STARTER}"
|
||||
|
||||
const val SPRING_CLOUD_STARTER = "org.springframework.cloud:spring-cloud-starter-config:${Versions.SPRING_CLOUD_STARTER}"
|
||||
const val SPRING_CLOUD_FEIGN = "org.springframework.cloud:spring-cloud-starter-openfeign:${Versions.SPRING_CLOUD_STARTER}"
|
||||
|
||||
const val LOMBOK = "org.projectlombok:lombok:${Versions.LOMBOK}"
|
||||
|
||||
const val SPRING_FOX_STARTER = "io.springfox:springfox-boot-starter:${Versions.SPRING_FOX}"
|
||||
const val SWAGGER = "io.springfox:springfox-swagger-ui:${Versions.SPRING_FOX}"
|
||||
|
||||
const val JASYPT_SPRING_BOOT_STARTER = "com.github.ulisesbocchio:jasypt-spring-boot-starter:${Versions.JASYPT}"
|
||||
|
||||
const val DISRUPTOR = "com.lmax:disruptor:${Versions.DISRUPTOR}"
|
||||
|
||||
const val JJWT = "io.jsonwebtoken:jjwt-api:${Versions.JJWT}"
|
||||
const val JSON_SIMPLE = "com.googlecode.json-simple:json-simple:${Versions.JSON_SIMPLE}"
|
||||
|
||||
const val MICROMETER_CORE = "io.micrometer:micrometer-core:${Versions.MICROMETER}"
|
||||
const val MICROMETER_REGISTRY_PROMETHEUS = "io.micrometer:micrometer-registry-prometheus:${Versions.MICROMETER}"
|
||||
|
||||
const val JSR350 = "com.google.code.findbugs:jsr305:${Versions.JSR350}"
|
||||
|
||||
object ModuleLib {
|
||||
const val SPRING_BOOT_STARTER_LOGGING = "org.springframework.boot:spring-boot-starter-logging"
|
||||
const val SPRING_BOOT_STARTER_LOG4J2 = "org.springframework.boot:spring-boot-starter-log4j2"
|
||||
}
|
||||
|
||||
object RuntimeOnlyLib {
|
||||
const val MYSQL = "mysql:mysql-connector-java:${Versions.MYSQL_CONNECTOR_JAVA}"
|
||||
const val JJWT_IMPL = "io.jsonwebtoken:jjwt-impl:${Versions.JJWT}"
|
||||
const val JJWT_JACKSON = "io.jsonwebtoken:jjwt-jackson:${Versions.JJWT}"
|
||||
}
|
||||
|
||||
object AnnotationProcessorLib {
|
||||
const val SPRING_BOOT_PROCESSOR = "org.springframework.boot:spring-boot-configuration-processor:${Versions.SPRING_BOOT_STARTER}"
|
||||
}
|
||||
|
||||
object TestLib {
|
||||
const val JUPITER = "org.junit.jupiter:junit-jupiter-api:${Versions.JUPITER}"
|
||||
const val SPRING_BOOT_STARTER = "org.springframework.boot:spring-boot-starter-test:${Versions.SPRING_BOOT_STARTER}"
|
||||
const val SPRING_SECURITY = "org.springframework.security:spring-security-test:${Versions.SECURITY}"
|
||||
}
|
||||
|
||||
object DependencyManagementLib {
|
||||
const val SPRING_CLOUD = "org.springframework.cloud:spring-cloud-dependencies:${Versions.SPRING_CLOUD}"
|
||||
}
|
||||
|
||||
}
|
||||
23
server/buildSrc/src/main/kotlin/Versions.kt
Normal file
23
server/buildSrc/src/main/kotlin/Versions.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
object Versions {
|
||||
|
||||
const val SPRING_BOOT_STARTER = "2.6.7"
|
||||
const val SPRING_DEPENDENCY_MANAGEMENT = "1.0.11.RELEASE"
|
||||
|
||||
const val SPRING_CLOUD_STARTER = "3.1.3"
|
||||
const val SPRING_CLOUD = "2021.0.3"
|
||||
|
||||
const val MYSQL_CONNECTOR_JAVA = "8.0.28"
|
||||
|
||||
const val LOMBOK = "1.18.24"
|
||||
const val SPRING_FOX = "3.0.0"
|
||||
const val JASYPT = "3.0.4"
|
||||
const val DISRUPTOR = "3.4.4"
|
||||
const val JJWT = "0.11.5"
|
||||
const val JSON_SIMPLE = "1.1.1"
|
||||
const val MICROMETER = "1.8.5"
|
||||
const val JSR350 = "3.0.2"
|
||||
|
||||
const val JUPITER = "5.8.1"
|
||||
const val SECURITY = "5.6.3"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ticketing.server.movie.aop;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class TicketLockAspectTest {
|
||||
|
||||
@Autowired
|
||||
private TicketLockAspect ticketLockAspect;
|
||||
|
||||
@Test
|
||||
@DisplayName("티켓 lock 동시성 체크")
|
||||
@SuppressWarnings({"java:S5960"})
|
||||
void ticketMultiThread() throws InterruptedException {
|
||||
// given
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
|
||||
List<String> lockIds = List.of("TicketLock:1", "TicketLock:2", "TicketLock:3");
|
||||
AtomicBoolean result1 = new AtomicBoolean(Boolean.TRUE);
|
||||
AtomicBoolean result2 = new AtomicBoolean(Boolean.TRUE);
|
||||
|
||||
// when
|
||||
executorService.execute(() -> {
|
||||
result1.set(ticketLockAspect.isEveryTicketIdLock(lockIds));
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
executorService.execute(() -> {
|
||||
result2.set(ticketLockAspect.isEveryTicketIdLock(List.of("TicketLock:1")));
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
latch.await();
|
||||
|
||||
// then
|
||||
Long unlockCount = ticketLockAspect.ticketIdsUnlock(lockIds);
|
||||
|
||||
assertAll(
|
||||
() -> assertThat(result1).isNotEqualTo(result2),
|
||||
() -> assertThat(unlockCount > 1).isTrue()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import static org.springframework.http.HttpStatus.CONFLICT;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
|
||||
import com.ticketing.server.global.redis.PaymentCache;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -24,8 +23,11 @@ public enum ErrorCode {
|
||||
BAD_REQUEST_PAYMENT_COMPLETE(BAD_REQUEST, "처리할 결제 정보가 존재하지 않습니다."),
|
||||
BAD_REQUEST_PAYMENT_READY(BAD_REQUEST, "이미 진행 중인 결제가 존재합니다."),
|
||||
BAD_REQUEST_PAYMENT_CANCEL(BAD_REQUEST, "취소할 티켓이 존재하지 않습니다."),
|
||||
BAD_REQUEST_TICKET_RESERVATION(BAD_REQUEST, "이미 다른 고객이 예약 진행 중인 좌석이 존재합니다."),
|
||||
BAD_REQUEST_TICKET_SOLD(BAD_REQUEST, "이미 환불 진행 중 입니다."),
|
||||
NOT_REFUNDABLE_TIME(BAD_REQUEST, "환불이 가능한 시간이 지났습니다."),
|
||||
NOT_REFUNDABLE_SEAT(BAD_REQUEST, "환불할 수 있는 좌석이 아닙니다."),
|
||||
EMPTY_TICKET_ID(BAD_REQUEST, "티켓 정보가 존재하지 않습니다."),
|
||||
|
||||
/* 403 FORBIDDEN : 접근 권한 제한 */
|
||||
VALID_USER_ID(FORBIDDEN, "해당 정보에 접근 권한이 존재하지 않습니다."),
|
||||
@@ -48,7 +50,7 @@ public enum ErrorCode {
|
||||
DELETED_MOVIE(CONFLICT, "이미 삭제된 영화 입니다.");
|
||||
|
||||
private final HttpStatus httpStatus;
|
||||
private String detail;
|
||||
private final String detail;
|
||||
|
||||
/* 400 BAD_REQUEST : 잘못된 요청 */
|
||||
public static TicketingException throwMismatchPassword() {
|
||||
@@ -67,14 +69,6 @@ public enum ErrorCode {
|
||||
throw new TicketingException(UNABLE_CHANGE_GRADE);
|
||||
}
|
||||
|
||||
public static TicketingException throwInvalidTicketId() {
|
||||
throw new TicketingException(INVALID_TICKET_ID);
|
||||
}
|
||||
|
||||
public static TicketingException throwBadRequestMovieTime() {
|
||||
throw new TicketingException(BAD_REQUEST_MOVIE_TIME);
|
||||
}
|
||||
|
||||
public static TicketingException throwBadRequestPaymentComplete() {
|
||||
throw new TicketingException(BAD_REQUEST_PAYMENT_COMPLETE);
|
||||
}
|
||||
@@ -83,27 +77,12 @@ public enum ErrorCode {
|
||||
throw new TicketingException(BAD_REQUEST_PAYMENT_READY);
|
||||
}
|
||||
|
||||
public static TicketingException throwBadRequestPaymentCancel() {
|
||||
throw new TicketingException(BAD_REQUEST_PAYMENT_CANCEL);
|
||||
}
|
||||
|
||||
public static TicketingException throwNotRefundableTime() {
|
||||
throw new TicketingException(NOT_REFUNDABLE_TIME);
|
||||
}
|
||||
|
||||
public static TicketingException throwNotRefundableSeat() {
|
||||
throw new TicketingException(NOT_REFUNDABLE_SEAT);
|
||||
}
|
||||
|
||||
/* 403 FORBIDDEN : 접근 권한 제한 */
|
||||
public static TicketingException throwValidUserId() {
|
||||
throw new TicketingException(VALID_USER_ID);
|
||||
}
|
||||
|
||||
/* 404 NOT_FOUND : Resource 를 찾을 수 없음 */
|
||||
public static TicketingException throwUserNotFound() {
|
||||
throw new TicketingException(USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
public static TicketingException throwEmailNotFound() {
|
||||
throw new TicketingException(EMAIL_NOT_FOUND);
|
||||
@@ -113,10 +92,6 @@ public enum ErrorCode {
|
||||
throw new TicketingException(MOVIE_NOT_FOUND);
|
||||
}
|
||||
|
||||
public static TicketingException throwMovieTimeNotFound() {
|
||||
throw new TicketingException(MOVIE_TIME_NOT_FOUND);
|
||||
}
|
||||
|
||||
public static TicketingException throwRefreshTokenNotFound() {
|
||||
throw new TicketingException(REFRESH_TOKEN_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,9 @@ public class RefreshToken {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public void changeToken(String token) {
|
||||
public RefreshToken changeToken(String token) {
|
||||
this.token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class JwtProvider {
|
||||
|
||||
private static final String AUTHORITIES_KEY = "auth";
|
||||
private static final String AUTHORITIES_DELIMITER = ",";
|
||||
private static final String ROLE = "ROLE_";
|
||||
|
||||
private final Key key;
|
||||
private final String prefix;
|
||||
@@ -89,7 +90,7 @@ public class JwtProvider {
|
||||
}
|
||||
|
||||
private String makeRoleName(String role) {
|
||||
return "ROLE_" + role.toUpperCase();
|
||||
return role.contains(ROLE) ? role.toUpperCase() : ROLE + role.toUpperCase();
|
||||
}
|
||||
|
||||
public Authentication getAuthentication(String token) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ticketing.server.movie.aop;
|
||||
|
||||
import static com.ticketing.server.movie.domain.TicketLock.LOCK_VALUE;
|
||||
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.movie.service.dto.TicketIdsDTO;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Aspect
|
||||
@RequiredArgsConstructor
|
||||
public class TicketLockAspect {
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Around("execution(* com.ticketing.server.movie.service.TicketLockService.*(..))")
|
||||
public Object ticketLock(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
List<String> ticketLockIds = getTicketLockIds(joinPoint);
|
||||
|
||||
try {
|
||||
if (!isEveryTicketIdLock(ticketLockIds)) {
|
||||
throw new TicketingException(ErrorCode.BAD_REQUEST_TICKET_SOLD);
|
||||
}
|
||||
|
||||
return joinPoint.proceed();
|
||||
} finally {
|
||||
ticketIdsUnlock(ticketLockIds);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isEveryTicketIdLock(List<String> ids) {
|
||||
for (String id : ids) {
|
||||
if (Boolean.FALSE.equals(redisTemplate.opsForValue().setIfAbsent(id, LOCK_VALUE.getValue(), 5, TimeUnit.MINUTES))) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
protected Long ticketIdsUnlock(List<String> ids) {
|
||||
return redisTemplate.delete(ids);
|
||||
}
|
||||
|
||||
private List<String> getTicketLockIds(ProceedingJoinPoint joinPoint) {
|
||||
for (Object arg : joinPoint.getArgs()) {
|
||||
if (arg instanceof TicketIdsDTO) {
|
||||
TicketIdsDTO ids = (TicketIdsDTO) arg;
|
||||
return ids.makeTicketLockIds();
|
||||
}
|
||||
}
|
||||
|
||||
throw new TicketingException(ErrorCode.EMPTY_TICKET_ID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.ticketing.server.movie.domain;
|
||||
|
||||
import static com.ticketing.server.global.exception.ErrorCode.BAD_REQUEST_PAYMENT_CANCEL;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.DUPLICATE_PAYMENT;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.NOT_REFUNDABLE_SEAT;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.NOT_REFUNDABLE_TIME;
|
||||
|
||||
import com.ticketing.server.global.dto.repository.AbstractEntity;
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.persistence.Entity;
|
||||
@@ -56,7 +62,7 @@ public class Ticket extends AbstractEntity {
|
||||
|
||||
public Ticket makeReservation() {
|
||||
if (!TicketStatus.SALE.equals(status)) {
|
||||
throw ErrorCode.throwDuplicatePayment();
|
||||
throw new TicketingException(DUPLICATE_PAYMENT);
|
||||
}
|
||||
|
||||
status = TicketStatus.RESERVATION;
|
||||
@@ -65,7 +71,7 @@ public class Ticket extends AbstractEntity {
|
||||
|
||||
public Ticket makeSold(Long paymentId) {
|
||||
if (TicketStatus.SOLD.equals(status)) {
|
||||
throw ErrorCode.throwDuplicatePayment();
|
||||
throw new TicketingException(DUPLICATE_PAYMENT);
|
||||
}
|
||||
|
||||
status = TicketStatus.SOLD;
|
||||
@@ -75,7 +81,7 @@ public class Ticket extends AbstractEntity {
|
||||
|
||||
public Ticket cancel() {
|
||||
if (!TicketStatus.RESERVATION.equals(status)) {
|
||||
throw ErrorCode.throwBadRequestPaymentCancel();
|
||||
throw new TicketingException(BAD_REQUEST_PAYMENT_CANCEL);
|
||||
}
|
||||
|
||||
status = TicketStatus.SALE;
|
||||
@@ -86,7 +92,7 @@ public class Ticket extends AbstractEntity {
|
||||
public Ticket refund(LocalDateTime dateTime) {
|
||||
long seconds = ChronoUnit.SECONDS.between(dateTime, getStartAt());
|
||||
if (600L > seconds) {
|
||||
throw ErrorCode.throwNotRefundableTime();
|
||||
throw new TicketingException(NOT_REFUNDABLE_TIME);
|
||||
}
|
||||
|
||||
return refund();
|
||||
@@ -94,7 +100,7 @@ public class Ticket extends AbstractEntity {
|
||||
|
||||
public Ticket refund() {
|
||||
if (!TicketStatus.SOLD.equals(status)) {
|
||||
throw ErrorCode.throwNotRefundableSeat();
|
||||
throw new TicketingException(NOT_REFUNDABLE_SEAT);
|
||||
}
|
||||
|
||||
status = TicketStatus.SALE;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ticketing.server.movie.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum TicketLock {
|
||||
|
||||
LOCK_KEY("TicketLock"),
|
||||
LOCK_VALUE("lock");
|
||||
|
||||
private final String value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ticketing.server.movie.service;
|
||||
|
||||
import static com.ticketing.server.global.exception.ErrorCode.BAD_REQUEST_MOVIE_TIME;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.INVALID_TICKET_ID;
|
||||
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.movie.domain.Ticket;
|
||||
import com.ticketing.server.movie.domain.repository.TicketRepository;
|
||||
import com.ticketing.server.movie.service.dto.TicketIdsDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketReservationDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketSoldDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsReservationDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsSoldDTO;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class TicketLockService {
|
||||
|
||||
private final TicketRepository ticketRepository;
|
||||
|
||||
public TicketsReservationDTO ticketReservation(@Valid TicketIdsDTO ticketIdsDto) {
|
||||
List<Ticket> tickets = getTicketsByInTicketIds(ticketIdsDto.getTicketIds());
|
||||
|
||||
Long firstMovieTimeId = firstMovieTimeId(tickets);
|
||||
List<TicketReservationDTO> reservationDtoList = tickets.stream()
|
||||
.map(Ticket::makeReservation)
|
||||
.filter(ticket -> firstMovieTimeId.equals(ticket.getMovieTimeId()))
|
||||
.map(TicketReservationDTO::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (tickets.size() != reservationDtoList.size()) {
|
||||
throw new TicketingException(BAD_REQUEST_MOVIE_TIME);
|
||||
}
|
||||
|
||||
return new TicketsReservationDTO(firstMovieTitle(tickets), reservationDtoList);
|
||||
}
|
||||
|
||||
public TicketsSoldDTO ticketSold(@NotNull Long paymentId, @Valid TicketIdsDTO ticketIdsDto) {
|
||||
List<Ticket> tickets = getTicketsByInTicketIds(ticketIdsDto.getTicketIds());
|
||||
|
||||
List<TicketSoldDTO> soldDtoList = tickets.stream()
|
||||
.map(ticket -> ticket.makeSold(paymentId))
|
||||
.map(TicketSoldDTO::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new TicketsSoldDTO(paymentId, soldDtoList);
|
||||
}
|
||||
|
||||
private List<Ticket> getTicketsByInTicketIds(List<Long> ticketIds) {
|
||||
List<Ticket> tickets = ticketRepository.findTicketFetchJoinByTicketIds(ticketIds);
|
||||
|
||||
if (tickets.size() != ticketIds.size()) {
|
||||
throw new TicketingException(INVALID_TICKET_ID);
|
||||
}
|
||||
|
||||
return tickets;
|
||||
}
|
||||
|
||||
private Long firstMovieTimeId(List<Ticket> tickets) {
|
||||
Ticket ticket = tickets.get(0);
|
||||
return ticket.getMovieTimeId();
|
||||
}
|
||||
|
||||
private String firstMovieTitle(List<Ticket> tickets) {
|
||||
Ticket ticket = tickets.get(0);
|
||||
return ticket.getMovieTitle();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
package com.ticketing.server.movie.service;
|
||||
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.INVALID_TICKET_ID;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.MOVIE_TIME_NOT_FOUND;
|
||||
import static com.ticketing.server.global.exception.ErrorCode.PAYMENT_ID_NOT_FOUND;
|
||||
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.global.validator.constraints.NotEmptyCollection;
|
||||
import com.ticketing.server.movie.domain.MovieTime;
|
||||
import com.ticketing.server.movie.domain.Ticket;
|
||||
import com.ticketing.server.movie.domain.repository.MovieTimeRepository;
|
||||
import com.ticketing.server.movie.domain.repository.TicketRepository;
|
||||
import com.ticketing.server.movie.service.dto.TicketDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketIdsDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketRefundDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketReservationDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketSoldDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsCancelDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsReservationDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsSoldDTO;
|
||||
@@ -33,13 +36,13 @@ import org.springframework.validation.annotation.Validated;
|
||||
public class TicketServiceImpl implements TicketService {
|
||||
|
||||
private final TicketRepository ticketRepository;
|
||||
|
||||
private final MovieTimeRepository movieTimeRepository;
|
||||
private final TicketLockService ticketLockService;
|
||||
|
||||
@Override
|
||||
public List<TicketDTO> getTickets(@NotNull Long movieTimeId) {
|
||||
MovieTime movieTime = movieTimeRepository.findById(movieTimeId)
|
||||
.orElseThrow(ErrorCode::throwMovieTimeNotFound);
|
||||
.orElseThrow(() -> new TicketingException(MOVIE_TIME_NOT_FOUND));
|
||||
|
||||
return ticketRepository.findValidTickets(movieTime)
|
||||
.stream()
|
||||
@@ -55,7 +58,7 @@ public class TicketServiceImpl implements TicketService {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (ticketDetails.isEmpty()) {
|
||||
throw ErrorCode.throwPaymentIdNotFound();
|
||||
throw new TicketingException(PAYMENT_ID_NOT_FOUND);
|
||||
}
|
||||
|
||||
return ticketDetails;
|
||||
@@ -64,33 +67,13 @@ public class TicketServiceImpl implements TicketService {
|
||||
@Override
|
||||
@Transactional
|
||||
public TicketsReservationDTO ticketReservation(@NotEmptyCollection List<Long> ticketIds) {
|
||||
List<Ticket> tickets = getTicketsByInTicketIds(ticketIds);
|
||||
|
||||
Long firstMovieTimeId = firstMovieTimeId(tickets);
|
||||
List<TicketReservationDTO> reservationDtoList = tickets.stream()
|
||||
.map(Ticket::makeReservation)
|
||||
.filter(ticket -> firstMovieTimeId.equals(ticket.getMovieTimeId()))
|
||||
.map(TicketReservationDTO::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (ticketIds.size() != reservationDtoList.size()) {
|
||||
throw ErrorCode.throwBadRequestMovieTime();
|
||||
}
|
||||
|
||||
return new TicketsReservationDTO(firstMovieTitle(tickets), reservationDtoList);
|
||||
return ticketLockService.ticketReservation(new TicketIdsDTO(ticketIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TicketsSoldDTO ticketSold(@NotNull Long paymentId, @NotEmptyCollection List<Long> ticketIds) {
|
||||
List<Ticket> tickets = getTicketsByInTicketIds(ticketIds);
|
||||
|
||||
List<TicketSoldDTO> soldDtoList = tickets.stream()
|
||||
.map(ticket -> ticket.makeSold(paymentId))
|
||||
.map(TicketSoldDTO::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new TicketsSoldDTO(paymentId, soldDtoList);
|
||||
return ticketLockService.ticketSold(paymentId, new TicketIdsDTO(ticketIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,20 +100,10 @@ public class TicketServiceImpl implements TicketService {
|
||||
List<Ticket> tickets = ticketRepository.findTicketFetchJoinByTicketIds(ticketIds);
|
||||
|
||||
if (tickets.size() != ticketIds.size()) {
|
||||
throw ErrorCode.throwInvalidTicketId();
|
||||
throw new TicketingException(INVALID_TICKET_ID);
|
||||
}
|
||||
|
||||
return tickets;
|
||||
}
|
||||
|
||||
private Long firstMovieTimeId(List<Ticket> tickets) {
|
||||
Ticket ticket = tickets.get(0);
|
||||
return ticket.getMovieTimeId();
|
||||
}
|
||||
|
||||
private String firstMovieTitle(List<Ticket> tickets) {
|
||||
Ticket ticket = tickets.get(0);
|
||||
return ticket.getMovieTitle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ticketing.server.movie.service.dto;
|
||||
|
||||
import static com.ticketing.server.movie.domain.TicketLock.LOCK_KEY;
|
||||
|
||||
import com.ticketing.server.global.validator.constraints.NotEmptyCollection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TicketIdsDTO {
|
||||
|
||||
@NotEmptyCollection
|
||||
private List<Long> ticketIds;
|
||||
|
||||
public List<String> makeTicketLockIds() {
|
||||
return ticketIds.stream()
|
||||
.map(id -> LOCK_KEY.getValue() + ":" + id)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.ticketing.server.movie.service.interfaces;
|
||||
import com.ticketing.server.global.validator.constraints.NotEmptyCollection;
|
||||
import com.ticketing.server.movie.domain.Ticket;
|
||||
import com.ticketing.server.movie.service.dto.TicketDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketIdsDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketRefundDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsCancelDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsReservationDTO;
|
||||
@@ -10,6 +11,7 @@ import com.ticketing.server.movie.service.dto.TicketsSoldDTO;
|
||||
import com.ticketing.server.payment.service.dto.TicketDetailDTO;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public interface TicketService {
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.ticketing.server.global.redis.RefreshRedisRepository;
|
||||
import com.ticketing.server.global.redis.RefreshToken;
|
||||
import com.ticketing.server.global.security.jwt.JwtProperties;
|
||||
import com.ticketing.server.global.security.jwt.JwtProvider;
|
||||
import com.ticketing.server.user.service.dto.TokenDTO;
|
||||
import com.ticketing.server.user.service.dto.DeleteRefreshTokenDTO;
|
||||
import com.ticketing.server.user.service.dto.TokenDTO;
|
||||
import com.ticketing.server.user.service.interfaces.AuthenticationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
@@ -40,8 +40,14 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
// refresh 토큰이 있으면 수정, 없으면 생성
|
||||
refreshRedisRepository.findByEmail(email)
|
||||
.ifPresentOrElse(
|
||||
tokenEntity -> tokenEntity.changeToken(tokenDto.getRefreshToken()),
|
||||
() -> refreshRedisRepository.save(new RefreshToken(email, tokenDto.getRefreshToken()))
|
||||
tokenEntity -> refreshRedisRepository.save(
|
||||
tokenEntity.changeToken(
|
||||
tokenDto.getRefreshToken()
|
||||
)
|
||||
),
|
||||
() -> refreshRedisRepository.save(
|
||||
new RefreshToken(email, tokenDto.getRefreshToken())
|
||||
)
|
||||
);
|
||||
|
||||
return tokenDto;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
server:
|
||||
port: 8443
|
||||
address: 0.0.0.0
|
||||
|
||||
http:
|
||||
port: 8080
|
||||
|
||||
ssl:
|
||||
key-store: classpath:keystore/ticketing.p12
|
||||
key-store-password: ENC(OMvGcpZLpggFTiGNkqNe66Zq/SmJXF6o)
|
||||
key-store-type: PKCS12
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://ticketing-db/ticketing?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
|
||||
username: ENC(LowN1n4w0Ep/DqLD8+q5Bq6AXM4b8e3V)
|
||||
password: ENC(OMvGcpZLpggFTiGNkqNe66Zq/SmJXF6o)
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
show_sql: true
|
||||
format_sql: true
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
|
||||
redis:
|
||||
host: 172.18.0.3
|
||||
port: 6379
|
||||
|
||||
application:
|
||||
name: monitoring
|
||||
|
||||
|
||||
@@ -26,6 +26,24 @@ spring:
|
||||
config:
|
||||
import: "optional:configserver:"
|
||||
|
||||
application:
|
||||
name: monitoring
|
||||
|
||||
management:
|
||||
endpoint:
|
||||
metrics:
|
||||
enabled: true
|
||||
prometheus:
|
||||
enabled: true
|
||||
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health, info, metrics, prometheus
|
||||
|
||||
metrics:
|
||||
tags:
|
||||
application: ${spring.application.name}
|
||||
|
||||
jasypt:
|
||||
encryptor:
|
||||
|
||||
BIN
server/src/main/resources/keystore/ticketing.p12
Normal file
BIN
server/src/main/resources/keystore/ticketing.p12
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package com.ticketing.server.movie.aop;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TicketLockAspectTest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.ticketing.server.movie.service;
|
||||
|
||||
import static com.ticketing.server.movie.domain.TicketTest.setupTickets;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.movie.domain.Ticket;
|
||||
import com.ticketing.server.movie.domain.repository.TicketRepository;
|
||||
import com.ticketing.server.movie.service.dto.TicketIdsDTO;
|
||||
import com.ticketing.server.movie.service.dto.TicketsReservationDTO;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TicketLockServiceTest {
|
||||
|
||||
@Mock
|
||||
TicketRepository ticketRepository;
|
||||
|
||||
@InjectMocks
|
||||
TicketLockService ticketLockService;
|
||||
|
||||
@Test
|
||||
@DisplayName("티켓목록 예약으로 변경 시 조회된 갯수랑 다른 경우")
|
||||
void ticketReservationFail() {
|
||||
// given
|
||||
List<Ticket> tickets = setupTickets();
|
||||
List<Ticket> list = List.of(tickets.get(0), tickets.get(1), tickets.get(2));
|
||||
List<Long> ids = List.of(0L, 1L, 2L, 10000L);
|
||||
TicketIdsDTO ticketIdsDto = new TicketIdsDTO(ids);
|
||||
|
||||
when(ticketRepository.findTicketFetchJoinByTicketIds(ids)).thenReturn(list);
|
||||
|
||||
// when
|
||||
// then
|
||||
assertThatThrownBy(() -> ticketLockService.ticketReservation(ticketIdsDto))
|
||||
.isInstanceOf(TicketingException.class)
|
||||
.extracting("errorCode")
|
||||
.isEqualTo(ErrorCode.INVALID_TICKET_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("티켓목록 예약으로 변경 완료")
|
||||
void ticketReservationSuccess() {
|
||||
// given
|
||||
List<Ticket> tickets = setupTickets();
|
||||
List<Ticket> list = List.of(tickets.get(0), tickets.get(1), tickets.get(2));
|
||||
List<Long> ids = List.of(0L, 1L, 2L);
|
||||
TicketIdsDTO ticketIdsDto = new TicketIdsDTO(ids);
|
||||
|
||||
when(ticketRepository.findTicketFetchJoinByTicketIds(ids)).thenReturn(list);
|
||||
|
||||
// when
|
||||
TicketsReservationDTO ticketReservationsDto = ticketLockService.ticketReservation(ticketIdsDto);
|
||||
|
||||
// then
|
||||
assertThat(ticketReservationsDto.getTicketReservationDtoList()).hasSize(3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import com.ticketing.server.global.exception.ErrorCode;
|
||||
import com.ticketing.server.global.exception.TicketingException;
|
||||
import com.ticketing.server.movie.domain.Ticket;
|
||||
import com.ticketing.server.movie.domain.repository.TicketRepository;
|
||||
import com.ticketing.server.movie.service.dto.TicketsReservationDTO;
|
||||
import com.ticketing.server.payment.service.dto.TicketDetailDTO;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -61,39 +60,4 @@ class TicketServiceImplTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("티켓목록 예약으로 변경 시 조회된 갯수랑 다른 경우")
|
||||
void ticketReservationFail() {
|
||||
// given
|
||||
List<Ticket> tickets = setupTickets();
|
||||
List<Ticket> list = List.of(tickets.get(0), tickets.get(1), tickets.get(2));
|
||||
List<Long> ids = List.of(0L, 1L, 2L, 10000L);
|
||||
|
||||
when(ticketRepository.findTicketFetchJoinByTicketIds(ids)).thenReturn(list);
|
||||
|
||||
// when
|
||||
// then
|
||||
assertThatThrownBy(() -> ticketService.ticketReservation(ids))
|
||||
.isInstanceOf(TicketingException.class)
|
||||
.extracting("errorCode")
|
||||
.isEqualTo(ErrorCode.INVALID_TICKET_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("티켓목록 예약으로 변경 완료")
|
||||
void ticketReservationSuccess() {
|
||||
// given
|
||||
List<Ticket> tickets = setupTickets();
|
||||
List<Ticket> list = List.of(tickets.get(0), tickets.get(1), tickets.get(2));
|
||||
List<Long> ids = List.of(0L, 1L, 2L);
|
||||
|
||||
when(ticketRepository.findTicketFetchJoinByTicketIds(ids)).thenReturn(list);
|
||||
|
||||
// when
|
||||
TicketsReservationDTO ticketReservationsDto = ticketService.ticketReservation(ids);
|
||||
|
||||
// then
|
||||
assertThat(ticketReservationsDto.getTicketReservationDtoList()).hasSize(3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user