diff --git a/src/main/generated/com/moabam/api/domain/entity/QBug.java b/src/main/generated/com/moabam/api/domain/entity/QBug.java deleted file mode 100644 index b0ec3e0b..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QBug.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; - - -/** - * QBug is a Querydsl query type for Bug - */ -@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer") -public class QBug extends BeanPath { - - private static final long serialVersionUID = -556789843L; - - public static final QBug bug = new QBug("bug"); - - public final NumberPath goldenBug = createNumber("goldenBug", Integer.class); - - public final NumberPath morningBug = createNumber("morningBug", Integer.class); - - public final NumberPath nightBug = createNumber("nightBug", Integer.class); - - public QBug(String variable) { - super(Bug.class, forVariable(variable)); - } - - public QBug(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QBug(PathMetadata metadata) { - super(Bug.class, metadata); - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QCertification.java b/src/main/generated/com/moabam/api/domain/entity/QCertification.java deleted file mode 100644 index a0058662..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QCertification.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QCertification is a Querydsl query type for Certification - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QCertification extends EntityPathBase { - - private static final long serialVersionUID = -1089572173L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QCertification certification = new QCertification("certification"); - - public final com.moabam.global.common.entity.QBaseTimeEntity _super = new com.moabam.global.common.entity.QBaseTimeEntity(this); - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath image = createString("image"); - - public final NumberPath memberId = createNumber("memberId", Long.class); - - public final QRoutine routine; - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QCertification(String variable) { - this(Certification.class, forVariable(variable), INITS); - } - - public QCertification(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QCertification(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QCertification(PathMetadata metadata, PathInits inits) { - this(Certification.class, metadata, inits); - } - - public QCertification(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.routine = inits.isInitialized("routine") ? new QRoutine(forProperty("routine"), inits.get("routine")) : null; - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QMember.java b/src/main/generated/com/moabam/api/domain/entity/QMember.java deleted file mode 100644 index 9ac14464..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QMember.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QMember is a Querydsl query type for Member - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QMember extends EntityPathBase { - - private static final long serialVersionUID = 137904833L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QMember member = new QMember("member1"); - - public final com.moabam.global.common.entity.QBaseTimeEntity _super = new com.moabam.global.common.entity.QBaseTimeEntity(this); - - public final QBug bug; - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final NumberPath currentMorningCount = createNumber("currentMorningCount", Integer.class); - - public final NumberPath currentNightCount = createNumber("currentNightCount", Integer.class); - - public final DateTimePath deletedAt = createDateTime("deletedAt", java.time.LocalDateTime.class); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath intro = createString("intro"); - - public final StringPath nickname = createString("nickname"); - - public final StringPath profileImage = createString("profileImage"); - - public final NumberPath reportCount = createNumber("reportCount", Integer.class); - - public final EnumPath role = createEnum("role", com.moabam.api.domain.entity.enums.Role.class); - - public final NumberPath socialId = createNumber("socialId", Long.class); - - public final NumberPath totalCertifyCount = createNumber("totalCertifyCount", Long.class); - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QMember(String variable) { - this(Member.class, forVariable(variable), INITS); - } - - public QMember(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QMember(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QMember(PathMetadata metadata, PathInits inits) { - this(Member.class, metadata, inits); - } - - public QMember(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.bug = inits.isInitialized("bug") ? new QBug(forProperty("bug")) : null; - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QParticipant.java b/src/main/generated/com/moabam/api/domain/entity/QParticipant.java deleted file mode 100644 index 5e71a9fd..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QParticipant.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QParticipant is a Querydsl query type for Participant - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QParticipant extends EntityPathBase { - - private static final long serialVersionUID = 615004012L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QParticipant participant = new QParticipant("participant"); - - public final NumberPath certifyCount = createNumber("certifyCount", Integer.class); - - public final DateTimePath deletedAt = createDateTime("deletedAt", java.time.LocalDateTime.class); - - public final StringPath deletedRoomTitle = createString("deletedRoomTitle"); - - public final NumberPath id = createNumber("id", Long.class); - - public final BooleanPath isManager = createBoolean("isManager"); - - public final NumberPath memberId = createNumber("memberId", Long.class); - - public final QRoom room; - - public QParticipant(String variable) { - this(Participant.class, forVariable(variable), INITS); - } - - public QParticipant(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QParticipant(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QParticipant(PathMetadata metadata, PathInits inits) { - this(Participant.class, metadata, inits); - } - - public QParticipant(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.room = inits.isInitialized("room") ? new QRoom(forProperty("room")) : null; - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QProduct.java b/src/main/generated/com/moabam/api/domain/entity/QProduct.java deleted file mode 100644 index deb3c4f5..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QProduct.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; - - -/** - * QProduct is a Querydsl query type for Product - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QProduct extends EntityPathBase { - - private static final long serialVersionUID = -1278273112L; - - public static final QProduct product = new QProduct("product"); - - public final com.moabam.global.common.entity.QBaseTimeEntity _super = new com.moabam.global.common.entity.QBaseTimeEntity(this); - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath name = createString("name"); - - public final NumberPath price = createNumber("price", Integer.class); - - public final NumberPath quantity = createNumber("quantity", Integer.class); - - public final EnumPath type = createEnum("type", com.moabam.api.domain.entity.enums.ProductType.class); - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QProduct(String variable) { - super(Product.class, forVariable(variable)); - } - - public QProduct(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QProduct(PathMetadata metadata) { - super(Product.class, metadata); - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QRoom.java b/src/main/generated/com/moabam/api/domain/entity/QRoom.java deleted file mode 100644 index 9b6807fe..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QRoom.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; - - -/** - * QRoom is a Querydsl query type for Room - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QRoom extends EntityPathBase { - - private static final long serialVersionUID = -80144702L; - - public static final QRoom room = new QRoom("room"); - - public final com.moabam.global.common.entity.QBaseTimeEntity _super = new com.moabam.global.common.entity.QBaseTimeEntity(this); - - public final StringPath announcement = createString("announcement"); - - public final NumberPath certifyTime = createNumber("certifyTime", Integer.class); - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final NumberPath currentUserCount = createNumber("currentUserCount", Integer.class); - - public final NumberPath id = createNumber("id", Long.class); - - public final NumberPath level = createNumber("level", Integer.class); - - public final NumberPath maxUserCount = createNumber("maxUserCount", Integer.class); - - public final StringPath password = createString("password"); - - public final StringPath roomImage = createString("roomImage"); - - public final EnumPath roomType = createEnum("roomType", com.moabam.api.domain.entity.enums.RoomType.class); - - public final StringPath title = createString("title"); - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QRoom(String variable) { - super(Room.class, forVariable(variable)); - } - - public QRoom(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QRoom(PathMetadata metadata) { - super(Room.class, metadata); - } - -} - diff --git a/src/main/generated/com/moabam/api/domain/entity/QRoutine.java b/src/main/generated/com/moabam/api/domain/entity/QRoutine.java deleted file mode 100644 index e9421850..00000000 --- a/src/main/generated/com/moabam/api/domain/entity/QRoutine.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.moabam.api.domain.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QRoutine is a Querydsl query type for Routine - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QRoutine extends EntityPathBase { - - private static final long serialVersionUID = 416853373L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QRoutine routine = new QRoutine("routine"); - - public final com.moabam.global.common.entity.QBaseTimeEntity _super = new com.moabam.global.common.entity.QBaseTimeEntity(this); - - public final StringPath content = createString("content"); - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final NumberPath id = createNumber("id", Long.class); - - public final QRoom room; - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QRoutine(String variable) { - this(Routine.class, forVariable(variable), INITS); - } - - public QRoutine(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QRoutine(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QRoutine(PathMetadata metadata, PathInits inits) { - this(Routine.class, metadata, inits); - } - - public QRoutine(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.room = inits.isInitialized("room") ? new QRoom(forProperty("room")) : null; - } - -} - diff --git a/src/main/generated/com/moabam/global/common/entity/QBaseTimeEntity.java b/src/main/generated/com/moabam/global/common/entity/QBaseTimeEntity.java deleted file mode 100644 index dc553d21..00000000 --- a/src/main/generated/com/moabam/global/common/entity/QBaseTimeEntity.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.moabam.global.common.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; - - -/** - * QBaseTimeEntity is a Querydsl query type for BaseTimeEntity - */ -@Generated("com.querydsl.codegen.DefaultSupertypeSerializer") -public class QBaseTimeEntity extends EntityPathBase { - - private static final long serialVersionUID = 115157954L; - - public static final QBaseTimeEntity baseTimeEntity = new QBaseTimeEntity("baseTimeEntity"); - - public final DateTimePath createdAt = createDateTime("createdAt", java.time.LocalDateTime.class); - - public final DateTimePath updatedAt = createDateTime("updatedAt", java.time.LocalDateTime.class); - - public QBaseTimeEntity(String variable) { - super(BaseTimeEntity.class, forVariable(variable)); - } - - public QBaseTimeEntity(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QBaseTimeEntity(PathMetadata metadata) { - super(BaseTimeEntity.class, metadata); - } - -} - diff --git a/src/main/java/com/moabam/api/application/MemberService.java b/src/main/java/com/moabam/api/application/MemberService.java index dae4a85f..03ef55a9 100644 --- a/src/main/java/com/moabam/api/application/MemberService.java +++ b/src/main/java/com/moabam/api/application/MemberService.java @@ -69,4 +69,4 @@ public Member getManager(Long roomId) { public List getRoomMembers(List memberIds) { return memberRepository.findAllById(memberIds); } -} \ No newline at end of file +} diff --git a/src/main/java/com/moabam/global/common/constant/RedisConstant.java b/src/main/java/com/moabam/global/common/constant/RedisConstant.java index fe06b7dd..a8a3a4e3 100644 --- a/src/main/java/com/moabam/global/common/constant/RedisConstant.java +++ b/src/main/java/com/moabam/global/common/constant/RedisConstant.java @@ -5,10 +5,17 @@ public class RedisConstant { public static final String REDIS_SERVER_MAX_MEMORY = "maxmemory 128M"; public static final String REDIS_BINARY_PATH = "binary/redis/redis-server-arm64"; public static final String FIND_LISTEN_PROCESS_COMMAND = "netstat -nat | grep LISTEN | grep %d"; + public static final String WIN_LISTEN_PROCESS_COMMAND = "netstat -ano | findstr LISTEN | findstr %d"; + public static final String SHELL_PATH = "/bin/sh"; + public static final String WIN_SHELL_PATH = "cmd.exe"; public static final String SHELL_COMMAND_OPTION = "-c"; + public static final String WIN_OPTION_OPERATOR = "/c"; + public static final String OS_ARCHITECTURE = "os.arch"; public static final String OS_NAME = "os.name"; public static final String ARM_ARCHITECTURE = "aarch64"; + public static final String AMD_ARCHITECTURE = "amd64"; + public static final String WINDOW_OS_NAME = "Windows"; public static final String MAC_OS_NAME = "Mac OS X"; } diff --git a/src/main/java/com/moabam/global/config/EmbeddedRedisConfig.java b/src/main/java/com/moabam/global/config/EmbeddedRedisConfig.java index 16587cac..6b1807c4 100644 --- a/src/main/java/com/moabam/global/config/EmbeddedRedisConfig.java +++ b/src/main/java/com/moabam/global/config/EmbeddedRedisConfig.java @@ -6,7 +6,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; -import java.util.Objects; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -17,8 +16,8 @@ import com.moabam.global.error.exception.MoabamException; import com.moabam.global.error.model.ErrorMessage; -import jakarta.annotation.PostConstruct; import jakarta.annotation.PreDestroy; +import lombok.Builder; import lombok.extern.slf4j.Slf4j; import redis.embedded.RedisServer; @@ -30,17 +29,24 @@ public class EmbeddedRedisConfig { @Value("${spring.data.redis.port}") private int redisPort; + private int availablePort; private RedisServer redisServer; - @PostConstruct + public EmbeddedRedisConfig(@Value("${spring.data.redis.port}") int redisPort) { + this.redisPort = redisPort; + + startRedis(); + } + public void startRedis() { - int port = isRedisRunning() ? findAvailablePort() : redisPort; + Os os = Os.createOs(); + availablePort = findPort(os); - if (isArmMac()) { - redisServer = new RedisServer(getRedisFileForArcMac(), port); + if (os.isMac()) { + redisServer = new RedisServer(getRedisFileForArcMac(), availablePort); } else { redisServer = RedisServer.builder() - .port(port) + .port(availablePort) .setting(REDIS_SERVER_MAX_MEMORY) .build(); } @@ -64,9 +70,21 @@ public void stopRedis() { } } - public int findAvailablePort() { + public int getAvailablePort() { + return availablePort; + } + + private int findPort(Os os) { + if (!isRunning(os.executeCommand(redisPort))) { + return redisPort; + } + + return findAvailablePort(os); + } + + private int findAvailablePort(Os os) { for (int port = 10000; port <= 65535; port++) { - Process process = executeGrepProcessCommand(port); + Process process = os.executeCommand(port); if (!isRunning(process)) { return port; @@ -76,21 +94,6 @@ public int findAvailablePort() { throw new MoabamException(ErrorMessage.NOT_FOUND_AVAILABLE_PORT); } - private boolean isRedisRunning() { - return isRunning(executeGrepProcessCommand(redisPort)); - } - - private Process executeGrepProcessCommand(int redisPort) { - String command = String.format(FIND_LISTEN_PROCESS_COMMAND, redisPort); - String[] shell = {SHELL_PATH, SHELL_COMMAND_OPTION, command}; - - try { - return Runtime.getRuntime().exec(shell); - } catch (IOException e) { - throw new MoabamException(e.getMessage()); - } - } - private boolean isRunning(Process process) { String line; StringBuilder pidInfo = new StringBuilder(); @@ -106,11 +109,6 @@ private boolean isRunning(Process process) { return StringUtils.hasText(pidInfo.toString()); } - private boolean isArmMac() { - return Objects.equals(System.getProperty(OS_ARCHITECTURE), ARM_ARCHITECTURE) - && Objects.equals(System.getProperty(OS_NAME), MAC_OS_NAME); - } - private File getRedisFileForArcMac() { try { return new ClassPathResource(REDIS_BINARY_PATH).getFile(); @@ -118,4 +116,74 @@ private File getRedisFileForArcMac() { throw new MoabamException(e.getMessage()); } } + + private static final class Os { + + enum Type { + MAC, + WIN, + LINUX + } + + private final String shellPath; + private final String optionOperator; + private final String command; + private final Type type; + + @Builder + private Os(String shellPath, String optionOperator, String command, Type type) { + this.shellPath = shellPath; + this.optionOperator = optionOperator; + this.command = command; + this.type = type; + } + + public Process executeCommand(int port) { + String command = String.format(this.command, port); + String[] script = {shellPath, optionOperator, command}; + + try { + return Runtime.getRuntime().exec(script); + } catch (IOException e) { + throw new MoabamException(e.getMessage()); + } + } + + public boolean isMac() { + return type == Type.MAC; + } + + public static Os createOs() { + String osArchitecture = System.getProperty(OS_ARCHITECTURE); + String osName = System.getProperty(OS_NAME); + + if (osArchitecture.equals(ARM_ARCHITECTURE) && osName.equals(MAC_OS_NAME)) { + return linuxOs(Type.MAC); + } + + if (osArchitecture.equals(AMD_ARCHITECTURE) && osName.contains(WINDOW_OS_NAME)) { + return windowOs(); + } + + return linuxOs(Type.LINUX); + } + + private static Os linuxOs(Type type) { + return Os.builder() + .shellPath(SHELL_PATH) + .optionOperator(SHELL_COMMAND_OPTION) + .command(FIND_LISTEN_PROCESS_COMMAND) + .type(type) + .build(); + } + + private static Os windowOs() { + return Os.builder() + .shellPath(WIN_SHELL_PATH) + .optionOperator(WIN_OPTION_OPERATOR) + .command(WIN_LISTEN_PROCESS_COMMAND) + .type(Type.WIN) + .build(); + } + } } diff --git a/src/main/java/com/moabam/global/config/RedisConfig.java b/src/main/java/com/moabam/global/config/RedisConfig.java index d4d484c2..79c0e85b 100644 --- a/src/main/java/com/moabam/global/config/RedisConfig.java +++ b/src/main/java/com/moabam/global/config/RedisConfig.java @@ -3,12 +3,14 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; @Configuration +@Profile("!test") public class RedisConfig { @Value("${spring.data.redis.host}") diff --git a/src/main/java/com/moabam/global/config/TimeConfig.java b/src/main/java/com/moabam/global/config/TimeConfig.java new file mode 100644 index 00000000..f3efaf10 --- /dev/null +++ b/src/main/java/com/moabam/global/config/TimeConfig.java @@ -0,0 +1,22 @@ +package com.moabam.global.config; + +import java.time.Clock; +import java.time.LocalDateTime; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class TimeConfig { + + private Clock clock; + + @Bean + public Clock clock() { + return Clock.systemDefaultZone(); + } + + public void main(String[] args) { + LocalDateTime.now(clock); + } +} diff --git a/src/main/resources/static/docs/index.html b/src/main/resources/static/docs/index.html index c1cb84c5..4c581a2b 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -616,7 +616,7 @@

