Skip to content

Commit

Permalink
achieve 100 line coverage for feature
Browse files Browse the repository at this point in the history
  • Loading branch information
janthoXO committed Jan 31, 2025
1 parent a31d414 commit 55cda7f
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -317,6 +318,34 @@ void testGetProgrammingExerciseByProjectKeyWithParticipationSubmissionAndResult(

}

@Test
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
void testGetProgrammingExerciseByProjectKeyNotFound() throws Exception {
Course course = courseUtilService.createCourseWithUserPrefix(TEST_PREFIX);
ProgrammingExercise programmingExercise = programmingExerciseUtilService.addProgrammingExerciseToCourse(course);

String projectKey;
List<ProgrammingExercise> foundProgrammingExercises;
do {
projectKey = UUID.randomUUID().toString();
foundProgrammingExercises = programmingExerciseRepository.findAllByProjectKey(projectKey);
}
while (!foundProgrammingExercises.isEmpty());

String body = request.get("/api/programming-exercises/project-key/" + projectKey, HttpStatus.NOT_FOUND, String.class);
}

@Test
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
void testGetProgrammingExerciseByProjectKeyNotVisible() throws Exception {
Course course = courseUtilService.createCourseWithUserPrefix(TEST_PREFIX);
ProgrammingExercise programmingExercise = programmingExerciseUtilService.addProgrammingExerciseToCourse(course);
programmingExercise.setReleaseDate(ZonedDateTime.now().plusHours(2));
programmingExercise = programmingExerciseRepository.save(programmingExercise);

String body = request.get("/api/programming-exercises/project-key/" + programmingExercise.getProjectKey(), HttpStatus.FORBIDDEN, String.class);
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testDeleteProgrammingExerciseChannel() throws Exception {
Expand Down

0 comments on commit 55cda7f

Please sign in to comment.