use of de.tum.in.www1.artemis.domain.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);
}
use of de.tum.in.www1.artemis.domain.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);
}
use of de.tum.in.www1.artemis.domain.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);
}
use of de.tum.in.www1.artemis.domain.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);
}
use of de.tum.in.www1.artemis.domain.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseResource method createModelingExercise.
/**
* POST /modeling-exercises : Create a new modelingExercise.
*
* @param modelingExercise the modelingExercise to create
* @return the ResponseEntity with status 201 (Created) and with body the new modelingExercise, or with status 400 (Bad Request) if the modelingExercise has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/modeling-exercises")
@Timed
public ResponseEntity<ModelingExercise> createModelingExercise(@RequestBody ModelingExercise modelingExercise) throws URISyntaxException {
log.debug("REST request to save ModelingExercise : {}", modelingExercise);
if (modelingExercise.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new modelingExercise cannot already have an ID")).body(null);
}
ModelingExercise result = modelingExerciseRepository.save(modelingExercise);
return ResponseEntity.created(new URI("/api/modeling-exercises/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations