@Test public void deleteNotificationById() throws Exception { Long notificationId = 700L; mockNotificationDao.deleteNotificationById(notificationId); expect(mockAuthentication.getName()).andReturn("user"); replayAll(); MvcResult result = mockMvc.perform( delete("/api/latest/plugin/notification/{notificationId}", notificationId) .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .session(mockHttpSession) .principal(mockAuthentication)) .andReturn(); verifyAll(); log.info("log status" + result.getResponse().getStatus()); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); }
@RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String deleteNotificationById( @PathVariable("notificationId") Long id ) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding notification with ID: " + id); } if (id != null) { try { JSONObject objectToReturnJSON = new JSONObject(); getNotificationDao().deleteNotificationById(id); log.info("Deleting notification by id '" + id + "'"); log.debug("Notification ID : " + id); objectToReturnJSON.put("deletedNotificationId", id); String objectToReturn; objectToReturn = objectToReturnJSON.toString(); return objectToReturn; } catch (PersistenceException e) { throw new AcmUserActionFailedException("Delete", "notification", id, e.getMessage(), e); } } throw new AcmObjectNotFoundException("Could not find notification", id, "", null); }
DeleteNotificationByIdAPIController { @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String deleteNotificationById( @PathVariable("notificationId") Long id ) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding notification with ID: " + id); } if (id != null) { try { JSONObject objectToReturnJSON = new JSONObject(); getNotificationDao().deleteNotificationById(id); log.info("Deleting notification by id '" + id + "'"); log.debug("Notification ID : " + id); objectToReturnJSON.put("deletedNotificationId", id); String objectToReturn; objectToReturn = objectToReturnJSON.toString(); return objectToReturn; } catch (PersistenceException e) { throw new AcmUserActionFailedException("Delete", "notification", id, e.getMessage(), e); } } throw new AcmObjectNotFoundException("Could not find notification", id, "", null); } }
DeleteNotificationByIdAPIController { @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String deleteNotificationById( @PathVariable("notificationId") Long id ) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding notification with ID: " + id); } if (id != null) { try { JSONObject objectToReturnJSON = new JSONObject(); getNotificationDao().deleteNotificationById(id); log.info("Deleting notification by id '" + id + "'"); log.debug("Notification ID : " + id); objectToReturnJSON.put("deletedNotificationId", id); String objectToReturn; objectToReturn = objectToReturnJSON.toString(); return objectToReturn; } catch (PersistenceException e) { throw new AcmUserActionFailedException("Delete", "notification", id, e.getMessage(), e); } } throw new AcmObjectNotFoundException("Could not find notification", id, "", null); }  }
DeleteNotificationByIdAPIController { @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String deleteNotificationById( @PathVariable("notificationId") Long id ) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding notification with ID: " + id); } if (id != null) { try { JSONObject objectToReturnJSON = new JSONObject(); getNotificationDao().deleteNotificationById(id); log.info("Deleting notification by id '" + id + "'"); log.debug("Notification ID : " + id); objectToReturnJSON.put("deletedNotificationId", id); String objectToReturn; objectToReturn = objectToReturnJSON.toString(); return objectToReturn; } catch (PersistenceException e) { throw new AcmUserActionFailedException("Delete", "notification", id, e.getMessage(), e); } } throw new AcmObjectNotFoundException("Could not find notification", id, "", null); }  @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String deleteNotificationById(
            @PathVariable("notificationId") Long id

    ); NotificationDao getNotificationDao(); void setNotificationDao(NotificationDao notificationDao); }
DeleteNotificationByIdAPIController { @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String deleteNotificationById( @PathVariable("notificationId") Long id ) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding notification with ID: " + id); } if (id != null) { try { JSONObject objectToReturnJSON = new JSONObject(); getNotificationDao().deleteNotificationById(id); log.info("Deleting notification by id '" + id + "'"); log.debug("Notification ID : " + id); objectToReturnJSON.put("deletedNotificationId", id); String objectToReturn; objectToReturn = objectToReturnJSON.toString(); return objectToReturn; } catch (PersistenceException e) { throw new AcmUserActionFailedException("Delete", "notification", id, e.getMessage(), e); } } throw new AcmObjectNotFoundException("Could not find notification", id, "", null); }  @RequestMapping(value = "/{notificationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String deleteNotificationById(
            @PathVariable("notificationId") Long id

    ); NotificationDao getNotificationDao(); void setNotificationDao(NotificationDao notificationDao);  }