Skip to content

Commit

Permalink
[Chore] QueryDsl 세팅 (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youhoseong authored Sep 3, 2022
1 parent 5f175f5 commit e9fb820
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'com.epages.restdocs-api-spec' version '0.16.2'
id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}

subprojects {
Expand Down Expand Up @@ -108,6 +109,8 @@ project(':keewe-core') {


project(':keewe-domain') {
apply plugin: 'com.ewerk.gradle.plugins.querydsl'

bootJar {
enabled = false
}
Expand All @@ -116,15 +119,43 @@ project(':keewe-domain') {
enabled = true
}

configurations {
querydsl {
extendsFrom compileClasspath
}
}

ext {
queryDslVersion = "5.0.0"
}

dependencies {
implementation project(path: ':keewe-core', configuration: 'default')
implementation project(path: ':keewe-infra', configuration: 'default')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'mysql:mysql-connector-java'
implementation group: 'com.h2database', name: 'h2', version: '2.1.214'
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
// todo ::jpa, redis import
}


def querydslSrcDir = "$buildDir/generated/querydsl"

querydsl {
jpa = true
querydslSourcesDir = querydslSrcDir
}

sourceSets {
main.java.srcDir querydslSrcDir
}

compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
}

project(':keewe-api') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void test1() {
User user = SecurityUtil.getUser();
userRepository.save(user);
System.out.println("user = " + user.getId());
Profile profile = Profile.init().user(user).build();
Profile profile = Profile.of(user);

Nest nest = new Nest();
nestRepository.save(nest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ public class Profile extends BaseTimeEntity {
public static final int NICKNAME_MAX_LENGTH = 10;
public static final int SOCIAL_LINKS_MAX_SIZE = 5;

public static ProfileBuilder init() {
return Profile.builder()
.privacy(PUBLIC)
.profileStatus(NICKNAME_NEEDED)
.activities(new ArrayList<>())
.followers(new ArrayList<>())
.followees(new ArrayList<>())
.socialLinks(new ArrayList<>())
.deleted(false);
}

public static Profile of(User user) {
Profile profile = new Profile();
profile.connectWithUser(user);
Expand Down Expand Up @@ -152,4 +141,5 @@ private void checkLinkPatternOrElseThrow(String link) {
if (!matcher.matches())
throw new IllegalArgumentException("링크 패턴이 일치하지 않습니다.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class ProfileDomainServiceTest {
@Test
@DisplayName("닉네임 생성 제약조건 테스트")
void nickname_constraint_test() {
Profile profile = Profile.init().build();
Profile profile = new Profile();

when(profileRepository.findById(any()))
.thenReturn(Optional.of(profile));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class ProfileTest {
@Test
@DisplayName("링크 패턴 정규식 테스트")
void test1() {
Profile profile = Profile.init().build();

Profile profile = new Profile();
// 정상적인 링크
profile.createLink("_hello._.world_");

Expand Down

0 comments on commit e9fb820

Please sign in to comment.