Revize d6c90b22
Přidáno uživatelem Dominik Poch před téměř 6 roky(ů)
server/src/main/java/cz/zcu/yamanager/domain/User.java | ||
---|---|---|
25 | 25 |
*/ |
26 | 26 |
private static final int EMAIL_ADDRESS_LENGTH = 100; |
27 | 27 |
|
28 |
/** |
|
29 |
* The url of a generic photo. |
|
30 |
*/ |
|
31 |
private static final String DEFAULT_PHOTO = "https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg"; |
|
32 |
|
|
28 | 33 |
/** |
29 | 34 |
* The logger. |
30 | 35 |
*/ |
... | ... | |
33 | 38 |
/** |
34 | 39 |
* The user's ID. |
35 | 40 |
*/ |
36 |
private final long id;
|
|
41 |
private Long id;
|
|
37 | 42 |
|
38 | 43 |
/** |
39 | 44 |
* The user's first name. |
... | ... | |
48 | 53 |
/** |
49 | 54 |
* The number of user's remaining hours of an overtime. |
50 | 55 |
*/ |
51 |
private float vacationCount;
|
|
56 |
private Float vacationCount;
|
|
52 | 57 |
|
53 | 58 |
/** |
54 | 59 |
* The number of user's sick days available during a year. |
55 | 60 |
*/ |
56 |
private int totalSickDayCount;
|
|
61 |
private Integer totalSickDayCount;
|
|
57 | 62 |
|
58 | 63 |
/** |
59 | 64 |
* The number of user's taken sick days. |
60 | 65 |
*/ |
61 |
private int takenSickDayCount;
|
|
66 |
private Integer takenSickDayCount;
|
|
62 | 67 |
|
63 | 68 |
/** |
64 | 69 |
* The date and time of sending an email warning about an incoming reset of remaining overtimes and sick days. |
... | ... | |
83 | 88 |
/** |
84 | 89 |
* The date and time of a user's creation. |
85 | 90 |
*/ |
86 |
private final LocalDateTime creationDate;
|
|
91 |
private LocalDateTime creationDate; |
|
87 | 92 |
|
88 | 93 |
/** |
89 | 94 |
* The user's role. |
... | ... | |
96 | 101 |
private Status status; |
97 | 102 |
|
98 | 103 |
/** |
99 |
* Creates an empty user for testing purposes only. |
|
100 |
* It just sets id to zero and creation date to now. |
|
101 |
*/ |
|
102 |
public User() { |
|
103 |
User.log.trace("Creating a new instance of the class User."); |
|
104 |
this.id = 0; |
|
105 |
this.creationDate = null; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Creates a new user and sets attributes known during an insertion. |
|
104 |
* Returns the user's ID. |
|
110 | 105 |
* |
111 |
* @param firstName the user's first name |
|
112 |
* @param lastName the user's last name. |
|
113 |
* @param vacationCount the number of user's remaining hours of an overtime |
|
114 |
* @param totalSickDayCount the number of user's sick days available during a year |
|
115 |
* @param takenSickDayCount the number of user's taken sick days |
|
116 |
* @param notification the date and time of sending an email warning about an incoming reset of remaining overtimes and sick days |
|
117 |
* @param token the token for the Google oAuth |
|
118 |
* @param email the user's email address |
|
119 |
* @param photo the URL of a user's photo |
|
120 |
* @param role the user's role |
|
121 |
* @param status the user's authorization status |
|
122 |
* @throws IllegalArgumentException when the vacationCount, totalSickDayCount or takenSickDayCount are negative or first name, last name or email exceed the maximal permitted number of characters |
|
123 |
*/ |
|
124 |
public User(final String firstName, final String lastName, final Float vacationCount, final Integer totalSickDayCount, final Integer takenSickDayCount, final LocalDateTime notification, final String token, final String email, final String photo, final UserRole role, final Status status) throws IllegalArgumentException { |
|
125 |
this(0, firstName, lastName, vacationCount, totalSickDayCount, takenSickDayCount, notification, token, email, photo, null, role, status); |
|
106 |
* @return the user's ID |
|
107 |
*/ |
|
108 |
public Long getId() { |
|
109 |
return this.id; |
|
126 | 110 |
} |
127 | 111 |
|
128 | 112 |
/** |
129 |
* Creates a new user and sets all his/hers attributes.
|
|
113 |
* Replaces the user's ID with the given one.
|
|
130 | 114 |
* |
131 |
* @param id the user's ID |
|
132 |
* @param firstName the user's first name |
|
133 |
* @param lastName the user's last name. |
|
134 |
* @param vacationCount the number of user's remaining hours of an overtime |
|
135 |
* @param totalSickDayCount the number of user's sick days available during a year |
|
136 |
* @param takenSickDayCount the number of user's taken sick days |
|
137 |
* @param notification the date and time of sending an email warning about an incoming reset of remaining overtimes and sick days |
|
138 |
* @param token the token for the Google oAuth |
|
139 |
* @param email the user's email address |
|
140 |
* @param photo the URL of a user's photo |
|
141 |
* @param creationDate the date and time of a user's creation |
|
142 |
* @param role the user's role |
|
143 |
* @param status the user's authorization status |
|
144 |
* @throws IllegalArgumentException when the vacationCount, totalSickDayCount or takenSickDayCount are negative or first name, last name or email exceed the maximal permitted number of characters |
|
145 |
*/ |
|
146 |
public User(final long id, final String firstName, final String lastName, final Float vacationCount, final Integer totalSickDayCount, final Integer takenSickDayCount, final LocalDateTime notification, final String token, final String email, final String photo, final LocalDateTime creationDate, final UserRole role, final Status status) throws IllegalArgumentException { |
|
147 |
User.log.trace("Creating a new instance of the class User."); |
|
148 |
User.log.debug("User: id={}, firstName={}, lastName={}, vacationCount={}, totalSickDayCount={}, takenSickDayCount={}, notification={}, token={}, email={}, photo={}, creationDate={}, role={}, status={}", id, firstName, lastName, vacationCount, totalSickDayCount, takenSickDayCount, notification, token, email, photo, creationDate, role, status); |
|
115 |
* @param id the given ID |
|
116 |
*/ |
|
117 |
public void setId(final Long id) { |
|
118 |
User.log.debug("Setting a new id: {}", id); |
|
149 | 119 |
|
150 | 120 |
this.id = id; |
151 |
this.setFirstName(firstName); |
|
152 |
this.setLastName(lastName); |
|
153 |
this.setVacationCount(vacationCount); |
|
154 |
this.setTotalSickDayCount(totalSickDayCount); |
|
155 |
this.setTakenSickDayCount(takenSickDayCount); |
|
156 |
this.setNotification(notification); |
|
157 |
this.token = token; |
|
158 |
this.setEmail(email); |
|
159 |
this.photo = photo; |
|
160 |
this.creationDate = creationDate; |
|
161 |
this.setRole(role); |
|
162 |
this.setStatus(status); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Returns the user's ID. |
|
167 |
* |
|
168 |
* @return the user's ID |
|
169 |
*/ |
|
170 |
public long getId() { |
|
171 |
return this.id; |
|
172 | 121 |
} |
173 | 122 |
|
174 | 123 |
/** |
... | ... | |
190 | 139 |
public void setFirstName(final String firstName) throws IllegalArgumentException { |
191 | 140 |
User.log.debug("Setting a new first name: {}", firstName); |
192 | 141 |
|
193 |
if (firstName.length() > User.NAME_LENGTH) { |
|
142 |
if (firstName == null) { |
|
143 |
User.log.warn("The given first name must not be null"); |
|
144 |
throw new IllegalArgumentException("first.name.null.error"); |
|
145 |
} else if (firstName.length() > User.NAME_LENGTH) { |
|
194 | 146 |
User.log.warn("The length of the given first name exceeded a limit"); |
195 | 147 |
throw new IllegalArgumentException("name.length.error"); |
196 | 148 |
} |
... | ... | |
217 | 169 |
public void setLastName(final String lastName) throws IllegalArgumentException { |
218 | 170 |
User.log.debug("Setting a new last name: {}", lastName); |
219 | 171 |
|
220 |
if (lastName.length() > User.NAME_LENGTH) { |
|
172 |
if(lastName == null) { |
|
173 |
User.log.warn("The given last name must not be null"); |
|
174 |
throw new IllegalArgumentException("last.name.null.error"); |
|
175 |
} else if (lastName.length() > User.NAME_LENGTH) { |
|
221 | 176 |
User.log.warn("The length of the given last name exceeded a limit"); |
222 | 177 |
throw new IllegalArgumentException("name.length.error"); |
223 | 178 |
} |
... | ... | |
230 | 185 |
* |
231 | 186 |
* @return the number of user's remaining hours of the overtime |
232 | 187 |
*/ |
233 |
public float getVacationCount() {
|
|
188 |
public Float getVacationCount() {
|
|
234 | 189 |
return this.vacationCount; |
235 | 190 |
} |
236 | 191 |
|
... | ... | |
255 | 210 |
this.vacationCount = vacationCount; |
256 | 211 |
} |
257 | 212 |
|
213 |
/** |
|
214 |
* Adds a difference of the given starting and the ending time of a vacation |
|
215 |
* to the number of user's available vacations. If some of the given parameters are null |
|
216 |
* or the times are not in order the method throws an exception. |
|
217 |
* |
|
218 |
* @param from the starting time of a vacation |
|
219 |
* @param to the ending time of a vacation |
|
220 |
* @throws IllegalArgumentException when some of the given parameters are null |
|
221 |
* or the times are not in order |
|
222 |
*/ |
|
223 |
public void addVacationCount(final LocalTime from, final LocalTime to) { |
|
224 |
User.log.debug("Adding a vacation from {} to {}", from, to); |
|
225 |
|
|
226 |
if(from == null || to == null) { |
|
227 |
User.log.warn("A vacation has to have a starting and an ending time"); |
|
228 |
throw new IllegalArgumentException("time.vacation.error"); |
|
229 |
} else if (from.compareTo(to) >= 0) { |
|
230 |
User.log.warn("A vacation must not start after it ends. from={}, to={}", from, to); |
|
231 |
throw new IllegalArgumentException("time.order.error"); |
|
232 |
} |
|
233 |
|
|
234 |
final float difference = from.until(to, MINUTES) / 60f; |
|
235 |
this.vacationCount += difference; |
|
236 |
} |
|
237 |
|
|
258 | 238 |
/** |
259 | 239 |
* Returns the number of user's sick days available during a year. |
260 | 240 |
* |
261 | 241 |
* @return the number of user's sick days available during the year |
262 | 242 |
*/ |
263 |
public int getTotalSickDayCount() {
|
|
243 |
public Integer getTotalSickDayCount() {
|
|
264 | 244 |
return this.totalSickDayCount; |
265 | 245 |
} |
266 | 246 |
|
... | ... | |
274 | 254 |
public void setTotalSickDayCount(final Integer totalSickDayCount) throws IllegalArgumentException { |
275 | 255 |
User.log.debug("Setting a new number of user's sick days available during a year: {}", totalSickDayCount); |
276 | 256 |
|
277 |
if (totalSickDayCount == null) { |
|
278 |
User.log.warn("The number of user's available sick days must not be null"); |
|
279 |
throw new IllegalArgumentException("sick.day.null.error"); |
|
280 |
} else if (totalSickDayCount < 0) { |
|
257 |
if (totalSickDayCount != null && totalSickDayCount < 0) { |
|
281 | 258 |
User.log.warn("The number of user's available sick days must not be negative"); |
282 | 259 |
throw new IllegalArgumentException("negative.sick.day.error"); |
283 | 260 |
} |
... | ... | |
290 | 267 |
* |
291 | 268 |
* @return the number of user's taken sick days |
292 | 269 |
*/ |
293 |
public int getTakenSickDayCount() {
|
|
270 |
public Integer getTakenSickDayCount() {
|
|
294 | 271 |
return this.takenSickDayCount; |
295 | 272 |
} |
296 | 273 |
|
... | ... | |
318 | 295 |
this.takenSickDayCount = takenSickDayCount; |
319 | 296 |
} |
320 | 297 |
|
298 |
/** |
|
299 |
* Adds the given amount to the number of user's remaining hours of an overtime. |
|
300 |
* If the given number is null or a result of the addition is negative the method throws an exception. |
|
301 |
* |
|
302 |
* @param value the given amount that is going to be added |
|
303 |
* @throws IllegalArgumentException when the given number is null or a result of the addition is negative |
|
304 |
*/ |
|
305 |
public void addTakenSickDayCount(final Integer value) throws IllegalArgumentException { |
|
306 |
User.log.debug("Increasing the number of remaining overtime by {}", value); |
|
307 |
|
|
308 |
if (value == null) { |
|
309 |
User.log.warn("The given value must not be null"); |
|
310 |
throw new IllegalArgumentException("vacation.null.error"); |
|
311 |
} else if (this.takenSickDayCount + value < 0) { |
|
312 |
User.log.warn("The number number of user's taken sick days must not be negative"); |
|
313 |
throw new IllegalArgumentException("negative.sick.day.error"); |
|
314 |
} else if (this.takenSickDayCount + value > this.totalSickDayCount) { |
|
315 |
User.log.warn("The number number of user's taken sick days must not greater than his/her available sick days"); |
|
316 |
throw new IllegalArgumentException("taken.sick.day.count.error"); |
|
317 |
} |
|
318 |
|
|
319 |
this.takenSickDayCount += value; |
|
320 |
} |
|
321 |
|
|
321 | 322 |
/** |
322 | 323 |
* Returns the date and time of sending an email warning about an incoming reset of remaining overtimes and sick days. |
323 | 324 |
* |
... | ... | |
337 | 338 |
public void setNotification(final LocalDateTime notification) throws IllegalArgumentException { |
338 | 339 |
User.log.debug("Setting a new date and time of sending an email warning: {}", notification); |
339 | 340 |
|
340 |
if(notification == null) { |
|
341 |
User.log.warn("The given notification must not be null"); |
|
342 |
throw new IllegalArgumentException("notification.null.error"); |
|
343 |
} |
|
344 |
|
|
345 | 341 |
this.notification = notification; |
346 | 342 |
} |
347 | 343 |
|
... | ... | |
361 | 357 |
*/ |
362 | 358 |
public void setToken(final String token) { |
363 | 359 |
User.log.debug("Setting a new token: {}", token); |
360 |
|
|
361 |
if (token == null) { |
|
362 |
User.log.warn("The given token must not be null"); |
|
363 |
throw new IllegalArgumentException("token.null.error"); |
|
364 |
} |
|
365 |
|
|
364 | 366 |
this.token = token; |
365 | 367 |
} |
366 | 368 |
|
... | ... | |
383 | 385 |
public void setEmail(final String email) throws IllegalArgumentException { |
384 | 386 |
User.log.debug("Setting a new email address: {}", email); |
385 | 387 |
|
386 |
if (email.length() > User.EMAIL_ADDRESS_LENGTH) { |
|
388 |
if (email == null) { |
|
389 |
User.log.warn("The given email must not be null"); |
|
390 |
throw new IllegalArgumentException("email.null.error"); |
|
391 |
}else if (email.length() > User.EMAIL_ADDRESS_LENGTH) { |
|
387 | 392 |
User.log.warn("The length of the email address exceeded a limit"); |
388 | 393 |
throw new IllegalArgumentException("email.length.error"); |
389 | 394 |
} |
... | ... | |
407 | 412 |
*/ |
408 | 413 |
public void setPhoto(final String photo) { |
409 | 414 |
User.log.debug("Setting a new url of a photo: {}", photo); |
410 |
this.photo = photo; |
|
415 |
|
|
416 |
this.photo = photo == null ? User.DEFAULT_PHOTO : photo; |
|
411 | 417 |
} |
412 | 418 |
|
413 | 419 |
/** |
... | ... | |
419 | 425 |
return this.creationDate; |
420 | 426 |
} |
421 | 427 |
|
428 |
/** |
|
429 |
* Replaces the user's creation date with the given date and time. |
|
430 |
* |
|
431 |
* @param creationDate the new creation date |
|
432 |
*/ |
|
433 |
public void setCreationDate(final LocalDateTime creationDate) { |
|
434 |
User.log.debug("Setting a new user's creation date: {}", creationDate); |
|
435 |
|
|
436 |
if (creationDate == null) { |
|
437 |
User.log.warn("The given creation date must not be null"); |
|
438 |
throw new IllegalArgumentException("creation.null.error"); |
|
439 |
} |
|
440 |
|
|
441 |
this.creationDate = creationDate; |
|
442 |
} |
|
443 |
|
|
422 | 444 |
/** |
423 | 445 |
* Returns the user's role. |
424 | 446 |
* |
server/src/test/java/cz/zcu/yamanager/domain/UserTest.java | ||
---|---|---|
8 | 8 |
import java.time.LocalDateTime; |
9 | 9 |
import java.time.LocalTime; |
10 | 10 |
|
11 |
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
12 |
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
11 |
import static org.junit.jupiter.api.Assertions.*; |
|
13 | 12 |
|
14 | 13 |
/** |
15 | 14 |
* This class tests methods of the {@code User} class. |
... | ... | |
28 | 27 |
@BeforeEach |
29 | 28 |
void setUp() { |
30 | 29 |
this.user = new User(); |
30 |
this.user.setVacationCount(0f); |
|
31 |
this.user.setTotalSickDayCount(0); |
|
32 |
this.user.setTakenSickDayCount(0); |
|
31 | 33 |
} |
32 | 34 |
|
33 | 35 |
/** |
34 | 36 |
* Tests the method {@code setFirstName} with common values where no problem should occur. |
35 | 37 |
*/ |
36 | 38 |
@Test |
37 |
void testSetFirstName() {
|
|
39 |
void setFirstName_valid() {
|
|
38 | 40 |
this.user.setFirstName("aaaaaa"); |
39 | 41 |
assertEquals("aaaaaa", this.user.getFirstName()); |
40 | 42 |
} |
... | ... | |
43 | 45 |
* Tests the method {@code setFirstName} with the maximal length of a name. |
44 | 46 |
*/ |
45 | 47 |
@Test |
46 |
void testSetFirstNameMax() {
|
|
48 |
void setFirstName_maxLength_valid() {
|
|
47 | 49 |
this.user.setFirstName("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
48 | 50 |
assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", this.user.getFirstName()); |
49 | 51 |
} |
... | ... | |
52 | 54 |
* Tests the method {@code setFirstName} with name that exceeds maximal length which should throw an exception. |
53 | 55 |
*/ |
54 | 56 |
@Test |
55 |
void testSetFirstNameException() {
|
|
57 |
void setFirstName_tooLong() {
|
|
56 | 58 |
assertThrows(IllegalArgumentException.class, () -> this.user.setFirstName("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
57 | 59 |
} |
58 | 60 |
|
61 |
/** |
|
62 |
* Tests the method {@code setFirstName} with null input which should throw an exception. |
|
63 |
*/ |
|
64 |
@Test |
|
65 |
void setFirstName_nullInput() { |
|
66 |
assertThrows(IllegalArgumentException.class, () -> this.user.setFirstName(null)); |
|
67 |
} |
|
68 |
|
|
59 | 69 |
/** |
60 | 70 |
* Tests the method {@code setLastName} with common values where no problem should occur. |
61 | 71 |
*/ |
62 | 72 |
@Test |
63 |
void testSetLastName() {
|
|
73 |
void setLastName_valid() {
|
|
64 | 74 |
this.user.setLastName("aaaaaa"); |
65 | 75 |
assertEquals("aaaaaa", this.user.getLastName()); |
66 | 76 |
} |
... | ... | |
69 | 79 |
* Tests the method {@code setLastName} with the maximal length of a name. |
70 | 80 |
*/ |
71 | 81 |
@Test |
72 |
void testSetLastNameMax() {
|
|
82 |
void setLastName_maxLength_valid() {
|
|
73 | 83 |
this.user.setLastName("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
74 | 84 |
assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", this.user.getLastName()); |
75 | 85 |
} |
... | ... | |
78 | 88 |
* Tests the method {@code setLastName} with name that exceeds maximal length which should throw an exception. |
79 | 89 |
*/ |
80 | 90 |
@Test |
81 |
void testSetLastNameException() {
|
|
91 |
void setLastName_tooLong() {
|
|
82 | 92 |
assertThrows(IllegalArgumentException.class, () -> this.user.setLastName("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
83 | 93 |
} |
84 | 94 |
|
95 |
/** |
|
96 |
* Tests the method {@code setLastName} with null input which should throw an exception. |
|
97 |
*/ |
|
98 |
@Test |
|
99 |
void setLastName_nullInput() { |
|
100 |
assertThrows(IllegalArgumentException.class, () -> this.user.setLastName(null)); |
|
101 |
} |
|
102 |
|
|
85 | 103 |
/** |
86 | 104 |
* Tests the method {@code setVacationCount} with common values where no problem should occur. |
87 | 105 |
*/ |
88 | 106 |
@Test |
89 |
void testSetVacationCount() {
|
|
107 |
void setVacationCount_valid() {
|
|
90 | 108 |
this.user.setVacationCount(10f); |
91 |
assertEquals(10, this.user.getVacationCount());
|
|
109 |
assertEquals(10f, this.user.getVacationCount().floatValue());
|
|
92 | 110 |
} |
93 | 111 |
|
94 | 112 |
/** |
95 | 113 |
* Tests the method {@code setVacationCount} with zero which is a threshold value. |
96 | 114 |
*/ |
97 | 115 |
@Test |
98 |
void testSetVacationCountZero() {
|
|
116 |
void setVacationCount_zeroInput_valid() {
|
|
99 | 117 |
this.user.setVacationCount(0f); |
100 |
assertEquals(0, this.user.getVacationCount());
|
|
118 |
assertEquals(0f, this.user.getVacationCount().floatValue());
|
|
101 | 119 |
} |
102 | 120 |
|
103 | 121 |
/** |
104 | 122 |
* Tests the method {@code setVacationCount} with negative one which is a threshold value. |
105 | 123 |
*/ |
106 | 124 |
@Test |
107 |
void testSetVacationCountNegativeOne() {
|
|
125 |
void setVacationCount_negativeOneInput() {
|
|
108 | 126 |
assertThrows(IllegalArgumentException.class, () -> this.user.setVacationCount(-1f)); |
109 | 127 |
} |
110 | 128 |
|
... | ... | |
112 | 130 |
* Tests the method {@code setVacationCount} with negative value. |
113 | 131 |
*/ |
114 | 132 |
@Test |
115 |
void testSetVacationCountNegative() {
|
|
133 |
void setVacationCount_negativeInput() {
|
|
116 | 134 |
assertThrows(IllegalArgumentException.class, () -> this.user.setVacationCount(-10f)); |
117 | 135 |
} |
118 | 136 |
|
119 | 137 |
/** |
120 |
* Tests the method {@code setVacationCount} with null value. |
|
138 |
* Tests the method {@code setVacationCount} with null value which should throw an exception.
|
|
121 | 139 |
*/ |
122 | 140 |
@Test |
123 |
void testSetVacationCountObjectNull() {
|
|
141 |
void setVacationCount_nullInput() {
|
|
124 | 142 |
assertThrows(IllegalArgumentException.class, () -> this.user.setVacationCount(null)); |
125 | 143 |
} |
126 | 144 |
|
145 |
/** |
|
146 |
* Tests the method {@code addVacationCount} with common values where no problem should occur. |
|
147 |
*/ |
|
148 |
@Test |
|
149 |
void addVacationCount_floatInput_valid() { |
|
150 |
this.user.addVacationCount(10f); |
|
151 |
assertEquals(10f, this.user.getVacationCount().floatValue()); |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* Tests the method {@code addVacationCount} with common values where no problem should occur. |
|
156 |
*/ |
|
157 |
@Test |
|
158 |
void addVacationCount_addFloatInput_valid() { |
|
159 |
this.user.setVacationCount(2f); |
|
160 |
this.user.addVacationCount(10f); |
|
161 |
assertEquals(12f, this.user.getVacationCount().floatValue()); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Tests the method {@code addVacationCount} with common values where no problem should occur. |
|
166 |
*/ |
|
167 |
@Test |
|
168 |
void addVacationCount_subtractFloatInput_valid() { |
|
169 |
this.user.setVacationCount(20f); |
|
170 |
this.user.addVacationCount(-10f); |
|
171 |
assertEquals(10f, this.user.getVacationCount().floatValue()); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Tests the method {@code addVacationCount} with negative result of the operation which should throw an exception. |
|
176 |
*/ |
|
177 |
@Test |
|
178 |
void addVacationCount_floatInput_negativeResult() { |
|
179 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(-10f)); |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Tests the method {@code addVacationCount} with null value which should throw an exception. |
|
184 |
*/ |
|
185 |
@Test |
|
186 |
void addVacationCount_nullFloatInput() { |
|
187 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(null)); |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Tests the method {@code addVacationCount} with common values where no problem should occur. |
|
192 |
*/ |
|
193 |
@Test |
|
194 |
void addVacationCount_timeInput_valid() { |
|
195 |
LocalTime from = LocalTime.of(10,0); |
|
196 |
LocalTime to = LocalTime.of(20,0); |
|
197 |
this.user.addVacationCount(from, to); |
|
198 |
assertEquals(10f, this.user.getVacationCount().floatValue()); |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* Tests the method {@code addVacationCount} with wrong order of parameters which should throw an exception. |
|
203 |
*/ |
|
204 |
@Test |
|
205 |
void addVacationCount_timeInput_order() { |
|
206 |
LocalTime from = LocalTime.of(10,0); |
|
207 |
LocalTime to = LocalTime.of(20,0); |
|
208 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(to, from)); |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* Tests the method {@code addVacationCount} with null from parameter which should throw an exception. |
|
213 |
*/ |
|
214 |
@Test |
|
215 |
void addVacationCount_timeInput_nullFrom() { |
|
216 |
LocalTime to = LocalTime.of(20,0); |
|
217 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(null, to)); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Tests the method {@code addVacationCount} with null to parameter which should throw an exception. |
|
222 |
*/ |
|
223 |
@Test |
|
224 |
void addVacationCount_timeInput_nullTo() { |
|
225 |
LocalTime from = LocalTime.of(20,0); |
|
226 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(from, null)); |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Tests the method {@code addVacationCount} with null parameters which should throw an exception. |
|
231 |
*/ |
|
232 |
@Test |
|
233 |
void addVacationCount_timeNullInput() { |
|
234 |
assertThrows(IllegalArgumentException.class, () -> this.user.addVacationCount(null, null)); |
|
235 |
} |
|
236 |
|
|
127 | 237 |
/** |
128 | 238 |
* Tests the method {@code setTotalSickDayCount} with common values where no problem should occur. |
129 | 239 |
*/ |
130 | 240 |
@Test |
131 |
void testSetTotalSickDayCount() {
|
|
241 |
void setTotalSickDayCount_valid() {
|
|
132 | 242 |
this.user.setTotalSickDayCount(10); |
133 |
assertEquals(10, this.user.getTotalSickDayCount()); |
|
243 |
assertEquals(10, this.user.getTotalSickDayCount().intValue());
|
|
134 | 244 |
} |
135 | 245 |
|
136 | 246 |
/** |
137 | 247 |
* Tests the method {@code setTotalSickDayCount} with zero which is a threshold value. |
138 | 248 |
*/ |
139 | 249 |
@Test |
140 |
void testSetTotalSickDayCountZero() {
|
|
250 |
void setTotalSickDayCount_zeroInput_valid() {
|
|
141 | 251 |
this.user.setTotalSickDayCount(0); |
142 |
assertEquals(0, this.user.getTotalSickDayCount()); |
|
252 |
assertEquals(0, this.user.getTotalSickDayCount().intValue());
|
|
143 | 253 |
} |
144 | 254 |
|
145 | 255 |
/** |
146 | 256 |
* Tests the method {@code setTotalSickDayCount} with negative one which is a threshold value. |
147 | 257 |
*/ |
148 | 258 |
@Test |
149 |
void testSetTotalSickDayCountNegativeOne() {
|
|
259 |
void setTotalSickDayCount_negativeOneInput() {
|
|
150 | 260 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTotalSickDayCount(-1)); |
151 | 261 |
} |
152 | 262 |
|
... | ... | |
154 | 264 |
* Tests the method {@code setTotalSickDayCount} with negative value. |
155 | 265 |
*/ |
156 | 266 |
@Test |
157 |
void testSetTotalSickDayCountNegative() {
|
|
267 |
void setTotalSickDayCount_negativeInput() {
|
|
158 | 268 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTotalSickDayCount(-10)); |
159 | 269 |
} |
160 | 270 |
|
... | ... | |
162 | 272 |
* Tests the method {@code setTotalSickDayCount} with null value. |
163 | 273 |
*/ |
164 | 274 |
@Test |
165 |
void testSetTotalSickDayCountObjectNull() { |
|
166 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTotalSickDayCount(null)); |
|
275 |
void setTotalSickDayCount_nullInput_valid() { |
|
276 |
this.user.setTotalSickDayCount(null); |
|
277 |
assertNull(this.user.getTotalSickDayCount()); |
|
167 | 278 |
} |
168 | 279 |
|
169 | 280 |
/** |
170 | 281 |
* Tests the method {@code setTakenSickDayCount} with common values where no problem should occur. |
171 | 282 |
*/ |
172 | 283 |
@Test |
173 |
void testSetTakenSickDayCount() {
|
|
174 |
this.user.setTotalSickDayCount(50);
|
|
284 |
void setTakenSickDayCount_valid() {
|
|
285 |
this.user.setTotalSickDayCount(20);
|
|
175 | 286 |
this.user.setTakenSickDayCount(10); |
176 |
assertEquals(10, this.user.getTakenSickDayCount()); |
|
287 |
assertEquals(10, this.user.getTakenSickDayCount().intValue());
|
|
177 | 288 |
} |
178 | 289 |
|
179 | 290 |
/** |
180 | 291 |
* Tests the method {@code setTakenSickDayCount} with zero which is a threshold value. |
181 | 292 |
*/ |
182 | 293 |
@Test |
183 |
void testSetTakenSickDayCountZero() { |
|
184 |
this.user.setTotalSickDayCount(50); |
|
294 |
void setTakenSickDayCount_zeroInput_valid() { |
|
185 | 295 |
this.user.setTakenSickDayCount(0); |
186 |
assertEquals(0, this.user.getTakenSickDayCount()); |
|
296 |
assertEquals(0, this.user.getTakenSickDayCount().intValue());
|
|
187 | 297 |
} |
188 | 298 |
|
189 | 299 |
/** |
190 | 300 |
* Tests the method {@code setTakenSickDayCount} with negative one which is a threshold value. |
191 | 301 |
*/ |
192 | 302 |
@Test |
193 |
void testSetTakenSickDayCountNegativeOne() { |
|
194 |
this.user.setTotalSickDayCount(10); |
|
303 |
void setTakenSickDayCount_negativeOneInput() { |
|
195 | 304 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTakenSickDayCount(-1)); |
196 | 305 |
} |
197 | 306 |
|
... | ... | |
199 | 308 |
* Tests the method {@code setTakenSickDayCount} with negative value. |
200 | 309 |
*/ |
201 | 310 |
@Test |
202 |
void testSetTakenSickDayCountNegative() {
|
|
311 |
void setTakenSickDayCount_negativeInput() {
|
|
203 | 312 |
this.user.setTotalSickDayCount(10); |
204 | 313 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTakenSickDayCount(-10)); |
205 | 314 |
} |
... | ... | |
208 | 317 |
* Tests the method {@code setTakenSickDayCount} with a value that is greater than total sick days. |
209 | 318 |
*/ |
210 | 319 |
@Test |
211 |
void testSetTakenSickDayCountOver() {
|
|
320 |
void setTakenSickDayCount_over() {
|
|
212 | 321 |
this.user.setTotalSickDayCount(10); |
213 | 322 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTakenSickDayCount(20)); |
214 | 323 |
} |
... | ... | |
217 | 326 |
* Tests the method {@code setTakenSickDayCount} with a value that is equals the total sick days. |
218 | 327 |
*/ |
219 | 328 |
@Test |
220 |
void testSetTakenSickDayCountSame() {
|
|
329 |
void setTakenSickDayCount_same() {
|
|
221 | 330 |
this.user.setTotalSickDayCount(10); |
222 | 331 |
this.user.setTakenSickDayCount(10); |
223 |
assertEquals(10, this.user.getTakenSickDayCount()); |
|
332 |
assertEquals(10, this.user.getTakenSickDayCount().intValue());
|
|
224 | 333 |
} |
225 | 334 |
|
226 | 335 |
/** |
227 | 336 |
* Tests the method {@code setTakenSickDayCount} with null value. |
228 | 337 |
*/ |
229 | 338 |
@Test |
230 |
void testSetTakenSickDayCountObjectNull() {
|
|
339 |
void setTakenSickDayCount_nullInput() {
|
|
231 | 340 |
assertThrows(IllegalArgumentException.class, () -> this.user.setTakenSickDayCount(null)); |
232 | 341 |
} |
233 | 342 |
|
343 |
/** |
|
344 |
* Tests the method {@code addTakenSickDayCount} with common values where no problem should occur. |
|
345 |
*/ |
|
346 |
@Test |
|
347 |
void addTakenSickDayCount_valid() { |
|
348 |
this.user.setTotalSickDayCount(50); |
|
349 |
this.user.addTakenSickDayCount(10); |
|
350 |
assertEquals(10, this.user.getTakenSickDayCount().intValue()); |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
* Tests the method {@code addTakenSickDayCount} with common values where no problem should occur. |
|
355 |
*/ |
|
356 |
@Test |
|
357 |
void addTakenSickDayCount_add_valid() { |
|
358 |
this.user.setTotalSickDayCount(50); |
|
359 |
this.user.setTakenSickDayCount(2); |
|
360 |
this.user.addTakenSickDayCount(10); |
|
361 |
assertEquals(12f, this.user.getTakenSickDayCount().intValue()); |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
365 |
* Tests the method {@code addTakenSickDayCount} with common values where no problem should occur. |
|
366 |
*/ |
|
367 |
@Test |
|
368 |
void addTakenSickDayCount_subtract_valid() { |
|
369 |
this.user.setTotalSickDayCount(50); |
|
370 |
this.user.setTakenSickDayCount(20); |
|
371 |
this.user.addTakenSickDayCount(-10); |
|
372 |
assertEquals(10f, this.user.getTakenSickDayCount().intValue()); |
|
373 |
} |
|
374 |
|
|
375 |
/** |
|
376 |
* Tests the method {@code addTakenSickDayCount} with negative result of the operation which should throw an exception. |
|
377 |
*/ |
|
378 |
@Test |
|
379 |
void addTakenSickDayCount_negativeResult() { |
|
380 |
assertThrows(IllegalArgumentException.class, () -> this.user.addTakenSickDayCount(-10)); |
|
381 |
} |
|
382 |
|
|
383 |
/** |
|
384 |
* Tests the method {@code addTakenSickDayCount} with null value which should throw an exception. |
|
385 |
*/ |
|
386 |
@Test |
|
387 |
void addTakenSickDayCount_nullInput() { |
|
388 |
assertThrows(IllegalArgumentException.class, () -> this.user.addTakenSickDayCount(null)); |
|
389 |
} |
|
390 |
|
|
391 |
/** |
|
392 |
* Tests the method {@code addTakenSickDayCount} with a value that is greater than total sick days. |
|
393 |
*/ |
|
394 |
@Test |
|
395 |
void addTakenSickDayCount_over() { |
|
396 |
this.user.setTotalSickDayCount(10); |
|
397 |
assertThrows(IllegalArgumentException.class, () -> this.user.addTakenSickDayCount(20)); |
|
398 |
} |
|
399 |
|
|
400 |
/** |
|
401 |
* Tests the method {@code addTakenSickDayCount} with a value that is equals the total sick days. |
|
402 |
*/ |
|
403 |
@Test |
|
404 |
void addTakenSickDayCount_same() { |
|
405 |
this.user.setTotalSickDayCount(10); |
|
406 |
this.user.addTakenSickDayCount(10); |
|
407 |
assertEquals(10, this.user.getTakenSickDayCount().intValue()); |
|
408 |
} |
|
409 |
|
|
410 |
|
|
234 | 411 |
/** |
235 | 412 |
* Tests the method {@code setNotification} with common values where no problem should occur. |
236 | 413 |
*/ |
237 | 414 |
@Test |
238 |
void testSetNotification() {
|
|
415 |
void setNotification_valid() {
|
|
239 | 416 |
this.user.setNotification(LocalDateTime.of(2010,5,1,20,0)); |
240 | 417 |
assertEquals(LocalDateTime.of(2010,5,1,20,0), this.user.getNotification()); |
241 | 418 |
} |
... | ... | |
244 | 421 |
* Tests the method {@code setNotification} with null value. |
245 | 422 |
*/ |
246 | 423 |
@Test |
247 |
void testSetNotificationNull() { |
|
248 |
assertThrows(IllegalArgumentException.class, () -> this.user.setNotification(null)); |
|
424 |
void setNotification_nullInput_valid() { |
|
425 |
this.user.setNotification(null); |
|
426 |
assertNull(this.user.getNotification()); |
|
427 |
} |
|
428 |
|
|
429 |
/** |
|
430 |
* Tests the method {@code setToken} with common values where no problem should occur. |
|
431 |
*/ |
|
432 |
@Test |
|
433 |
void setToken_valid() { |
|
434 |
this.user.setToken("aaaaa"); |
|
435 |
assertEquals("aaaaa", this.user.getToken()); |
|
436 |
} |
|
437 |
|
|
438 |
/** |
|
439 |
* Tests the method {@code setToken} with null value. |
|
440 |
*/ |
|
441 |
@Test |
|
442 |
void setToken_nullInput() { |
|
443 |
assertThrows(IllegalArgumentException.class, () -> this.user.setToken(null)); |
|
249 | 444 |
} |
250 | 445 |
|
251 | 446 |
/** |
252 | 447 |
* Tests the method {@code setEmail} with common values where no problem should occur. |
253 | 448 |
*/ |
254 | 449 |
@Test |
255 |
void testSetEmail() {
|
|
450 |
void setEmail_valid() {
|
|
256 | 451 |
this.user.setEmail("aaaaaa"); |
257 | 452 |
assertEquals("aaaaaa", this.user.getEmail()); |
258 | 453 |
} |
... | ... | |
261 | 456 |
* Tests the method {@code setEmail} with the maximal length of an email address. |
262 | 457 |
*/ |
263 | 458 |
@Test |
264 |
void testSetEmailMax() {
|
|
459 |
void setEmail_maxLength() {
|
|
265 | 460 |
this.user.setEmail("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
266 | 461 |
assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", this.user.getEmail()); |
267 | 462 |
} |
... | ... | |
270 | 465 |
* Tests the method {@code setEmail} with email address that exceeds maximal length which should throw an exception. |
271 | 466 |
*/ |
272 | 467 |
@Test |
273 |
void testSetEmailException() {
|
|
468 |
void setEmail_tooLong() {
|
|
274 | 469 |
assertThrows(IllegalArgumentException.class, () -> this.user.setEmail("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
275 | 470 |
} |
276 | 471 |
|
472 |
/** |
|
473 |
* Tests the method {@code setEmail} with null value. |
|
474 |
*/ |
|
475 |
@Test |
|
476 |
void setEmail_nullInput() { |
|
477 |
assertThrows(IllegalArgumentException.class, () -> this.user.setEmail(null)); |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
* Tests the method {@code setPhoto} with common values where no problem should occur. |
|
482 |
*/ |
|
483 |
@Test |
|
484 |
void setPhoto_valid() { |
|
485 |
this.user.setPhoto("aaaaa"); |
|
486 |
assertEquals("aaaaa", this.user.getPhoto()); |
|
487 |
} |
|
488 |
|
|
489 |
/** |
|
490 |
* Tests the method {@code setPhoto} with null value. |
|
491 |
*/ |
|
492 |
@Test |
|
493 |
void setPhoto_nullInput_valid() { |
|
494 |
this.user.setPhoto(null); |
|
495 |
assertEquals("https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg", this.user.getPhoto()); |
|
496 |
} |
|
497 |
|
|
277 | 498 |
/** |
278 | 499 |
* Tests the method {@code setRole} with common values where no problem should occur. |
279 | 500 |
*/ |
280 | 501 |
@Test |
281 |
void testSetRole() {
|
|
502 |
void setRole_valid() {
|
|
282 | 503 |
this.user.setRole(UserRole.EMPLOYER); |
283 | 504 |
assertEquals(UserRole.EMPLOYER, this.user.getRole()); |
284 | 505 |
} |
... | ... | |
287 | 508 |
* Tests the method {@code setRole} with null value. |
288 | 509 |
*/ |
289 | 510 |
@Test |
290 |
void testSetRoleNull() {
|
|
511 |
void setRole_nullInput() {
|
|
291 | 512 |
assertThrows(IllegalArgumentException.class, () -> this.user.setRole(null)); |
292 | 513 |
} |
293 | 514 |
|
... | ... | |
295 | 516 |
* Tests the method {@code setStatus} with common values where no problem should occur. |
296 | 517 |
*/ |
297 | 518 |
@Test |
298 |
void testSetStatus() {
|
|
519 |
void setStatus_valid() {
|
|
299 | 520 |
this.user.setStatus(Status.ACCEPTED); |
300 | 521 |
assertEquals(Status.ACCEPTED, this.user.getStatus()); |
301 | 522 |
} |
... | ... | |
304 | 525 |
* Tests the method {@code setStatus} with null value. |
305 | 526 |
*/ |
306 | 527 |
@Test |
307 |
void testSetStatusNull() {
|
|
528 |
void setStatus_nullInput() {
|
|
308 | 529 |
assertThrows(IllegalArgumentException.class, () -> this.user.setStatus(null)); |
309 | 530 |
} |
310 | 531 |
|
... | ... | |
312 | 533 |
* Tests the method {@code takeVacation} with common values where no problem should occur. |
313 | 534 |
*/ |
314 | 535 |
@Test |
315 |
void testTakeVacation() {
|
|
536 |
void takeVacation_valid() {
|
|
316 | 537 |
this.user.setVacationCount(10f); |
317 | 538 |
this.user.takeVacation(LocalTime.of(15,0), LocalTime.of(20, 0)); |
318 |
assertEquals(5, this.user.getVacationCount()); |
|
539 |
assertEquals(5, this.user.getVacationCount().intValue());
|
|
319 | 540 |
} |
320 | 541 |
|
321 | 542 |
/** |
322 | 543 |
* Tests the method {@code takeVacation} when there is not enough vacations. |
323 | 544 |
*/ |
324 | 545 |
@Test |
325 |
void testTakeVacationException() {
|
|
546 |
void takeVacation_notEnough() {
|
|
326 | 547 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeVacation(LocalTime.of(15,0), LocalTime.of(20, 0))); |
327 | 548 |
} |
328 | 549 |
|
... | ... | |
330 | 551 |
* Tests the method {@code takeVacation} with switched from and to parameters. |
331 | 552 |
*/ |
332 | 553 |
@Test |
333 |
void testTakeVacationOrder() {
|
|
554 |
void takeVacation_order() {
|
|
334 | 555 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeVacation( LocalTime.of(20,0), LocalTime.of(10,0))); |
335 | 556 |
} |
336 | 557 |
|
... | ... | |
338 | 559 |
* Tests the method {@code takeVacation} with from argument null. |
339 | 560 |
*/ |
340 | 561 |
@Test |
341 |
void testTakeVacationNullFrom() {
|
|
562 |
void takeVacation_nullFrom() {
|
|
342 | 563 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeVacation(null, LocalTime.of(15,0))); |
343 | 564 |
} |
344 | 565 |
|
... | ... | |
346 | 567 |
* Tests the method {@code takeVacation} with to argument null. |
347 | 568 |
*/ |
348 | 569 |
@Test |
349 |
void testTakeVacationNullTo() {
|
|
570 |
void takeVacation_nullTo() {
|
|
350 | 571 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeVacation(LocalTime.of(15,0), null)); |
351 | 572 |
} |
352 | 573 |
|
... | ... | |
354 | 575 |
* Tests the method {@code takeVacation } with both arguments null. |
355 | 576 |
*/ |
356 | 577 |
@Test |
357 |
void testTakeVacationNullBoth() {
|
|
578 |
void takeVacation_nullBoth() {
|
|
358 | 579 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeVacation(null, null)); |
359 | 580 |
} |
360 | 581 |
|
... | ... | |
362 | 583 |
* Tests the method {@code takeVacation} with common values where no problem should occur. |
363 | 584 |
*/ |
364 | 585 |
@Test |
365 |
void testTakeSickDay() {
|
|
586 |
void takeSickDay_valid() {
|
|
366 | 587 |
this.user.setTotalSickDayCount(5); |
367 | 588 |
this.user.takeSickDay(); |
368 |
assertEquals(1, this.user.getTakenSickDayCount()); |
|
589 |
assertEquals(1, this.user.getTakenSickDayCount().intValue());
|
|
369 | 590 |
} |
370 | 591 |
|
371 | 592 |
/** |
372 | 593 |
* Tests the method {@code takeVacation} when there is not enough available sick days. |
373 | 594 |
*/ |
374 | 595 |
@Test |
375 |
void testTakeSickDayException() {
|
|
596 |
void takeSickDay_notEnough() {
|
|
376 | 597 |
assertThrows(IllegalArgumentException.class, () -> this.user.takeSickDay()); |
377 | 598 |
} |
378 | 599 |
|
... | ... | |
381 | 602 |
*/ |
382 | 603 |
@Test |
383 | 604 |
void testToString() { |
384 |
User user = new User(5, "Jan", "Nov\u00E1k",0f, 10, 5, LocalDateTime.of(2008,10,30,20,0), "tokenContent", "novak@email.com", "url", LocalDateTime.of(2010,7,31,12,5), UserRole.EMPLOYER, Status.ACCEPTED); |
|
605 |
User user = new User(); |
|
606 |
user.setId(5L); |
|
607 |
user.setFirstName("Jan"); |
|
608 |
user.setLastName("Nov\u00E1k"); |
|
609 |
user.setVacationCount(0f); |
|
610 |
user.setTotalSickDayCount(10); |
|
611 |
user.setTakenSickDayCount(5); |
|
612 |
user.setNotification(LocalDateTime.of(2008,10,30,20,0)); |
|
613 |
user.setToken("tokenContent"); |
|
614 |
user.setEmail("novak@email.com"); |
|
615 |
user.setPhoto("url"); |
|
616 |
user.setCreationDate(LocalDateTime.of(2010,7,31,12,5)); |
|
617 |
user.setRole(UserRole.EMPLOYER); |
|
618 |
user.setStatus(Status.ACCEPTED); |
|
385 | 619 |
assertEquals("User{id=5, firstName='Jan', lastName='Nov\u00E1k', vacationCount=0.0, totalSickDayCount=10, takenSickDayCount=5, notification=2008-10-30T20:00, token='tokenContent', email='novak@email.com', photo='url', creationDate=2010-07-31T12:05, role=EMPLOYER, status=ACCEPTED}", user.toString()); |
386 | 620 |
} |
387 | 621 |
} |
Také k dispozici: Unified diff
Final version of domain class User with tests