Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Strohgelaender committed Oct 10, 2023
1 parent 4ef6376 commit af313a8
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

View check run for this annotation

Teamscale / teamscale-findings

src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingSubmissionIntegrationTest.java#L521

[New] Method `testNotifyPush_studentCommitUpdatesSubmissionCount` violates naming convention. Should be one of `[a-z][a-zA-Z0-9]*` https://teamscale.io/findings.html#details/GitHub-ls1intum-Artemis?t=fix%2Flong-feedback-fetch%3AHEAD&id=7112B6CD5147C6370E9B03B936007EBA
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 {
Expand Down

0 comments on commit af313a8

Please sign in to comment.