-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into feat/#246
- Loading branch information
Showing
9 changed files
with
236 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CD-Back-Dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
paths: 'backend/**' | ||
|
||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
working-directory: backend | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 리포지토리 체크아웃 | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.SUBMODULE_TOKEN }} | ||
|
||
- name: 자바 설치 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
|
||
- name: gradlew 권한 부여 | ||
run: chmod +x gradlew | ||
|
||
- name: Gradle Test | ||
run: ./gradlew test | ||
|
||
- name: trigger to jenkins dev cd | ||
uses: appleboy/jenkins-action@master | ||
with: | ||
url: ${{ secrets.JENKINS_URL }} | ||
user: "festago" | ||
token: ${{ secrets.JENKINS_API_TOKEN}} | ||
job: "festago-dev-cd" |
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,74 @@ | ||
package com.festago.domain; | ||
|
||
import com.festago.exception.ErrorCode; | ||
import com.festago.exception.InternalServerException; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
|
||
@Entity | ||
public class School { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@Size(max = 50) | ||
private String domain; | ||
|
||
@NotNull | ||
@Size(max = 255) | ||
private String name; | ||
|
||
protected School() { | ||
} | ||
|
||
public School(Long id, String domain, String name) { | ||
validate(domain, name); | ||
this.id = id; | ||
this.domain = domain; | ||
this.name = name; | ||
} | ||
|
||
private void validate(String domain, String name) { | ||
checkNotNull(domain, name); | ||
checkLength(domain, name); | ||
} | ||
|
||
private void checkNotNull(String domain, String name) { | ||
if (domain == null || | ||
name == null) { | ||
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
|
||
private void checkLength(String domain, String name) { | ||
if (overLength(domain, 50) || | ||
overLength(name, 255)) { | ||
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
|
||
private boolean overLength(String target, int maxLength) { | ||
if (target == null) { | ||
return false; | ||
} | ||
return target.length() > maxLength; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getDomain() { | ||
return domain; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
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,86 @@ | ||
package com.festago.domain; | ||
|
||
import com.festago.exception.ErrorCode; | ||
import com.festago.exception.InternalServerException; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
|
||
@Entity | ||
public class Student { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private Member member; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private School school; | ||
|
||
@Size(max = 255) | ||
@NotNull | ||
private String username; | ||
|
||
protected Student() { | ||
} | ||
|
||
public Student(Long id, Member member, School school, String username) { | ||
validate(member, school, username); | ||
this.id = id; | ||
this.member = member; | ||
this.school = school; | ||
this.username = username; | ||
} | ||
|
||
private void validate(Member member, School school, String username) { | ||
checkNotNull(member, school, username); | ||
checkLength(username); | ||
} | ||
|
||
private void checkNotNull(Member member, School school, String username) { | ||
if (member == null || | ||
school == null || | ||
username == null) { | ||
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
|
||
private void checkLength(String username) { | ||
if (overLength(username, 255)) { | ||
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR); | ||
} | ||
} | ||
|
||
private boolean overLength(String target, int maxLength) { | ||
if (target == null) { | ||
return false; | ||
} | ||
return target.length() > maxLength; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Member getMember() { | ||
return member; | ||
} | ||
|
||
public School getSchool() { | ||
return school; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,24 @@ | ||
package com.festago.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.festago.support.MemberFixture; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@DisplayNameGeneration(ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
class MemberTest { | ||
|
||
@Test | ||
void 프로필_이미지가_null이면_기본값이_할당된다() { | ||
// when | ||
Member actual = MemberFixture.member() | ||
.profileImage(null) | ||
.build(); | ||
|
||
// then | ||
assertThat(actual.getProfileImage()).isNotNull(); | ||
} | ||
} |