Add quizSize for User
This commit is contained in:
@@ -5,6 +5,8 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public final class QuizConstants {
|
||||
|
||||
public static int MAXIMUM_QUIZ_SIZE = 3;
|
||||
public static final int DEFAULT_QUIZ_SIZE = 3;
|
||||
public static final int MINIMUM_QUIZ_SIZE = 1;
|
||||
public static final int MAXIMUM_QUIZ_SIZE = 7;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mangkyu.employment.interview.app.user.dto;
|
||||
|
||||
import com.mangkyu.employment.interview.app.quiz.enums.QuizLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import static com.mangkyu.employment.interview.app.quiz.constants.QuizConstants.*;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor(force = true)
|
||||
public class AddUserRequest {
|
||||
|
||||
@NotBlank
|
||||
private final String email;
|
||||
|
||||
@NotNull
|
||||
private final QuizLevel quizLevel;
|
||||
|
||||
@Range(min = MINIMUM_QUIZ_SIZE, max = MAXIMUM_QUIZ_SIZE)
|
||||
private final Integer quizSize = DEFAULT_QUIZ_SIZE;
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mangkyu.employment.interview.app.quiz.constants.QuizConstants.DEFAULT_QUIZ_SIZE;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
@Getter
|
||||
@@ -25,6 +27,8 @@ public class User extends BaseEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private QuizLevel quizLevel;
|
||||
|
||||
private Integer quizSize = DEFAULT_QUIZ_SIZE;
|
||||
|
||||
@OneToMany(mappedBy = "user")
|
||||
private List<SolvedQuiz> solvedQuizList = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class UserRepositoryTest {
|
||||
final User user = User.builder()
|
||||
.email("minkyu@test.com")
|
||||
.quizLevel(QuizLevel.JUNIOR)
|
||||
.quizSize(5)
|
||||
.build();
|
||||
|
||||
// when
|
||||
@@ -30,6 +31,7 @@ class UserRepositoryTest {
|
||||
// then
|
||||
assertThat(result.getEmail()).isEqualTo(user.getEmail());
|
||||
assertThat(result.getQuizLevel()).isEqualTo(user.getQuizLevel());
|
||||
assertThat(result.getQuizSize()).isEqualTo(user.getQuizSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user