-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from Nexters/develop
테스트코드 추가
- Loading branch information
Showing
14 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
spring: | ||
datasource: | ||
driver-class-name: org.h2.Driver | ||
url: jdbc:h2:mem:testdb;MODE=MySQL; | ||
username: sa | ||
password: | ||
|
||
jpa: | ||
open-in-view: true | ||
hibernate: | ||
ddl-auto: update | ||
naming: | ||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl | ||
show-sql: true | ||
properties: | ||
hibernate: | ||
format_sql: true | ||
dialect: org.hibernate.dialect.MySQL8InnoDBDialect | ||
defer-datasource-initialization: true | ||
sql: | ||
init: | ||
mode: always | ||
encoding: UTF-8 |
23 changes: 23 additions & 0 deletions
23
src/test/java/com/sirius/spurt/common/config/QuerydslConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sirius.spurt.common.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.sirius.spurt.store.repository.database.custom.impl.QuestionRepositoryImpl; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@TestConfiguration | ||
public class QuerydslConfigTest { | ||
@PersistenceContext private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
|
||
@Bean | ||
public QuestionRepositoryImpl questionRepositoryImpl() { | ||
return new QuestionRepositoryImpl(jpaQueryFactory()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/com/sirius/spurt/store/repository/database/repository/UserRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.sirius.spurt.store.repository.database.repository; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.sirius.spurt.common.config.QuerydslConfigTest; | ||
import com.sirius.spurt.test.UserTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@DataJpaTest | ||
@ActiveProfiles("test") | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | ||
@Import(QuerydslConfigTest.class) | ||
class UserRepositoryTest implements UserTest { | ||
@Autowired private UserRepository userRepository; | ||
|
||
@Test | ||
void 유저_존재_확인_테스트() { | ||
// given | ||
userRepository.save(TEST_USER); | ||
|
||
// when | ||
boolean isExistsUser = userRepository.existsByUserId(TEST_USER_ID); | ||
|
||
// then | ||
assertThat(isExistsUser).isEqualTo(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.sirius.spurt.test; | ||
|
||
import com.sirius.spurt.common.meta.JobGroup; | ||
import com.sirius.spurt.store.repository.database.entity.UserEntity; | ||
|
||
public interface UserTest { | ||
String TEST_USER_ID = "userId"; | ||
JobGroup TEST_JOB_GROUP = JobGroup.DEVELOPER; | ||
String TEST_EMAIL = "[email protected]"; | ||
Boolean TEST_HAS_PINED = Boolean.TRUE; | ||
Boolean TEST_HAS_POSTED = Boolean.TRUE; | ||
|
||
UserEntity TEST_USER = | ||
UserEntity.builder() | ||
.userId(TEST_USER_ID) | ||
.jobGroup(TEST_JOB_GROUP) | ||
.email(TEST_EMAIL) | ||
.hasPined(TEST_HAS_PINED) | ||
.hasPosted(TEST_HAS_POSTED) | ||
.build(); | ||
} |