Skip to content

Commit e2b8421

Browse files
committed
add tests for CourseSectionBlockWip
1 parent e039d69 commit e2b8421

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

ucst-core/src/test/java/com/dvf/ucst/core/courseutils/CourseSectionBlockTest.java

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import com.dvf.ucst.core.courseutils.CourseSectionBlock.BlockTimeEnclosure;
44
import com.dvf.ucst.core.courseutils.CourseSectionBlock.IllegalTimeEnclosureException;
55
import com.dvf.ucst.core.courseutils.UbcTimeUtils.BlockTime;
6+
import com.dvf.ucst.core.spider.CourseWip.CourseSectionWip.CourseSectionBlockWip;
7+
import com.dvf.ucst.utils.general.WorkInProgress;
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Nested;
610
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.function.ThrowingSupplier;
712

813
import java.util.ArrayList;
914
import java.util.List;
@@ -15,10 +20,59 @@
1520

1621
class CourseSectionBlockTest {
1722

23+
@Test
24+
void test() {
25+
26+
}
27+
28+
29+
30+
/**
31+
*
32+
*/
33+
@Nested
34+
final class CourseSectionBlockWipTest {
35+
36+
@Test
37+
void makeWip() {
38+
final CourseSectionBlockWip blockWip = new CourseSectionBlockWip()
39+
.setBeginTime(T0800)
40+
.setEndTime(T0900)
41+
.setRepetitionType(CourseSectionBlock.BlockRepetition.EVERY_WEEK)
42+
.setWeekDay(CourseUtils.WeekDay.MONDAY);
43+
final Set<ThrowingSupplier<Object>> getters = Set.of(
44+
blockWip::getBeginTime,
45+
blockWip::getEndTime,
46+
blockWip::getRepetitionType,
47+
blockWip::getWeekDay
48+
);
49+
getters.forEach(Assertions::assertDoesNotThrow);
50+
}
51+
52+
@Test
53+
void assertThrowsIncomplete() {
54+
// make a block wip and don't populate its fields:
55+
final CourseSectionBlockWip blockWip = new CourseSectionBlockWip();
56+
final Set<ThrowingSupplier<Object>> getters = Set.of(
57+
blockWip::getBeginTime,
58+
blockWip::getEndTime,
59+
blockWip::getRepetitionType,
60+
blockWip::getWeekDay
61+
);
62+
getters.forEach(getter -> assertThrows(
63+
WorkInProgress.IncompleteWipException.class,
64+
getter::get
65+
));
66+
}
67+
}
68+
69+
70+
1871
/**
1972
* Tests for the private class [BlockTimeEnclosure]
2073
*/
21-
static final class BlockTimeEnclosureTest {
74+
@Nested
75+
final class BlockTimeEnclosureTest {
2276

2377
@Test
2478
void assertNoOverlaps() {
@@ -115,7 +169,7 @@ void assertIllegalEnclosure() {
115169
}
116170

117171
// for sake of brevity:
118-
private static BlockTimeEnclosure bte(
172+
private BlockTimeEnclosure bte(
119173
final BlockTime begin,
120174
final BlockTime end
121175
) throws IllegalTimeEnclosureException {

0 commit comments

Comments
 (0)