Search in sources :

Example 11 with AnswerPost

use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.

the class AnswerPostIntegrationTest method testEditAnswerPost_asStudent1.

@Test
@WithMockUser(username = "student1", roles = "USER")
public void testEditAnswerPost_asStudent1() throws Exception {
    // update own post (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);
}
Also used : AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 12 with AnswerPost

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

Example 13 with AnswerPost

use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.

the class AnswerPostIntegrationTest method testEditAnswerPostWithIdIsNull_badRequest.

@Test
@WithMockUser(username = "student1", roles = "USER")
public void testEditAnswerPostWithIdIsNull_badRequest() throws Exception {
    AnswerPost answerPostToUpdate = createAnswerPost(existingPostsWithAnswersCourseWide.get(0));
    AnswerPost updatedAnswerPostServer = request.putWithResponseBody("/api/courses/" + courseId + "/answer-posts/" + answerPostToUpdate.getId(), answerPostToUpdate, AnswerPost.class, HttpStatus.BAD_REQUEST);
    assertThat(updatedAnswerPostServer).isNull();
}
Also used : AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 14 with AnswerPost

use of de.tum.in.www1.artemis.domain.metis.AnswerPost in project ArTEMiS by ls1intum.

the class AnswerPostIntegrationTest method testCreateAnswerPostInLecture.

// CREATE
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testCreateAnswerPostInLecture() throws Exception {
    AnswerPost answerPostToSave = createAnswerPost(existingPostsWithAnswersInLecture.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());
}
Also used : AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 15 with AnswerPost

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

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