Revize adaf7531
Přidáno uživatelem Pavel Fidransky před více než 4 roky(ů)
server/src/test/java/org/danekja/ymanager/domain/DefaultSettingsDTOTest.java | ||
---|---|---|
1 |
package org.danekja.ymanager.domain; |
|
2 |
|
|
3 |
import org.junit.jupiter.api.BeforeEach; |
|
4 |
import org.junit.jupiter.api.Test; |
|
5 |
|
|
6 |
import java.time.LocalDateTime; |
|
7 |
|
|
8 |
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
9 |
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
10 |
|
|
11 |
/** |
|
12 |
* This class tests methods of the {@code DefaultSettings} class. |
|
13 |
* @see DefaultSettings |
|
14 |
*/ |
|
15 |
class DefaultSettingsDTOTest { |
|
16 |
|
|
17 |
/** |
|
18 |
* The empty instance of the {@code DefaultSettings}. |
|
19 |
*/ |
|
20 |
private DefaultSettings defaultSettings; |
|
21 |
|
|
22 |
/** |
|
23 |
* Prepares the instance of the {@code DefaultSettings}. |
|
24 |
*/ |
|
25 |
@BeforeEach |
|
26 |
void setUp() { |
|
27 |
this.defaultSettings = new DefaultSettings(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* Tests the method {@code setSickDayCount} with common values where no problem should occur. |
|
32 |
*/ |
|
33 |
@Test |
|
34 |
void setSickDaysCount_valid() { |
|
35 |
this.defaultSettings.setSickDayCount(10); |
|
36 |
assertEquals(10, this.defaultSettings.getSickDayCount()); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* Tests the method {@code setSickDayCount} with zero which is a threshold value. |
|
41 |
*/ |
|
42 |
@Test |
|
43 |
void setSickDaysCount_zeroInput() { |
|
44 |
this.defaultSettings.setSickDayCount(0); |
|
45 |
assertEquals(0, this.defaultSettings.getSickDayCount()); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Tests the method {@code setSickDayCount} with negative one which is a threshold value. |
|
50 |
*/ |
|
51 |
@Test |
|
52 |
void setSickDaysCount_negativeOneInput() { |
|
53 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(-1)); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Tests the method {@code setSickDayCount} with negative value. |
|
58 |
*/ |
|
59 |
@Test |
|
60 |
void setSickDaysCount_negativeInput() { |
|
61 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(-10)); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Tests the method {@code setSickDayCount} with null value. |
|
66 |
*/ |
|
67 |
@Test |
|
68 |
void setSickDaysCount_nullInput() { |
|
69 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(null)); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Tests the method {@code setNotification} with common values where no problem should occur. |
|
74 |
*/ |
|
75 |
@Test |
|
76 |
void setNotification_valid() { |
|
77 |
this.defaultSettings.setNotification(LocalDateTime.of(2010,5,1,20,0)); |
|
78 |
assertEquals(LocalDateTime.of(2010,5,1,20,0), this.defaultSettings.getNotification()); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Tests the method {@code setNotification} with null value. |
|
83 |
*/ |
|
84 |
@Test |
|
85 |
void setNotification_nullInput() { |
|
86 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setNotification(null)); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Tests the method {@code toString}. |
|
91 |
*/ |
|
92 |
@Test |
|
93 |
void testToString() { |
|
94 |
DefaultSettings defaultSettings = new DefaultSettings(); |
|
95 |
defaultSettings.setId(5L); |
|
96 |
defaultSettings.setSickDayCount(1); |
|
97 |
defaultSettings.setNotification(LocalDateTime.of(2008,10,30,20,0)); |
|
98 |
assertEquals("DefaultSettings{id=5, sickDayCount=1, notification=2008-10-30T20:00}", defaultSettings.toString()); |
|
99 |
} |
|
100 |
} |
server/src/test/java/org/danekja/ymanager/domain/DefaultSettingsTest.java | ||
---|---|---|
1 |
package org.danekja.ymanager.domain; |
|
2 |
|
|
3 |
import org.junit.jupiter.api.BeforeEach; |
|
4 |
import org.junit.jupiter.api.Test; |
|
5 |
|
|
6 |
import java.time.LocalDateTime; |
|
7 |
|
|
8 |
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
9 |
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
10 |
|
|
11 |
/** |
|
12 |
* This class tests methods of the {@link DefaultSettings} class. |
|
13 |
*/ |
|
14 |
class DefaultSettingsTest { |
|
15 |
|
|
16 |
/** |
|
17 |
* The empty instance of the {@code DefaultSettings}. |
|
18 |
*/ |
|
19 |
private DefaultSettings defaultSettings; |
|
20 |
|
|
21 |
/** |
|
22 |
* Prepares the instance of the {@code DefaultSettings}. |
|
23 |
*/ |
|
24 |
@BeforeEach |
|
25 |
void setUp() { |
|
26 |
this.defaultSettings = new DefaultSettings(); |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Tests the method {@code setSickDayCount} with common values where no problem should occur. |
|
31 |
*/ |
|
32 |
@Test |
|
33 |
void setSickDaysCount_valid() { |
|
34 |
this.defaultSettings.setSickDayCount(10); |
|
35 |
assertEquals(10, this.defaultSettings.getSickDayCount()); |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* Tests the method {@code setSickDayCount} with zero which is a threshold value. |
|
40 |
*/ |
|
41 |
@Test |
|
42 |
void setSickDaysCount_zeroInput() { |
|
43 |
this.defaultSettings.setSickDayCount(0); |
|
44 |
assertEquals(0, this.defaultSettings.getSickDayCount()); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Tests the method {@code setSickDayCount} with negative one which is a threshold value. |
|
49 |
*/ |
|
50 |
@Test |
|
51 |
void setSickDaysCount_negativeOneInput() { |
|
52 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(-1)); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Tests the method {@code setSickDayCount} with negative value. |
|
57 |
*/ |
|
58 |
@Test |
|
59 |
void setSickDaysCount_negativeInput() { |
|
60 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(-10)); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Tests the method {@code setSickDayCount} with null value. |
|
65 |
*/ |
|
66 |
@Test |
|
67 |
void setSickDaysCount_nullInput() { |
|
68 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setSickDayCount(null)); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Tests the method {@code setNotification} with common values where no problem should occur. |
|
73 |
*/ |
|
74 |
@Test |
|
75 |
void setNotification_valid() { |
|
76 |
this.defaultSettings.setNotification(LocalDateTime.of(2010,5,1,20,0)); |
|
77 |
assertEquals(LocalDateTime.of(2010,5,1,20,0), this.defaultSettings.getNotification()); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Tests the method {@code setNotification} with null value. |
|
82 |
*/ |
|
83 |
@Test |
|
84 |
void setNotification_nullInput() { |
|
85 |
assertThrows(IllegalArgumentException.class, () -> this.defaultSettings.setNotification(null)); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Tests the method {@code toString}. |
|
90 |
*/ |
|
91 |
@Test |
|
92 |
void testToString() { |
|
93 |
DefaultSettings defaultSettings = new DefaultSettings(); |
|
94 |
defaultSettings.setId(5L); |
|
95 |
defaultSettings.setSickDayCount(1); |
|
96 |
defaultSettings.setNotification(LocalDateTime.of(2008,10,30,20,0)); |
|
97 |
assertEquals("DefaultSettings{id=5, sickDayCount=1, notification=2008-10-30T20:00}", defaultSettings.toString()); |
|
98 |
} |
|
99 |
} |
server/src/test/java/org/danekja/ymanager/dto/DefaultSettingsDTOTest.java | ||
---|---|---|
1 |
package org.danekja.ymanager.dto; |
|
2 |
|
|
3 |
import org.danekja.ymanager.domain.DefaultSettings; |
|
4 |
import org.junit.jupiter.api.Test; |
|
5 |
|
|
6 |
import java.time.LocalDateTime; |
|
7 |
|
|
8 |
import static org.junit.Assert.assertEquals; |
|
9 |
import static org.junit.Assert.assertNull; |
|
10 |
|
|
11 |
/** |
|
12 |
* Unit tests of {@link DefaultSettingsDTO}. |
|
13 |
*/ |
|
14 |
class DefaultSettingsDTOTest { |
|
15 |
@Test |
|
16 |
void constructor_noArguments() { |
|
17 |
DefaultSettingsDTO defaultSettingsDTO = new DefaultSettingsDTO(); |
|
18 |
|
|
19 |
assertNull(defaultSettingsDTO.getNotification()); |
|
20 |
assertNull(defaultSettingsDTO.getSickDayCount()); |
|
21 |
} |
|
22 |
|
|
23 |
@Test |
|
24 |
void constructor_properties() { |
|
25 |
DefaultSettingsDTO defaultSettingsDTO = new DefaultSettingsDTO(5, LocalDateTime.MAX); |
|
26 |
|
|
27 |
assertEquals(5, (int) defaultSettingsDTO.getSickDayCount()); |
|
28 |
assertEquals(LocalDateTime.MAX, defaultSettingsDTO.getNotification()); |
|
29 |
} |
|
30 |
|
|
31 |
@Test |
|
32 |
void constructor_domainObject() { |
|
33 |
DefaultSettings defaultSettings = new DefaultSettings(5, LocalDateTime.MAX); |
|
34 |
DefaultSettingsDTO defaultSettingsDTO = new DefaultSettingsDTO(defaultSettings); |
|
35 |
|
|
36 |
assertEquals(5, (int) defaultSettingsDTO.getSickDayCount()); |
|
37 |
assertEquals(LocalDateTime.MAX, defaultSettingsDTO.getNotification()); |
|
38 |
} |
|
39 |
|
|
40 |
@Test |
|
41 |
void toEntity() { |
|
42 |
DefaultSettingsDTO defaultSettingsDTO = new DefaultSettingsDTO(5, LocalDateTime.MAX); |
|
43 |
DefaultSettings defaultSettings = defaultSettingsDTO.toEntity(); |
|
44 |
|
|
45 |
assertEquals(5, defaultSettings.getSickDayCount()); |
|
46 |
assertEquals(LocalDateTime.MAX, defaultSettings.getNotification()); |
|
47 |
} |
|
48 |
} |
Také k dispozici: Unified diff
re #42 add tests of DefaultSettingsDTO