Search in sources :

Example 1 with ModelingSubmission

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

the class ModelingSubmissionResourceIntTest method updateModelingSubmission.

@Test
@Transactional
public void updateModelingSubmission() throws Exception {
    // Initialize the database
    modelingSubmissionRepository.saveAndFlush(modelingSubmission);
    int databaseSizeBeforeUpdate = modelingSubmissionRepository.findAll().size();
    // Update the modelingSubmission
    ModelingSubmission updatedModelingSubmission = modelingSubmissionRepository.findOne(modelingSubmission.getId());
    updatedModelingSubmission.submissionPath(UPDATED_SUBMISSION_PATH);
    restModelingSubmissionMockMvc.perform(put("/api/modeling-submissions").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedModelingSubmission))).andExpect(status().isOk());
    // Validate the ModelingSubmission in the database
    List<ModelingSubmission> modelingSubmissionList = modelingSubmissionRepository.findAll();
    assertThat(modelingSubmissionList).hasSize(databaseSizeBeforeUpdate);
    ModelingSubmission testModelingSubmission = modelingSubmissionList.get(modelingSubmissionList.size() - 1);
    assertThat(testModelingSubmission.getSubmissionPath()).isEqualTo(UPDATED_SUBMISSION_PATH);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ModelingSubmission

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

the class ModelingSubmissionResource method getModelingSubmission.

/**
 * GET  /modeling-submissions/:id : get the "id" modelingSubmission.
 *
 * @param id the id of the modelingSubmission to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the modelingSubmission, or with status 404 (Not Found)
 */
@GetMapping("/modeling-submissions/{id}")
@Timed
public ResponseEntity<ModelingSubmission> getModelingSubmission(@PathVariable Long id) {
    log.debug("REST request to get ModelingSubmission : {}", id);
    ModelingSubmission modelingSubmission = modelingSubmissionRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(modelingSubmission));
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with ModelingSubmission

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

the class ModelingSubmissionResource method updateModelingSubmission.

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

Example 4 with ModelingSubmission

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

the class ModelingSubmissionResource method createModelingSubmission.

/**
 * POST  /modeling-submissions : Create a new modelingSubmission.
 *
 * @param modelingSubmission the modelingSubmission to create
 * @return the ResponseEntity with status 201 (Created) and with body the new modelingSubmission, or with status 400 (Bad Request) if the modelingSubmission has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/modeling-submissions")
@Timed
public ResponseEntity<ModelingSubmission> createModelingSubmission(@RequestBody ModelingSubmission modelingSubmission) throws URISyntaxException {
    log.debug("REST request to save ModelingSubmission : {}", modelingSubmission);
    if (modelingSubmission.getId() != null) {
        return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new modelingSubmission cannot already have an ID")).body(null);
    }
    ModelingSubmission result = modelingSubmissionRepository.save(modelingSubmission);
    return ResponseEntity.created(new URI("/api/modeling-submissions/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with ModelingSubmission

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

the class ModelingSubmissionResourceIntTest method equalsVerifier.

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

Aggregations

ModelingSubmission (de.tum.in.www1.artemis.domain.ModelingSubmission)6 Timed (com.codahale.metrics.annotation.Timed)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 URI (java.net.URI)1