use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testCreateAnswerPostCourseWide.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateAnswerPostCourseWide() throws Exception {
AnswerPost answerPostToSave = createAnswerPost(existingPostsWithAnswersCourseWide.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 createAnswerPost.
// HELPER METHODS
private AnswerPost createAnswerPost(Post post) {
AnswerPost answerPost = new AnswerPost();
answerPost.setContent("Content Answer Post");
answerPost.setPost(post);
post.addAnswerPost(answerPost);
return answerPost;
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testToggleResolvesPost.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testToggleResolvesPost() throws Exception {
AnswerPost answerPost = existingAnswerPosts.get(0);
// confirm that answer post resolves the original post
answerPost.setResolvesPost(true);
AnswerPost resolvingAnswerPost = request.putWithResponseBody("/api/courses/" + courseId + "/answer-posts/" + answerPost.getId(), answerPost, AnswerPost.class, HttpStatus.OK);
assertThat(resolvingAnswerPost).isEqualTo(answerPost);
// revoke that answer post resolves the original post
answerPost.setResolvesPost(false);
AnswerPost notResolvingAnswerPost = request.putWithResponseBody("/api/courses/" + courseId + "/answer-posts/" + answerPost.getId(), answerPost, AnswerPost.class, HttpStatus.OK);
assertThat(notResolvingAnswerPost).isEqualTo(answerPost);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project Artemis by ls1intum.
the class AnswerPostIntegrationTest method testCreateAnswerPostInLecture_asInstructor.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testCreateAnswerPostInLecture_asInstructor() throws Exception {
AnswerPost answerPostToSave = createAnswerPost(existingPostsWithAnswersInLecture.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());
}
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());
}
Aggregations