Search in sources :

Example 1 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResourceIntTest method updateModelingExercise.

@Test
@Transactional
public void updateModelingExercise() throws Exception {
    // Initialize the database
    modelingExerciseRepository.saveAndFlush(modelingExercise);
    int databaseSizeBeforeUpdate = modelingExerciseRepository.findAll().size();
    // Update the modelingExercise
    ModelingExercise updatedModelingExercise = modelingExerciseRepository.findOne(modelingExercise.getId());
    updatedModelingExercise.baseFilePath(UPDATED_BASE_FILE_PATH);
    restModelingExerciseMockMvc.perform(put("/api/modeling-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedModelingExercise))).andExpect(status().isOk());
    // Validate the ModelingExercise in the database
    List<ModelingExercise> modelingExerciseList = modelingExerciseRepository.findAll();
    assertThat(modelingExerciseList).hasSize(databaseSizeBeforeUpdate);
    ModelingExercise testModelingExercise = modelingExerciseList.get(modelingExerciseList.size() - 1);
    assertThat(testModelingExercise.getBaseFilePath()).isEqualTo(UPDATED_BASE_FILE_PATH);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(ModelingExercise.class);
    ModelingExercise modelingExercise1 = new ModelingExercise();
    modelingExercise1.setId(1L);
    ModelingExercise modelingExercise2 = new ModelingExercise();
    modelingExercise2.setId(modelingExercise1.getId());
    assertThat(modelingExercise1).isEqualTo(modelingExercise2);
    modelingExercise2.setId(2L);
    assertThat(modelingExercise1).isNotEqualTo(modelingExercise2);
    modelingExercise1.setId(null);
    assertThat(modelingExercise1).isNotEqualTo(modelingExercise2);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResourceIntTest method createModelingExercise.

@Test
@Transactional
public void createModelingExercise() throws Exception {
    int databaseSizeBeforeCreate = modelingExerciseRepository.findAll().size();
    // Create the ModelingExercise
    restModelingExerciseMockMvc.perform(post("/api/modeling-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(modelingExercise))).andExpect(status().isCreated());
    // Validate the ModelingExercise in the database
    List<ModelingExercise> modelingExerciseList = modelingExerciseRepository.findAll();
    assertThat(modelingExerciseList).hasSize(databaseSizeBeforeCreate + 1);
    ModelingExercise testModelingExercise = modelingExerciseList.get(modelingExerciseList.size() - 1);
    assertThat(testModelingExercise.getBaseFilePath()).isEqualTo(DEFAULT_BASE_FILE_PATH);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResource method updateModelingExercise.

/**
 * PUT  /modeling-exercises : Updates an existing modelingExercise.
 *
 * @param modelingExercise the modelingExercise to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated modelingExercise,
 * or with status 400 (Bad Request) if the modelingExercise is not valid,
 * or with status 500 (Internal Server Error) if the modelingExercise couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/modeling-exercises")
@Timed
public ResponseEntity<ModelingExercise> updateModelingExercise(@RequestBody ModelingExercise modelingExercise) throws URISyntaxException {
    log.debug("REST request to update ModelingExercise : {}", modelingExercise);
    if (modelingExercise.getId() == null) {
        return createModelingExercise(modelingExercise);
    }
    ModelingExercise result = modelingExerciseRepository.save(modelingExercise);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, modelingExercise.getId().toString())).body(result);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project Artemis by ls1intum.

the class AssessmentKnowledgeIntegrationTest method testKeepModelAssessmentKnowledgeWhenExerciseIsDeletedIfOtherExercisesUseIt.

/**
 * Tests that ModelAssessmentKnowledge is not removed from the DB even after deleting
 * the parent exercise if there are other exercises using it
 *
 * @throws Exception might be thrown from Network Call to Artemis API
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testKeepModelAssessmentKnowledgeWhenExerciseIsDeletedIfOtherExercisesUseIt() throws Exception {
    final Course course = database.addCourseWithOneReleasedModelExerciseWithKnowledge();
    ModelingExercise modelingExercise = modelingExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
    request.postWithResponseBody("/api/modeling-exercises/import/" + modelingExercise.getId(), modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
    int exerciseCount = modelingExerciseRepository.findAll().size();
    int modelAssessmentKnowledgeCount = modelAssesmentKnowledgeRepository.findAll().size();
    request.delete("/api/modeling-exercises/" + modelingExercise.getId(), HttpStatus.OK);
    assertThat(modelingExerciseRepository.findAll().size()).isEqualTo(exerciseCount - 1);
    assertThat(modelAssesmentKnowledgeRepository.findAll().size()).isEqualTo(modelAssessmentKnowledgeCount);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) Course(de.tum.in.www1.artemis.domain.Course) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)188 WithMockUser (org.springframework.security.test.context.support.WithMockUser)126 Test (org.junit.jupiter.api.Test)120 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)90 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)72 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)28 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)26 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)16 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Course (de.tum.in.www1.artemis.domain.Course)14 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)14 ZonedDateTime (java.time.ZonedDateTime)12 Exam (de.tum.in.www1.artemis.domain.exam.Exam)10 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)10 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)9 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8