-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ef6376
commit af313a8
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,6 +516,36 @@ void testNotifyPush_isSetupCommit() throws Exception { | |
|
||
} | ||
|
||
@Test | ||
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") | ||
void testNotifyPush_studentCommitUpdatesSubmissionCount() throws Exception { | ||
Check warning on line 521 in src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingSubmissionIntegrationTest.java Teamscale / teamscale-findingssrc/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingSubmissionIntegrationTest.java#L521
|
||
var participation = participationUtilService.addStudentParticipationForProgrammingExercise(exercise, TEST_PREFIX + "student1"); | ||
|
||
Commit mockCommit = mock(Commit.class); | ||
doReturn(mockCommit).when(versionControlService).getLastCommitDetails(any()); | ||
doReturn("default-branch").when(versionControlService).getDefaultBranchOfRepository(any()); | ||
|
||
doReturn("hash1").when(mockCommit).getCommitHash(); | ||
doReturn("default-branch").when(mockCommit).getBranch(); | ||
doReturn("Student 1").when(mockCommit).getAuthorName(); | ||
doReturn("[email protected]").when(mockCommit).getAuthorEmail(); | ||
doReturn("my nice little solution").when(mockCommit).getMessage(); | ||
|
||
String url = "/api/public/programming-submissions/" + participation.getId(); | ||
// no request body needed since the commit information are mocked above | ||
request.postWithoutLocation(url, "test", HttpStatus.OK, null); | ||
|
||
verify(websocketMessagingService, timeout(2000)).sendMessageToUser(eq(TEST_PREFIX + "student1"), eq(NEW_SUBMISSION_TOPIC), | ||
argThat(arg -> arg instanceof SubmissionDTO submissionDTO && submissionDTO.participation().submissionCount() == 1)); | ||
|
||
// second push | ||
doReturn("hash2").when(mockCommit).getCommitHash(); | ||
request.postWithoutLocation(url, "test", HttpStatus.OK, null); | ||
|
||
verify(websocketMessagingService, timeout(2000)).sendMessageToUser(eq(TEST_PREFIX + "student1"), eq(NEW_SUBMISSION_TOPIC), | ||
argThat(arg -> arg instanceof SubmissionDTO submissionDTO && submissionDTO.participation().submissionCount() == 2)); | ||
} | ||
|
||
@Test | ||
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") | ||
void getAllProgrammingSubmissionsAsInstructorAllSubmissionsReturned() throws Exception { | ||
|