use of de.tum.in.www1.artemis.domain.hestia.ExerciseHint in project ArTEMiS by ls1intum.
the class ExerciseHintIntegrationTest method updateHintAsInstructor.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updateHintAsInstructor() throws Exception {
ExerciseHint exerciseHint = exerciseHintRepository.findAll().get(0);
String newContent = "new content value!";
exerciseHint.setContent(newContent);
request.put("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + exerciseHint.getId(), exerciseHint, HttpStatus.OK);
Optional<ExerciseHint> hintAfterSave = exerciseHintRepository.findById(exerciseHint.getId());
assertThat(hintAfterSave).isPresent();
assertThat(hintAfterSave.get()).isInstanceOf(ExerciseHint.class);
assertThat((hintAfterSave.get()).getContent()).isEqualTo(newContent);
}
use of de.tum.in.www1.artemis.domain.hestia.ExerciseHint in project ArTEMiS by ls1intum.
the class ExerciseHintIntegrationTest method updateCodeHintTitle.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updateCodeHintTitle() throws Exception {
CodeHint codeHint = new CodeHint();
codeHint.setTitle("Hint 1");
codeHint.setExercise(exerciseLite);
exerciseHintRepository.save(codeHint);
codeHint.setTitle("New Title");
request.put("/api/programming-exercises/" + codeHint.getExercise().getId() + "/exercise-hints/" + codeHint.getId(), codeHint, HttpStatus.OK);
Optional<ExerciseHint> hintAfterSave = exerciseHintRepository.findById(codeHint.getId());
assertThat(hintAfterSave).isPresent();
assertThat(hintAfterSave.get()).isInstanceOf(CodeHint.class);
assertThat((hintAfterSave.get()).getTitle()).isEqualTo("New Title");
}
use of de.tum.in.www1.artemis.domain.hestia.ExerciseHint in project ArTEMiS by ls1intum.
the class ExerciseHintIntegrationTest method updateHintForbidden.
private void updateHintForbidden() throws Exception {
ExerciseHint exerciseHint = exerciseHintRepository.findAll().get(0);
String newContent = "new content value!";
String contentBefore = exerciseHint.getContent();
exerciseHint.setContent(newContent);
request.put("/api/programming-exercises/" + exerciseHint.getExercise().getId() + "/exercise-hints/" + exerciseHint.getId(), exerciseHint, HttpStatus.FORBIDDEN);
Optional<ExerciseHint> hintAfterSave = exerciseHintRepository.findById(exerciseHint.getId());
assertThat(hintAfterSave).isPresent();
assertThat(hintAfterSave.get()).isInstanceOf(ExerciseHint.class);
assertThat((hintAfterSave.get()).getContent()).isEqualTo(contentBefore);
}
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);
}
use of de.tum.in.www1.artemis.domain.hestia.ExerciseHint in project ArTEMiS by ls1intum.
the class ExerciseHintIntegrationTest method createHintWithInvalidExerciseIds.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createHintWithInvalidExerciseIds() throws Exception {
Course course = database.addCourseWithOneProgrammingExercise();
var unrelatedExercise = course.getExercises().stream().findFirst().orElseThrow();
ExerciseHint exerciseHint = new ExerciseHint();
exerciseHint.setTitle("Test Title");
exerciseHint.setExercise(exerciseLite);
request.post("/api/programming-exercises/" + unrelatedExercise.getId() + "/exercise-hints", exerciseHint, HttpStatus.CONFLICT);
}
Aggregations