Search in sources :

Example 21 with Team

use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.

the class TeamImportIntegrationTest method testImportTeamsIntoExerciseWithConflictsUsingPurgeExistingStrategy.

private void testImportTeamsIntoExerciseWithConflictsUsingPurgeExistingStrategy(ImportType type, List<Team> body, List<Team> addedTeams) throws Exception {
    TeamImportStrategyType strategyType = TeamImportStrategyType.PURGE_EXISTING;
    database.addTeamsForExercise(destinationExercise, "sameShortName", 2, tutor);
    // imported source teams = destination teams after
    testImportTeamsIntoExercise(type, strategyType, body, addedTeams);
}
Also used : TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)

Example 22 with Team

use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.

the class TeamImportIntegrationTest method testImportTeamsIntoExercise.

private void testImportTeamsIntoExercise(ImportType type, TeamImportStrategyType importStrategyType, List<Team> body, List<Team> addedTeams) throws Exception {
    TeamImportStrategyType importStrategy = TeamImportStrategyType.CREATE_ONLY;
    if (importStrategyType != null) {
        importStrategy = importStrategyType;
    }
    String url = importFromSourceExerciseUrl(importStrategy);
    if (type == ImportType.FROM_LIST) {
        url = importFromListUrl(importStrategy);
    }
    List<Team> destinationTeamsAfter = request.putWithResponseBodyList(url, body, Team.class, HttpStatus.OK);
    assertCorrectnessOfImport(addedTeams, destinationTeamsAfter);
}
Also used : TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)

Example 23 with Team

use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.

the class TeamImportIntegrationTest method getTeamsIntoOneIdentifierTeams.

private List<Team> getTeamsIntoOneIdentifierTeams(List<Team> teams, String identifier) {
    return teams.stream().map(team -> {
        Team newTeam = new Team();
        newTeam.setName(team.getName());
        newTeam.setShortName(team.getShortName());
        newTeam.setOwner(team.getOwner());
        List<User> newStudents = team.getStudents().stream().map(student -> {
            User newStudent = new User();
            newStudent.setFirstName(student.getFirstName());
            newStudent.setLastName(student.getLastName());
            if ("login".equals(identifier)) {
                newStudent.setLogin(student.getLogin());
            } else if ("registrationNumber".equals(identifier)) {
                newStudent.setVisibleRegistrationNumber(student.getRegistrationNumber());
            }
            return newStudent;
        }).toList();
        newTeam.setStudents(new HashSet<>(newStudents));
        return newTeam;
    }).collect(Collectors.toList());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) java.util(java.util) TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ExerciseMode(de.tum.in.www1.artemis.domain.enumeration.ExerciseMode) Autowired(org.springframework.beans.factory.annotation.Autowired) EnumSource(org.junit.jupiter.params.provider.EnumSource) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Pair(org.springframework.data.util.Pair) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) WithMockUser(org.springframework.security.test.context.support.WithMockUser)

Example 24 with Team

use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.

the class TeamImportIntegrationTest method testImportTeamsIntoExerciseWithTeamShortNameConflictsUsingCreateOnlyStrategy.

private void testImportTeamsIntoExerciseWithTeamShortNameConflictsUsingCreateOnlyStrategy(ImportType type, List<Team> body, List<Team> teamsWithoutConflict) throws Exception {
    TeamImportStrategyType strategyType = TeamImportStrategyType.CREATE_ONLY;
    List<Team> destinationTeamsBefore = database.addTeamsForExercise(destinationExercise, "sameShortName", 3, tutor);
    // destination teams before + conflict-free source teams = destination teams after
    testImportTeamsIntoExercise(type, strategyType, body, addLists(destinationTeamsBefore, teamsWithoutConflict));
}
Also used : TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)

Example 25 with Team

use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.

the class TeamImportIntegrationTest method testImportTeamsIntoExerciseWithNoConflictsUsingCreateOnlyStrategy.

private void testImportTeamsIntoExerciseWithNoConflictsUsingCreateOnlyStrategy(ImportType type, List<Team> body, List<Team> addedTeams) throws Exception {
    TeamImportStrategyType strategyType = TeamImportStrategyType.CREATE_ONLY;
    List<Team> destinationTeamsBefore = database.addTeamsForExercise(destinationExercise, 1, tutor);
    // destination teams before + source teams = destination teams after
    testImportTeamsIntoExercise(type, strategyType, body, addLists(destinationTeamsBefore, addedTeams));
}
Also used : TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)

Aggregations

WithMockUser (org.springframework.security.test.context.support.WithMockUser)34 Test (org.junit.jupiter.api.Test)32 TeamImportStrategyType (de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)14 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)12 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)12 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)10 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)10 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)8 ExerciseMode (de.tum.in.www1.artemis.domain.enumeration.ExerciseMode)8 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)8 ZonedDateTime (java.time.ZonedDateTime)8 java.util (java.util)8 Collectors (java.util.stream.Collectors)8 Stream (java.util.stream.Stream)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 TeamSearchUserDTO (de.tum.in.www1.artemis.service.dto.TeamSearchUserDTO)6 ModelFactory (de.tum.in.www1.artemis.util.ModelFactory)6 CourseLearningGoalProgress (de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6