Search in sources :

Example 26 with AnswerPost

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);
}
Also used : Reaction(de.tum.in.www1.artemis.domain.metis.Reaction) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 27 with AnswerPost

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);
}
Also used : Reaction(de.tum.in.www1.artemis.domain.metis.Reaction) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Example 28 with AnswerPost

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);
}
Also used : AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) Post(de.tum.in.www1.artemis.domain.metis.Post) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) Exam(de.tum.in.www1.artemis.domain.exam.Exam) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 29 with AnswerPost

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);
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) PlagiarismCase(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) Post(de.tum.in.www1.artemis.domain.metis.Post) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 30 with AnswerPost

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);
}
Also used : Reaction(de.tum.in.www1.artemis.domain.metis.Reaction) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test)

Aggregations

AnswerPost (de.tum.in.www1.artemis.domain.metis.AnswerPost)71 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)48 Test (org.junit.jupiter.api.Test)48 WithMockUser (org.springframework.security.test.context.support.WithMockUser)48 Reaction (de.tum.in.www1.artemis.domain.metis.Reaction)18 Post (de.tum.in.www1.artemis.domain.metis.Post)16 Course (de.tum.in.www1.artemis.domain.Course)12 User (de.tum.in.www1.artemis.domain.User)10 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)6 MetisPostDTO (de.tum.in.www1.artemis.web.websocket.dto.MetisPostDTO)6 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)4 BeforeAll (org.junit.jupiter.api.BeforeAll)4 Exam (de.tum.in.www1.artemis.domain.exam.Exam)2 Posting (de.tum.in.www1.artemis.domain.metis.Posting)2 PlagiarismCase (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase)2 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)2 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)2 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)2 AccessForbiddenException (de.tum.in.www1.artemis.web.rest.errors.AccessForbiddenException)2 MimeMessage (javax.mail.internet.MimeMessage)2