use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.
the class ReactionIntegrationTest method testCreateAnswerPostReactions.
@Test
@WithMockUser(username = "student2", roles = "USER")
public void testCreateAnswerPostReactions() throws Exception {
// student 1 is the author of the answer post and student 2 reacts on this answer post
AnswerPost answerPostReactedOn = existingAnswerPosts.get(0);
Reaction reactionToSaveOnAnswerPost = createReactionOnAnswerPost(answerPostReactedOn);
Reaction createdFirstReaction = request.postWithResponseBody("/api/courses/" + courseId + "/postings/reactions", reactionToSaveOnAnswerPost, Reaction.class, HttpStatus.CREATED);
checkCreatedReaction(reactionToSaveOnAnswerPost, createdFirstReaction);
assertThat(answerPostReactedOn.getReactions()).hasSize(reactionRepository.findReactionsByAnswerPostId(answerPostReactedOn.getId()).size() - 1);
// student 2 reacts again on this answer post
reactionToSaveOnAnswerPost = createReactionOnAnswerPost(answerPostReactedOn);
// change the emojiId to react differently
reactionToSaveOnAnswerPost.setEmojiId("cry");
Reaction createdSecondReaction = request.postWithResponseBody("/api/courses/" + courseId + "/postings/reactions", reactionToSaveOnAnswerPost, Reaction.class, HttpStatus.CREATED);
checkCreatedReaction(reactionToSaveOnAnswerPost, createdSecondReaction);
assertThat(answerPostReactedOn.getReactions()).hasSize(reactionRepository.findReactionsByAnswerPostId(answerPostReactedOn.getId()).size() - 2);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.
the class ReactionIntegrationTest method testCreateOwnAnswerPostReaction.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateOwnAnswerPostReaction() throws Exception {
// student 1 is the author of the answer post and reacts on this answer post
AnswerPost answerPostReactedOn = existingAnswerPosts.get(0);
Reaction reactionToSaveOnAnswerPost = createReactionOnAnswerPost(answerPostReactedOn);
Reaction createdReaction = request.postWithResponseBody("/api/courses/" + courseId + "/postings/reactions", reactionToSaveOnAnswerPost, Reaction.class, HttpStatus.CREATED);
checkCreatedReaction(reactionToSaveOnAnswerPost, createdReaction);
assertThat(answerPostReactedOn.getReactions()).hasSize(reactionRepository.findReactionsByAnswerPostId(answerPostReactedOn.getId()).size() - 1);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.
the class GroupNotificationFactoryTest method setUp.
/**
* sets up all needed mocks and their wanted behavior once for all test cases.
*/
@BeforeAll
public static void setUp() {
course = new Course();
course.setId(COURSE_ID);
lecture = new Lecture();
lecture.setId(LECTURE_ID);
lecture.setCourse(course);
exam = new Exam();
exam.setId(EXAM_ID);
exam.setCourse(course);
exerciseGroup = new ExerciseGroup();
exerciseGroup.setExam(exam);
exercise = new TextExercise();
exercise.setId(EXERCISE_ID);
exercise.setTitle(EXERCISE_TITLE);
exercise.setCourse(course);
exercise.setProblemStatement(PROBLEM_STATEMENT);
programmingExercise = new ProgrammingExercise();
programmingExercise.setId(EXERCISE_ID);
programmingExercise.setTitle(EXERCISE_TITLE);
programmingExercise.setCourse(course);
programmingExercise.setProblemStatement(PROBLEM_STATEMENT);
examExercise = new TextExercise();
examExercise.setId(EXERCISE_ID);
examExercise.setTitle(EXERCISE_TITLE);
examExercise.setCourse(course);
examExercise.setExerciseGroup(exerciseGroup);
examExercise.setProblemStatement(PROBLEM_STATEMENT);
attachment = new Attachment();
attachment.setLecture(lecture);
post = new Post();
post.setExercise(exercise);
post.setLecture(lecture);
answerPost = new AnswerPost();
answerPost.setPost(post);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.
the class SingleUserNotificationFactoryTest method setUp.
/**
* sets up all needed mocks and their wanted behavior once for all test cases.
*/
@BeforeAll
public static void setUp() {
course = new Course();
course.setId(COURSE_ID);
lecture = new Lecture();
lecture.setId(LECTURE_ID);
lecture.setCourse(course);
exercise = new TextExercise();
exercise.setId(EXERCISE_ID);
exercise.setTitle(EXERCISE_TITLE);
exercise.setCourse(course);
exercise.setProblemStatement(PROBLEM_STATEMENT);
post = new Post();
post.setExercise(exercise);
post.setLecture(lecture);
answerPost = new AnswerPost();
answerPost.setPost(post);
cheatingUser = new User();
cheatingUser.setLogin(USER_LOGIN);
plagiarismResult = new TextPlagiarismResult();
plagiarismResult.setExercise(exercise);
plagiarismSubmission = new PlagiarismSubmission();
plagiarismSubmission.setStudentLogin(USER_LOGIN);
plagiarismSubmissionSet = new HashSet<>();
plagiarismSubmissionSet.add(plagiarismSubmission);
plagiarismComparison = new PlagiarismComparison();
plagiarismComparison.setPlagiarismResult(plagiarismResult);
plagiarismComparison.setSubmissionA(plagiarismSubmission);
plagiarismCase = new PlagiarismCase();
plagiarismCase.setExercise(exercise);
plagiarismCase.setStudent(cheatingUser);
plagiarismCase.setPlagiarismSubmissions(plagiarismSubmissionSet);
}
use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.
the class ReactionIntegrationTest method testCreatePostReactions.
@Test
@WithMockUser(username = "student2", roles = "USER")
public void testCreatePostReactions() throws Exception {
// student 1 is the author of the post and student 2 reacts on this post
AnswerPost answerPostReactedOn = existingAnswerPosts.get(0);
Reaction reactionToSaveOnAnswerPost = createReactionOnAnswerPost(answerPostReactedOn);
Reaction createdFirstReaction = request.postWithResponseBody("/api/courses/" + courseId + "/postings/reactions", reactionToSaveOnAnswerPost, Reaction.class, HttpStatus.CREATED);
checkCreatedReaction(reactionToSaveOnAnswerPost, createdFirstReaction);
assertThat(answerPostReactedOn.getReactions()).hasSize(reactionRepository.findReactionsByAnswerPostId(answerPostReactedOn.getId()).size() - 1);
// student 2 reacts again on this answer post
reactionToSaveOnAnswerPost = createReactionOnAnswerPost(answerPostReactedOn);
// change the emojiId to react differently
reactionToSaveOnAnswerPost.setEmojiId("cry");
Reaction createdSecondReaction = request.postWithResponseBody("/api/courses/" + courseId + "/postings/reactions", reactionToSaveOnAnswerPost, Reaction.class, HttpStatus.CREATED);
checkCreatedReaction(reactionToSaveOnAnswerPost, createdSecondReaction);
assertThat(answerPostReactedOn.getReactions()).hasSize(reactionRepository.findReactionsByAnswerPostId(answerPostReactedOn.getId()).size() - 2);
}
Aggregations