use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class PostIntegrationTest method testArchivePost_asTutor.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testArchivePost_asTutor() throws Exception {
Post postToArchive = editExistingPost(existingPosts.get(0));
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("displayPriority", DisplayPriority.ARCHIVED.toString());
// change display priority to ARCHIVED
Post updatedPost = request.putWithResponseBodyAndParams("/api/courses/" + courseId + "/posts/" + postToArchive.getId() + "/display-priority", null, Post.class, HttpStatus.OK, params);
database.assertSensitiveInformationHidden(updatedPost);
assertThat(updatedPost).isEqualTo(postToArchive);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class PostIntegrationTest method testCreateLecturePost.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateLecturePost() throws Exception {
Post postToSave = createPostWithoutContext();
Lecture lecture = existingLecturePosts.get(0).getLecture();
postToSave.setLecture(lecture);
Post createdPost = request.postWithResponseBody("/api/courses/" + courseId + "/posts", postToSave, Post.class, HttpStatus.CREATED);
database.assertSensitiveInformationHidden(createdPost);
checkCreatedPost(postToSave, createdPost);
assertThat(existingLecturePosts).hasSize(postRepository.findPostsByLectureId(lectureId, false, false, false, null).size() - 1);
verify(groupNotificationService, times(1)).notifyAllGroupsAboutNewPostForLecture(createdPost, course);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class PostIntegrationTest method testCreateExistingPost_badRequest.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateExistingPost_badRequest() throws Exception {
Post existingPostToSave = existingPosts.get(0);
request.postWithResponseBody("/api/courses/" + courseId + "/posts", existingPostToSave, Post.class, HttpStatus.BAD_REQUEST);
assertThat(existingPosts.size()).isEqualTo(postRepository.count());
verify(groupNotificationService, times(0)).notifyAllGroupsAboutNewPostForExercise(any(), any());
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class PostIntegrationTest method testEditPostByChangingContext1_asTutor.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testEditPostByChangingContext1_asTutor() throws Exception {
// update exercise post
Post postToUpdate = existingExercisePosts.get(0);
// change to context to lecture
postToUpdate.setExercise(null);
postToUpdate.setLecture(this.existingLecturePosts.get(0).getLecture());
Post updatedPost = request.putWithResponseBody("/api/courses/" + courseId + "/posts/" + postToUpdate.getId(), postToUpdate, Post.class, HttpStatus.OK);
database.assertSensitiveInformationHidden(updatedPost);
assertThat(updatedPost).isEqualTo(postToUpdate);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class PostIntegrationTest method testEditAnnouncement_asTutor_forbidden.
// UPDATE
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testEditAnnouncement_asTutor_forbidden() throws Exception {
Post postToUpdate = editExistingPost(existingCourseWidePosts.get(0));
// simulate as if it was an announcement
postToUpdate.setCourseWideContext(CourseWideContext.ANNOUNCEMENT);
Post notUpdatedPost = request.putWithResponseBody("/api/courses/" + courseId + "/posts/" + postToUpdate.getId(), postToUpdate, Post.class, HttpStatus.FORBIDDEN);
assertThat(notUpdatedPost).isNull();
}
Aggregations