diff --git a/src/main/resources/static/docs/notification.html b/src/main/resources/static/docs/notification.html index e28c38d8..fb1fa2d7 100644 --- a/src/main/resources/static/docs/notification.html +++ b/src/main/resources/static/docs/notification.html @@ -473,7 +473,7 @@

응답

Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 64 +Content-Length: 66 { "message" : "이미 콕 알림을 보낸 대상입니다." @@ -487,7 +487,7 @@

응답

diff --git a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java index 7477725d..04c19fda 100644 --- a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java @@ -770,16 +770,14 @@ void get_room_details_test() throws Exception { participant1.enableManager(); Member member2 = Member.builder() - .socialId("SOCIAL_2") + .socialId(2L) .nickname("NICKNAME_2") - .profileImage("PROFILE_IMAGE_2") .bug(BugFixture.bug()) .build(); Member member3 = Member.builder() - .socialId("SOCIAL_3") + .socialId(3L) .nickname("NICKNAME_3") - .profileImage("PROFILE_IMAGE_3") .bug(BugFixture.bug()) .build(); diff --git a/src/test/java/com/moabam/global/common/config/TestConfig.java b/src/test/java/com/moabam/global/common/config/TestConfig.java new file mode 100644 index 00000000..6aae3e50 --- /dev/null +++ b/src/test/java/com/moabam/global/common/config/TestConfig.java @@ -0,0 +1,35 @@ +package com.moabam.global.common.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import com.moabam.global.config.EmbeddedRedisConfig; + +@Configuration +@Profile("test") +public class TestConfig { + + @Value("${spring.data.redis.host}") + private String redisHost; + + @Bean + public RedisConnectionFactory redisConnectionFactory(EmbeddedRedisConfig embeddedRedisConfig) { + return new LettuceConnectionFactory(redisHost, embeddedRedisConfig.getAvailablePort()); + } + + @Bean + public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) { + StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(); + stringRedisTemplate.setKeySerializer(new StringRedisSerializer()); + stringRedisTemplate.setValueSerializer(new StringRedisSerializer()); + stringRedisTemplate.setConnectionFactory(redisConnectionFactory); + + return stringRedisTemplate; + } +} diff --git a/src/test/java/com/moabam/global/common/repository/StringRedisRepositoryTest.java b/src/test/java/com/moabam/global/common/repository/StringRedisRepositoryTest.java index 0deb6cea..b48610b0 100644 --- a/src/test/java/com/moabam/global/common/repository/StringRedisRepositoryTest.java +++ b/src/test/java/com/moabam/global/common/repository/StringRedisRepositoryTest.java @@ -10,11 +10,14 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import com.moabam.global.common.config.TestConfig; import com.moabam.global.config.EmbeddedRedisConfig; import com.moabam.global.config.RedisConfig; @SpringBootTest(classes = {RedisConfig.class, EmbeddedRedisConfig.class, StringRedisRepository.class}) +@Import(TestConfig.class) class StringRedisRepositoryTest { @Autowired