Search in sources :

Example 1 with Feedback

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);
}
Also used : Feedback(de.tum.in.www1.artemis.domain.Feedback) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Feedback

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);
}
Also used : Feedback(de.tum.in.www1.artemis.domain.Feedback) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Feedback

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));
}
Also used : Feedback(de.tum.in.www1.artemis.domain.Feedback) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with 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);
}
Also used : Feedback(de.tum.in.www1.artemis.domain.Feedback) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with Feedback

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);
}
Also used : Feedback(de.tum.in.www1.artemis.domain.Feedback) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Feedback (de.tum.in.www1.artemis.domain.Feedback)6 Timed (com.codahale.metrics.annotation.Timed)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 URI (java.net.URI)2 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)1 ResultRepository (de.tum.in.www1.artemis.repository.ResultRepository)1 de.tum.in.www1.artemis.service (de.tum.in.www1.artemis.service)1 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)1 HeaderUtil (de.tum.in.www1.artemis.web.rest.util.HeaderUtil)1 URISyntaxException (java.net.URISyntaxException)1 ZonedDateTime (java.time.ZonedDateTime)1 java.util (java.util)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 Authentication (org.springframework.security.core.Authentication)1