use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testCreateExistingAnswerPost_badRequest.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateExistingAnswerPost_badRequest() throws Exception {
AnswerPost existingAnswerPostToSave = existingAnswerPosts.get(0);
request.postWithResponseBody("/api/courses/" + courseId + "/answer-posts", existingAnswerPostToSave, AnswerPost.class, HttpStatus.BAD_REQUEST);
assertThat(existingAnswerPosts.size()).isEqualTo(answerPostRepository.count());
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testCreateAnswerPostInExercise.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateAnswerPostInExercise() throws Exception {
AnswerPost answerPostToSave = createAnswerPost(existingPostsWithAnswersInExercise.get(0));
AnswerPost createdAnswerPost = request.postWithResponseBody("/api/courses/" + courseId + "/answer-posts", answerPostToSave, AnswerPost.class, HttpStatus.CREATED);
// should not be automatically post resolving
assertThat(createdAnswerPost.doesResolvePost()).isFalse();
checkCreatedAnswerPost(answerPostToSave, createdAnswerPost);
assertThat(existingAnswerPosts.size() + 1).isEqualTo(answerPostRepository.count());
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testEditAnswerPost_asTutor.
// UPDATE
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testEditAnswerPost_asTutor() throws Exception {
// update post of student1 (index 0)--> OK
AnswerPost answerPostToUpdate = editExistingAnswerPost(existingAnswerPosts.get(0));
AnswerPost updatedAnswerPost = request.putWithResponseBody("/api/courses/" + courseId + "/answer-posts/" + answerPostToUpdate.getId(), answerPostToUpdate, AnswerPost.class, HttpStatus.OK);
assertThat(answerPostToUpdate).isEqualTo(updatedAnswerPost);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testDeleteAnswerPost_asTutor.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testDeleteAnswerPost_asTutor() throws Exception {
// delete post from another student (index 0) --> ok
AnswerPost answerPostToDelete = existingAnswerPosts.get(0);
request.delete("/api/courses/" + courseId + "/answer-posts/" + answerPostToDelete.getId(), HttpStatus.OK);
assertThat(answerPostRepository.count()).isEqualTo(existingAnswerPosts.size() - 1);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testCreateAnswerPostInExercise_asInstructor.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testCreateAnswerPostInExercise_asInstructor() throws Exception {
AnswerPost answerPostToSave = createAnswerPost(existingPostsWithAnswersInExercise.get(0));
AnswerPost createdAnswerPost = request.postWithResponseBody("/api/courses/" + courseId + "/answer-posts", answerPostToSave, AnswerPost.class, HttpStatus.CREATED);
checkCreatedAnswerPost(answerPostToSave, createdAnswerPost);
assertThat(existingAnswerPosts.size() + 1).isEqualTo(answerPostRepository.count());
}
Aggregations