Search in sources :

Example 11 with TeamAssignmentPayload

use of de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload in project Artemis by ls1intum.

the class TeamWebsocketServiceTest method testSendTeamAssignmentUpdateOnRemoveStudentFromTeam.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
void testSendTeamAssignmentUpdateOnRemoveStudentFromTeam() throws Exception {
    Team team = new Team().name("Team").shortName("team").exercise(modelingExercise).students(students);
    team = request.postWithResponseBody(teamResourceUrl(), team, Team.class, HttpStatus.CREATED);
    User studentToRemoveFromTeam = students.iterator().next();
    Team updatedTeam = new Team(team).id(team.getId()).removeStudents(studentToRemoveFromTeam);
    request.putWithResponseBody(teamResourceUrl() + "/" + updatedTeam.getId(), updatedTeam, Team.class, HttpStatus.OK);
    TeamAssignmentPayload expectedPayload = new TeamAssignmentPayload(modelingExercise, null);
    verify(messagingTemplate).convertAndSendToUser(studentToRemoveFromTeam.getLogin(), assignmentTopic, expectedPayload);
}
Also used : WithMockUser(org.springframework.security.test.context.support.WithMockUser) TeamAssignmentPayload(de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 12 with TeamAssignmentPayload

use of de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload in project Artemis by ls1intum.

the class TeamWebsocketServiceTest method testSendTeamAssignmentUpdateOnAddStudentToTeam.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
void testSendTeamAssignmentUpdateOnAddStudentToTeam() throws Exception {
    Team team = new Team().name("Team").shortName("team").exercise(modelingExercise);
    team = request.postWithResponseBody(teamResourceUrl(), team, Team.class, HttpStatus.CREATED);
    Team updatedTeam = new Team(team).id(team.getId()).students(students);
    updatedTeam = request.putWithResponseBody(teamResourceUrl() + "/" + updatedTeam.getId(), updatedTeam, Team.class, HttpStatus.OK);
    TeamAssignmentPayload expectedPayload = new TeamAssignmentPayload(modelingExercise, updatedTeam);
    team.getStudents().forEach(user -> verify(messagingTemplate).convertAndSendToUser(user.getLogin(), assignmentTopic, expectedPayload));
}
Also used : TeamAssignmentPayload(de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Aggregations

TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)12 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)10 Test (org.junit.jupiter.api.Test)10 WithMockUser (org.springframework.security.test.context.support.WithMockUser)10 Team (de.tum.in.www1.artemis.domain.Team)2 User (de.tum.in.www1.artemis.domain.User)2