Skip to content

Commit d08d1a3

Browse files
Increased test coverage to effectively 100%
1 parent 964bb53 commit d08d1a3

File tree

3 files changed

+214
-110
lines changed

3 files changed

+214
-110
lines changed

src/main/java/de/tum/cit/aet/artemis/exam/domain/Exam.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,25 +444,25 @@ public void setExamArchivePath(String examArchivePath) {
444444
/**
445445
* check if students are allowed to see this exam
446446
*
447-
* @return true, if students are allowed to see this exam, otherwise false, null if this cannot be determined
447+
* @return true, if students are allowed to see this exam, otherwise false
448448
*/
449449
@JsonIgnore
450-
public Boolean isVisibleToStudents() throws IllegalStateException {
450+
public boolean isVisibleToStudents() {
451451
if (visibleDate == null) { // no visible date means the exam is configured wrongly and should not be visible!
452-
throw new IllegalStateException("The exam " + this.title + " has no visible date set!");
452+
return false;
453453
}
454454
return visibleDate.isBefore(ZonedDateTime.now());
455455
}
456456

457457
/**
458458
* check if the exam has started
459459
*
460-
* @return true, if the exam has started, otherwise false, null if this cannot be determined
460+
* @return true, if the exam has started, otherwise false
461461
*/
462462
@JsonIgnore
463-
public Boolean isStarted() throws IllegalStateException {
463+
public boolean isStarted() {
464464
if (startDate == null) { // no start date means the exam is configured wrongly and we cannot answer the question!
465-
throw new IllegalStateException("The exam " + this.title + " has no start date set!");
465+
return false;
466466
}
467467
return startDate.isBefore(ZonedDateTime.now());
468468
}
@@ -473,7 +473,7 @@ public Boolean isStarted() throws IllegalStateException {
473473
* @return true, if the results are published, false if not published or not set!
474474
*/
475475
@JsonIgnore
476-
public Boolean resultsPublished() {
476+
public boolean resultsPublished() {
477477
if (publishResultsDate == null) {
478478
return false;
479479
}

src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ default Exam findWithExerciseGroupsAndExercisesAndDetailsByIdOrElseThrow(long ex
468468
* @return only the visible exams
469469
*/
470470
default Set<Exam> filterVisibleExams(Set<Exam> exams) {
471-
return exams.stream().filter(exam -> Boolean.TRUE.equals(exam.isVisibleToStudents())).collect(Collectors.toSet());
471+
return exams.stream().filter(Exam::isVisibleToStudents).collect(Collectors.toSet());
472472
}
473473

474474
/**

0 commit comments

Comments
 (0)