Search in sources :

Example 21 with ExerciseHint

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

the class ExerciseHintIntegrationTest method deleteHintAsInstructor.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void deleteHintAsInstructor() throws Exception {
    ExerciseHint exerciseHint = new ExerciseHint().content("content 4").title("title 4").exercise(exerciseLite);
    request.delete("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + 0L, HttpStatus.NOT_FOUND);
    request.post("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints", exerciseHint, HttpStatus.CREATED);
    List<ExerciseHint> exerciseHints = exerciseHintRepository.findAll();
    request.delete("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + exerciseHints.get(0).getId(), HttpStatus.NO_CONTENT);
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 22 with ExerciseHint

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

the class ExerciseHintIntegrationTest method getHintForAnExerciseAsAnInstructor.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getHintForAnExerciseAsAnInstructor() throws Exception {
    ExerciseHint exerciseHint = exerciseHintRepository.findAll().get(0);
    request.get("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + exerciseHint.getId(), HttpStatus.OK, ExerciseHint.class);
    request.get("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + 0L, HttpStatus.NOT_FOUND, ExerciseHint.class);
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 23 with ExerciseHint

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

the class ExerciseHintIntegrationTest method deleteHintWithInvalidExerciseIds.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void deleteHintWithInvalidExerciseIds() throws Exception {
    Course course = database.addCourseWithOneProgrammingExercise();
    var unrelatedExercise = course.getExercises().stream().findFirst().orElseThrow();
    ExerciseHint exerciseHint = exerciseHintRepository.findAll().get(0);
    request.delete("/api/programming-exercises/" + unrelatedExercise.getId() + "/exercise-hints/" + exerciseHint.getId(), HttpStatus.CONFLICT);
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 24 with ExerciseHint

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

the class ExerciseHintIntegrationTest method updateHintWithInvalidExerciseIds.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updateHintWithInvalidExerciseIds() throws Exception {
    Course course = database.addCourseWithOneProgrammingExercise();
    var unrelatedExercise = course.getExercises().stream().findFirst().orElseThrow();
    ExerciseHint exerciseHint = exerciseHintRepository.findAll().get(0);
    exerciseHint.setTitle("New Title");
    request.put("/api/programming-exercises/" + unrelatedExercise.getId() + "/exercise-hints/" + exerciseHint.getId(), exerciseHint, HttpStatus.CONFLICT);
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 25 with ExerciseHint

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

the class ExerciseHintIntegrationTest method createHintAsTutorForbidden.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void createHintAsTutorForbidden() throws Exception {
    ExerciseHint exerciseHint = new ExerciseHint().content("content 4").title("title 4").exercise(exerciseLite);
    request.post("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/", exerciseHint, HttpStatus.FORBIDDEN);
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Aggregations

ExerciseHint (de.tum.in.www1.artemis.domain.hestia.ExerciseHint)52 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)38 Test (org.junit.jupiter.api.Test)38 WithMockUser (org.springframework.security.test.context.support.WithMockUser)38 ProgrammingExercise (de.tum.in.www1.artemis.domain.ProgrammingExercise)14 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 CodeHint (de.tum.in.www1.artemis.domain.hestia.CodeHint)10 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)8 ConflictException (de.tum.in.www1.artemis.web.rest.errors.ConflictException)8 AccessForbiddenException (de.tum.in.www1.artemis.web.rest.errors.AccessForbiddenException)6 Exercise (de.tum.in.www1.artemis.domain.Exercise)4 Feedback (de.tum.in.www1.artemis.domain.Feedback)2 Submission (de.tum.in.www1.artemis.domain.Submission)2 User (de.tum.in.www1.artemis.domain.User)2 ExerciseHintActivation (de.tum.in.www1.artemis.domain.hestia.ExerciseHintActivation)2 ProgrammingExerciseTask (de.tum.in.www1.artemis.domain.hestia.ProgrammingExerciseTask)2 StudentParticipationRepository (de.tum.in.www1.artemis.repository.StudentParticipationRepository)2 ExerciseHintActivationRepository (de.tum.in.www1.artemis.repository.hestia.ExerciseHintActivationRepository)2 ExerciseHintRepository (de.tum.in.www1.artemis.repository.hestia.ExerciseHintRepository)2 Role (de.tum.in.www1.artemis.security.Role)2