use of de.tum.in.www1.artemis.domain.Feedback in project ArTEMiS by ls1intum.
the class FeedbackResourceIntTest method createFeedback.
@Test
@Transactional
public void createFeedback() throws Exception {
int databaseSizeBeforeCreate = feedbackRepository.findAll().size();
// Create the Feedback
restFeedbackMockMvc.perform(post("/api/feedbacks").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(feedback))).andExpect(status().isCreated());
// Validate the Feedback in the database
List<Feedback> feedbackList = feedbackRepository.findAll();
assertThat(feedbackList).hasSize(databaseSizeBeforeCreate + 1);
Feedback testFeedback = feedbackList.get(feedbackList.size() - 1);
assertThat(testFeedback.getText()).isEqualTo(DEFAULT_TEXT);
assertThat(testFeedback.getDetailText()).isEqualTo(DEFAULT_DETAIL_TEXT);
assertThat(testFeedback.isPositive()).isEqualTo(DEFAULT_POSITIVE);
assertThat(testFeedback.getType()).isEqualTo(DEFAULT_TYPE);
}
use of de.tum.in.www1.artemis.domain.Feedback in project ArTEMiS by ls1intum.
the class FeedbackResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Feedback.class);
Feedback feedback1 = new Feedback();
feedback1.setId(1L);
Feedback feedback2 = new Feedback();
feedback2.setId(feedback1.getId());
assertThat(feedback1).isEqualTo(feedback2);
feedback2.setId(2L);
assertThat(feedback1).isNotEqualTo(feedback2);
feedback1.setId(null);
assertThat(feedback1).isNotEqualTo(feedback2);
}
use of de.tum.in.www1.artemis.domain.Feedback in project ArTEMiS by ls1intum.
the class FeedbackResource method getFeedback.
// Deactivated because it would load all (thousands) feedback objects and completely overload the server
// TODO: activate this call again using the infinite scroll page mechanism
// /**
// * GET /feedbacks : get all the feedbacks.
// *
// * @return the ResponseEntity with status 200 (OK) and the list of feedbacks in body
// */
// @GetMapping("/feedbacks")
// @Timed
// public List<Feedback> getAllFeedbacks() {
// log.debug("REST request to get all Feedbacks");
// return feedbackRepository.findAll();
// }
/**
* GET /feedbacks/:id : get the "id" feedback.
*
* @param id the id of the feedback to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the feedback, or with status 404 (Not Found)
*/
@GetMapping("/feedbacks/{id}")
@Timed
public ResponseEntity<Feedback> getFeedback(@PathVariable Long id) {
log.debug("REST request to get Feedback : {}", id);
Feedback feedback = feedbackRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(feedback));
}
use of de.tum.in.www1.artemis.domain.Feedback in project ArTEMiS by ls1intum.
the class FeedbackResource method createFeedback.
/**
* POST /feedbacks : Create a new feedback.
*
* @param feedback the feedback to create
* @return the ResponseEntity with status 201 (Created) and with body the new feedback, or with status 400 (Bad Request) if the feedback has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/feedbacks")
@Timed
public ResponseEntity<Feedback> createFeedback(@RequestBody Feedback feedback) throws URISyntaxException {
log.debug("REST request to save Feedback : {}", feedback);
if (feedback.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new feedback cannot already have an ID")).body(null);
}
Feedback savedFeedback = feedbackService.save(feedback);
return ResponseEntity.created(new URI("/api/feedbacks/" + savedFeedback.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, savedFeedback.getId().toString())).body(savedFeedback);
}
use of de.tum.in.www1.artemis.domain.Feedback in project ArTEMiS by ls1intum.
the class FeedbackResource method updateFeedback.
/**
* PUT /feedbacks : Updates an existing feedback.
*
* @param feedback the feedback to update
* @return the ResponseEntity with status 200 (OK) and with body the updated feedback,
* or with status 400 (Bad Request) if the feedback is not valid,
* or with status 500 (Internal Server Error) if the feedback couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/feedbacks")
@Timed
public ResponseEntity<Feedback> updateFeedback(@RequestBody Feedback feedback) throws URISyntaxException {
log.debug("REST request to update Feedback : {}", feedback);
if (feedback.getId() == null) {
return createFeedback(feedback);
}
Feedback result = feedbackRepository.save(feedback);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, feedback.getId().toString())).body(result);
}
Aggregations