PageResource extends AssetResource<Page> { @RequestMapping(value = "/{pageId}", method = RequestMethod.DELETE) public void delete(@PathVariable("pageId") String pageId) throws RepositoryException { pageRepository.delete(pageId); messagingTemplate.convertAndSend(PREVIEWABLE_REMOVAL, pageId); } @Inject  PageResource(
            PageService pageService,
            PageRepository pageRepository,
            SimpMessagingTemplate messagingTemplate,
            ContractToPageMapper contractToPageMapper,
            AssetService<Page> pageAssetService,
            AssetVisitor assetVisitor,
            ComponentVisitor componentVisitor, AuthRulesCollector authRulesCollector); @RequestMapping(method = RequestMethod.GET) @JsonView(JsonViewLight.class) List<Page> list(); @RequestMapping(method = RequestMethod.POST) ResponseEntity<Page> create(@RequestBody Page page,
            @RequestParam(value = "duplicata", required = false) String sourcePageId); @RequestMapping(value = "/contract/{scope}/{name}", method = RequestMethod.POST) ResponseEntity<Page> create(@RequestBody Contract contract, @PathVariable("scope") String scope,
            @PathVariable("name") String name); @RequestMapping(value = "/{pageId}", method = RequestMethod.PUT) ResponseEntity<Void> save(HttpServletRequest request, @PathVariable("pageId") String pageId,
            @RequestBody Page page); @RequestMapping(value = "/{pageId}/name", method = RequestMethod.PUT) ResponseEntity<Void> rename(HttpServletRequest request, @PathVariable("pageId") String pageId,
            @RequestBody String name); @RequestMapping(value = "/{pageId}/favorite", method = RequestMethod.PUT) void favorite(@PathVariable("pageId") String pageId, @RequestBody Boolean favorite); @RequestMapping(value = "/{pageId}", method = RequestMethod.GET) MappingJacksonValue get(@PathVariable("pageId") String pageId); @RequestMapping(value = "/{pageId}", method = RequestMethod.DELETE) void delete(@PathVariable("pageId") String pageId); @RequestMapping(value = "/{pageId}/resources", method = RequestMethod.GET) List<String> getResources(@PathVariable("pageId") String pageId); static final String BONITA_RESOURCE_REGEX; static final String EXTENSION_RESOURCE_REGEX; }
@Test public void should_respond_404_not_found_when_delete_inexisting_page() throws Exception { doThrow(new NotFoundException("page not found")).when(pageRepository).delete("my-page"); mockMvc.perform(delete("/rest/pages/my-page")).andExpect(status().isNotFound()); }
@Test public void should_respond_500_internal_error_when_error_on_deletion_page() throws Exception { doThrow(new RepositoryException("error occurs", new RuntimeException())).when(pageRepository).delete("my-page"); mockMvc.perform(delete("/rest/pages/my-page")).andExpect(status().isInternalServerError()); }
@Test public void should_delete_a_page() throws Exception { mockMvc .perform(delete("/rest/pages/my-page")) .andExpect(status().isOk()); }
@Test public void should_delete_an_asset() throws Exception { Page page = mockPageOfId("my-page"); mockMvc.perform( delete("/rest/pages/my-page/assets/UIID") .contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()); verify(pageAssetService).delete(page, "UIID"); }