1
1
package nextstep .qna .domain ;
2
2
3
- import nextstep .courses .domain .FreeSession ;
4
- import nextstep .courses .domain .LectureStatus ;
5
- import nextstep .courses .domain .PaidSession ;
6
- import nextstep .courses .domain .Session ;
3
+ import nextstep .courses .domain .*;
7
4
import nextstep .payments .domain .Payment ;
8
5
import org .junit .jupiter .api .DisplayName ;
9
6
import org .junit .jupiter .api .Test ;
@@ -20,10 +17,9 @@ void notRegisterSession() {
20
17
Session session = new FreeSession (
21
18
1L ,
22
19
"자바지기" ,
23
- LocalDate .now (),
24
- LocalDate .now (),
20
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
25
21
null ,
26
- LectureStatus .CLOSED
22
+ SessionStatus .CLOSED
27
23
);
28
24
assertThatThrownBy (() -> {
29
25
session .register (1L , new Payment ());
@@ -35,10 +31,9 @@ void registerSession() {
35
31
Session session = new FreeSession (
36
32
1L ,
37
33
"자바지기" ,
38
- LocalDate .now (),
39
- LocalDate .now (),
34
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
40
35
null ,
41
- LectureStatus .RECRUITING
36
+ SessionStatus .RECRUITING
42
37
);
43
38
session .register (1L , new Payment ());
44
39
assertThat (session .isRegistered (1L )).isTrue ();
@@ -50,19 +45,24 @@ void paidSession() {
50
45
Session session = new PaidSession (
51
46
1L ,
52
47
"자바지기" ,
53
- LocalDate .now (),
54
- LocalDate .now (),
48
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
55
49
null ,
56
- LectureStatus .RECRUITING ,
57
- 0 ,
58
- 10000L
50
+ SessionStatus .RECRUITING ,
51
+ 1 ,
52
+ 10000
59
53
);
60
54
assertThatThrownBy (() -> {
61
55
session .register (11L , new Payment (
62
56
"1" ,
63
57
1L ,
64
58
11L ,
65
- 10000L
59
+ 10000
60
+ ));
61
+ session .register (11L , new Payment (
62
+ "1" ,
63
+ 1L ,
64
+ 11L ,
65
+ 10000
66
66
));
67
67
}).isInstanceOf (IllegalStateException .class ).hasMessage ("수강 인원을 초과하였습니다." );
68
68
}
@@ -73,12 +73,11 @@ void paidSessionWithoutPayment() {
73
73
Session session = new PaidSession (
74
74
1L ,
75
75
"자바지기" ,
76
- LocalDate .now (),
77
- LocalDate .now (),
76
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
78
77
null ,
79
- LectureStatus .RECRUITING ,
78
+ SessionStatus .RECRUITING ,
80
79
10 ,
81
- 10000L
80
+ 10000
82
81
);
83
82
assertThatThrownBy (() -> {
84
83
session .register (11L , null );
@@ -91,19 +90,18 @@ void paidSessionWithDifferentPayment() {
91
90
Session session = new PaidSession (
92
91
1L ,
93
92
"자바지기" ,
94
- LocalDate .now (),
95
- LocalDate .now (),
93
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
96
94
null ,
97
- LectureStatus .RECRUITING ,
95
+ SessionStatus .RECRUITING ,
98
96
10 ,
99
- 10000L
97
+ 10000
100
98
);
101
99
assertThatThrownBy (() -> {
102
100
session .register (11L , new Payment (
103
101
"1" ,
104
102
2L ,
105
103
11L ,
106
- 10000L
104
+ 10000
107
105
));
108
106
}).isInstanceOf (IllegalArgumentException .class ).hasMessage ("결제한 강의와 일치하지 않습니다." );
109
107
}
@@ -114,19 +112,18 @@ void paidSessionWithDifferentStudent() {
114
112
Session session = new PaidSession (
115
113
1L ,
116
114
"자바지기" ,
117
- LocalDate .now (),
118
- LocalDate .now (),
115
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
119
116
null ,
120
- LectureStatus .RECRUITING ,
117
+ SessionStatus .RECRUITING ,
121
118
10 ,
122
- 10000L
119
+ 10000
123
120
);
124
121
assertThatThrownBy (() -> {
125
122
session .register (11L , new Payment (
126
123
"1" ,
127
124
1L ,
128
125
12L ,
129
- 10000L
126
+ 10000
130
127
));
131
128
}).isInstanceOf (IllegalArgumentException .class ).hasMessage ("결제한 사용자와 일치하지 않습니다." );
132
129
}
@@ -137,20 +134,20 @@ void paidSessionWithDifferentTuitionFee() {
137
134
Session session = new PaidSession (
138
135
1L ,
139
136
"자바지기" ,
140
- LocalDate .now (),
141
- LocalDate .now (),
137
+ new Period (LocalDate .now (), LocalDate .now ().plusDays (1 )),
142
138
null ,
143
- LectureStatus .RECRUITING ,
139
+ SessionStatus .RECRUITING ,
144
140
10 ,
145
- 10000L
141
+ 10000
146
142
);
147
143
assertThatThrownBy (() -> {
148
144
session .register (11L , new Payment (
149
145
"1" ,
150
146
1L ,
151
147
11L ,
152
- 20000L
148
+ 20000
153
149
));
154
150
}).isInstanceOf (IllegalArgumentException .class ).hasMessage ("결제 금액과 일치하지 않습니다." );
155
151
}
152
+
156
153
}
0 commit comments