-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 4주차 테스트 코드 10개 작성 #1
Open
mikekks
wants to merge
3
commits into
main
Choose a base branch
from
week4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,46 @@ | ||
package com.sopt.Server.common; | ||
|
||
import static com.sopt.Server.exception.Error.*; | ||
|
||
import com.sopt.Server.exception.Error; | ||
import com.sopt.Server.exception.model.CustomException; | ||
import java.util.Arrays; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum AgeEnum { | ||
TEENAGER("어리숙한 귀요미", "아직은 알아갈 것들이 너무 많은 당신! 세상엔 새로운 것들이 천지삐까리야~", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011954.png?raw=true", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_10.png?raw=true"), | ||
TWENTIES("말랑한 깜찍이", "뭐가 뭔지 이제 조금 알 것 같은 당신! 앞으로도 재밌는 것들을 많이 알아가보자", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011951.png?raw=true","https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_20.png?raw=true"), | ||
THIRTIES("성장중인 새싹이", "매일 매일 자라고 있는 당신! 다음 달엔 얼마나 발전했을지 궁금한 걸?", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011952.png?raw=true","https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_30.png?raw=true"), | ||
FORTIES("성숙한 멋쟁이", "어디에서든 멋진 당신! 뭐든 좋으니 하고 싶은 거 다 해봐!", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011953.png?raw=true","https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_40.png?raw=true"), | ||
FIFTIES("진정한 어른이", "어른이란 이런 건가 싶은 당신! 이런 식이면 진짜 어른이 될 수밖에 없어 ", "https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011955.png?raw=true","https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_50.png?raw=true"); | ||
TEENAGER(10, 19, "어리숙한 귀요미", "아직은 알아갈 것들이 너무 많은 당신! 세상엔 새로운 것들이 천지삐까리야~", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011954.png?raw=true", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_10.png?raw=true"), | ||
TWENTIES(20, 29,"말랑한 깜찍이", "뭐가 뭔지 이제 조금 알 것 같은 당신! 앞으로도 재밌는 것들을 많이 알아가보자", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011951.png?raw=true", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_20.png?raw=true"), | ||
THIRTIES(30, 39, "성장중인 새싹이", "매일 매일 자라고 있는 당신! 다음 달엔 얼마나 발전했을지 궁금한 걸?", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011952.png?raw=true", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_30.png?raw=true"), | ||
FORTIES(40, 49, "성숙한 멋쟁이", "어디에서든 멋진 당신! 뭐든 좋으니 하고 싶은 거 다 해봐!", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011953.png?raw=true", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_40.png?raw=true"), | ||
FIFTIES(50, Integer.MAX_VALUE, "진정한 어른이", "어른이란 이런 건가 싶은 당신! 이런 식이면 진짜 어른이 될 수밖에 없어 ", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Frame%2011955.png?raw=true", | ||
"https://github.com/DO-SOPT-SOPKATHON-iOS4/SOPKATHON-Server/blob/main/image/Result_ic_50.png?raw=true"); | ||
|
||
private final int minAge; | ||
private final int maxAge; | ||
private final String title; | ||
private final String content; | ||
private final String imageUrl1; | ||
private final String imageUrl2; | ||
|
||
public static AgeEnum getAgeEnum(int age) { | ||
return Arrays.stream(AgeEnum.values()) | ||
.filter(ageEnum -> ageEnum.minAge <= age && ageEnum.maxAge >= age) | ||
.findAny() | ||
.orElseThrow(() -> new CustomException(INVALID_AGE_ENUM, INVALID_AGE_ENUM.getMessage())); | ||
} | ||
|
||
Comment on lines
+38
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 이렇게 수정하셨군요!! 근데 서비스의 이해를 높여드리자면 TEENAGER의 minAge는 0살이면 좋을 것 같습니다! 10대 이하일 경우 에러를 반환하는게 아니라 그냥 10대의 결과를 반환하는게 저희 솝커톤의 서비스 흐름이었거든요! |
||
} | ||
|
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
4 changes: 3 additions & 1 deletion
4
src/main/java/com/sopt/Server/controller/request/AnswerRequestDTO.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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
package com.sopt.Server.controller.request; | ||
|
||
public record AnswerRequestDTO(Long questionId, boolean answerType) { | ||
public record AnswerRequestDTO( | ||
Long questionId, | ||
boolean answerType) { | ||
} |
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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
package com.sopt.Server.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "QUESTIONS") | ||
@NoArgsConstructor | ||
public class Question { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long questionId; | ||
|
||
private String questionContent; | ||
|
||
public Question(String questionContent) { | ||
this.questionContent = questionContent; | ||
} | ||
} |
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,34 @@ | ||
package com.sopt.Server.common; | ||
|
||
import static com.sopt.Server.exception.Error.INVALID_AGE_ENUM; | ||
import static com.sopt.Server.exception.Error.INVALID_NAME; | ||
|
||
import com.sopt.Server.exception.model.CustomException; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class AgeEnumTest { | ||
|
||
@Test | ||
void 연령Enum조회_성공_정상입력(){ | ||
// given | ||
int age = 20; | ||
|
||
// when | ||
AgeEnum ageEnum = AgeEnum.getAgeEnum(age); | ||
|
||
// then | ||
Assertions.assertThat(ageEnum.getMinAge()).isEqualTo(20); | ||
} | ||
|
||
@Test | ||
void 연령Enum조회_예외발생_연령대가10세미만인경우(){ | ||
// given | ||
int age = 9; | ||
|
||
// when | ||
Assertions.assertThatThrownBy(() -> AgeEnum.getAgeEnum(age)) | ||
.isInstanceOf(CustomException.class) | ||
.hasMessageContaining(INVALID_AGE_ENUM.getMessage()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿!