Search in sources :

Example 6 with Feedback

use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.

the class ErrorRestController method feedbackError.

@PreAuthorize("isAuthenticated()")
@PostMapping("/feedback/error")
public ResponseEntity<Void> feedbackError(@RequestBody Map<String, String> body, HttpSession session) {
    logger.info("Entered feedback error...");
    String exceptionMessage = body.get("exceptionMessage");
    session.setAttribute("feedback", new Feedback(exceptionMessage));
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) Feedback(edu.hawaii.its.groupings.type.Feedback) PostMapping(org.springframework.web.bind.annotation.PostMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 7 with Feedback

use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.

the class HomeController method feedbackSubmit.

@PreAuthorize("isAuthenticated()")
@PostMapping("/feedback")
public String feedbackSubmit(@ModelAttribute Feedback feedback, Model model, RedirectAttributes redirectAttributes) {
    logger.info("User has submitted feedback.");
    emailService.send(feedback);
    // Ensure the feedback form is reset after submission.
    model.addAttribute("feedback", new Feedback());
    redirectAttributes.addFlashAttribute("success", true);
    return "redirect:/feedback";
}
Also used : Feedback(edu.hawaii.its.groupings.type.Feedback) PostMapping(org.springframework.web.bind.annotation.PostMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 8 with Feedback

use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.

the class HomeController method feedbackForm.

@PreAuthorize("isAuthenticated()")
@GetMapping("/feedback")
public String feedbackForm(Model model, HttpSession session) {
    logger.info("User has entered feedback page.");
    Feedback sessionFeedback = (Feedback) session.getAttribute("feedback");
    if (sessionFeedback != null) {
        sessionFeedback.setType("problem");
        sessionFeedback.setEmail(userContextService.getCurrentUid() + "@hawaii.edu");
        model.addAttribute("feedback", sessionFeedback);
    } else {
        Feedback feedback = new Feedback();
        feedback.setType("general");
        feedback.setEmail(userContextService.getCurrentUid() + "@hawaii.edu");
        model.addAttribute("feedback", feedback);
    }
    return "feedback";
}
Also used : Feedback(edu.hawaii.its.groupings.type.Feedback) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 9 with Feedback

use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.

the class HomeControllerTest method requestFeedbackWithException.

@Test
@WithMockUhUser
public void requestFeedbackWithException() throws Exception {
    HttpSession session = mockMvc.perform(get("/feedback").sessionAttr("feedback", new Feedback("exception"))).andExpect(status().isOk()).andExpect(model().attributeExists("feedback")).andExpect(model().attribute("feedback", hasProperty("exceptionMessage", equalTo("exception")))).andExpect(model().attribute("feedback", hasProperty("email", equalTo("user@hawaii.edu")))).andReturn().getRequest().getSession();
    assertThat(session.getAttribute("feedback"), notNullValue());
}
Also used : Feedback(edu.hawaii.its.groupings.type.Feedback) HttpSession(javax.servlet.http.HttpSession) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with Feedback

use of edu.hawaii.its.groupings.type.Feedback in project uhgroupings by uhawaii-system-its-ti-iam.

the class EmailServiceTest method createBaseFeedback.

private Feedback createBaseFeedback() {
    Feedback feedback = new Feedback();
    feedback.setName("John Doe");
    feedback.setEmail("jdoe@hawaii.edu");
    feedback.setType("problem");
    feedback.setMessage("Some problem happened.");
    feedback.setExceptionMessage("");
    return feedback;
}
Also used : Feedback(edu.hawaii.its.groupings.type.Feedback)

Aggregations

Feedback (edu.hawaii.its.groupings.type.Feedback)11 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 HttpSession (javax.servlet.http.HttpSession)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseEntity (org.springframework.http.ResponseEntity)1 MailSendException (org.springframework.mail.MailSendException)1 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)1 JavaMailSender (org.springframework.mail.javamail.JavaMailSender)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1