Search in sources :

Example 46 with ParticipantScore

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

the class ResultListenerIntegrationTest method saveRatedResult_then_saveAnotherUnratedResult_then_removeRatedResult_ShouldUpdateOriginalStudentScore.

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveRatedResult_then_saveAnotherUnratedResult_then_removeRatedResult_ShouldUpdateOriginalStudentScore(boolean isTeamTest) {
    ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(true, isTeamTest);
    Result originalResult = originalParticipantScore.getLastResult();
    // creating a new rated result should trigger the entity listener and update the student score BUT only the not rated part
    Result newResult = createNewResult(isTeamTest, false);
    verifyStructureOfParticipantScoreInDatabase(isTeamTest, newResult.getId(), newResult.getScore(), originalResult.getId(), originalResult.getScore());
    resultRepository.deleteById(originalResult.getId());
    List<Result> savedResults = resultRepository.findAll();
    assertThat(savedResults).hasSize(1);
    verifyStructureOfParticipantScoreInDatabase(isTeamTest, newResult.getId(), newResult.getScore(), null, null);
}
Also used : ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 47 with ParticipantScore

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

the class ResultListenerIntegrationTest method saveUnratedResult_then_saveAnotherRatedResult_thenRemoveSecondResult_ShouldUpdateStudentScore.

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveUnratedResult_then_saveAnotherRatedResult_thenRemoveSecondResult_ShouldUpdateStudentScore(boolean isTeamTest) {
    ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(false, isTeamTest);
    Result originalResult = originalParticipantScore.getLastResult();
    // creating a new rated result should trigger the entity listener and update the student score BUT only the not rated part
    Result newResult = createNewResult(isTeamTest, true);
    verifyStructureOfParticipantScoreInDatabase(isTeamTest, newResult.getId(), newResult.getScore(), newResult.getId(), newResult.getScore());
    resultRepository.deleteById(newResult.getId());
    List<Result> savedResults = resultRepository.findAll();
    assertThat(savedResults).hasSize(1);
    verifyStructureOfParticipantScoreInDatabase(isTeamTest, originalResult.getId(), originalResult.getScore(), null, null);
}
Also used : ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with ParticipantScore

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

the class ResultListenerIntegrationTest method saveRatedResult_then_saveAnotherUnratedResult_ShouldUpdateOriginalStudentScore.

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveRatedResult_then_saveAnotherUnratedResult_ShouldUpdateOriginalStudentScore(boolean isTeamTest) {
    ParticipantScore originalStudentScore = setupTestScenarioWithOneResultSaved(true, isTeamTest);
    Result originalResult = originalStudentScore.getLastResult();
    // creating a new rated result should trigger the entity listener and update the student score BUT only the not rated part
    Result newResult = createNewResult(isTeamTest, false);
    verifyStructureOfParticipantScoreInDatabase(isTeamTest, newResult.getId(), newResult.getScore(), originalResult.getId(), originalResult.getScore());
}
Also used : ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParticipantScore (de.tum.in.www1.artemis.domain.scores.ParticipantScore)40 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)28 ValueSource (org.junit.jupiter.params.provider.ValueSource)28 WithMockUser (org.springframework.security.test.context.support.WithMockUser)28 StudentScore (de.tum.in.www1.artemis.domain.scores.StudentScore)14 TeamScore (de.tum.in.www1.artemis.domain.scores.TeamScore)10 Participant (de.tum.in.www1.artemis.domain.participation.Participant)4 Transactional (org.springframework.transaction.annotation.Transactional)4 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)2 ExerciseScoresAggregatedInformation (de.tum.in.www1.artemis.web.rest.dto.ExerciseScoresAggregatedInformation)2 ExerciseScoresDTO (de.tum.in.www1.artemis.web.rest.dto.ExerciseScoresDTO)2 Authentication (org.springframework.security.core.Authentication)2