List of usage examples for org.springframework.http HttpStatus NOT_FOUND
HttpStatus NOT_FOUND
To view the source code for org.springframework.http HttpStatus NOT_FOUND.
Click Source Link
From source file:access.test.PiazzaEnvironmentTests.java
@Test public void testResourcesDoNotExist() { Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces"), Mockito.eq(HttpMethod.POST), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("{\"result\": \"all good\"}", HttpStatus.OK)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces/piazza.xml"), Mockito.eq(HttpMethod.PUT), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("{\"result\": \"all good\"}", HttpStatus.OK)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/datastores/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("{invalid JSON}", HttpStatus.OK)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/datastores"), Mockito.eq(HttpMethod.POST), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("{\"result\": \"all good\"}", HttpStatus.OK)); piazzaEnvironment.initializeEnvironment(); assertTrue(true); // no error occurred }
From source file:com.itn.webservices.AdminControllerWebservice.java
@RequestMapping(value = "/food/{id}", method = RequestMethod.PUT) public ResponseEntity<FoodInventory> updateUser(@PathVariable("id") long id, @RequestBody FoodInventory foodInventory) { logger.info("Updating Food " + id); FoodInventory currentFood = foodInventoryService.findById(id); if (currentFood == null) { logger.info("Food with id " + id + " not found"); return new ResponseEntity<FoodInventory>(HttpStatus.NOT_FOUND); }/*from www. j a v a 2s . c om*/ currentFood.setFoodName(foodInventory.getFoodName()); currentFood.setPrice(foodInventory.getPrice()); foodInventoryService.update(currentFood); return new ResponseEntity<FoodInventory>(currentFood, HttpStatus.OK); }
From source file:com.srinathavan.mwbng.rest.mvc.BlogController.java
@RequestMapping(value = "/{blogId}", method = RequestMethod.PUT) public ResponseEntity<Object> updateBlog(@PathVariable Long blogId, @RequestBody Blog requestBlog) { Blog responseBlog = blogService.updateBlog(blogId, requestBlog); if (null != responseBlog) { return new ResponseEntity<Object>(responseBlog, HttpStatus.OK); } else {// www . j a v a 2 s .c om return new ResponseEntity<Object>(HttpStatus.NOT_FOUND); } }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void unregister_notFound() { controller.register(new Application("http://localhost", "FOO")); ResponseEntity<?> response = controller.unregister("unknown"); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
From source file:com.indeed.iupload.web.controller.AppController.java
@ResponseStatus(value = HttpStatus.NOT_FOUND) @ExceptionHandler(ResourceNotFoundException.class) public @ResponseBody BasicResponse handleResourceNotFoundException(ResourceNotFoundException e) { return BasicResponse.error(e.getMessage()); }
From source file:org.ff4j.spring.boot.exceptions.FF4jExceptionHandler.java
@ExceptionHandler(value = AuthorizationNotExistsException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "no security has been defined") public void authorizationNotExistsException() { // Not necessary to handle this exception }
From source file:web.MaterialController.java
@ExceptionHandler(NotFoundException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Entity with specified id not found") public void handleNotFoundException(NotFoundException ex, HttpServletResponse response) throws IOException { }
From source file:org.syncope.core.rest.RoleTestITCase.java
@Test public void delete() { try {//from www . jav a 2 s . c o m restTemplate.delete(BASE_URL + "role/delete/{roleId}", 0); } catch (HttpStatusCodeException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode()); } restTemplate.delete(BASE_URL + "role/delete/{roleId}", 5); try { restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json", RoleTO.class, 2); } catch (HttpStatusCodeException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode()); } }
From source file:cn.edu.zjnu.acm.judge.contest.ContestController.java
@GetMapping(value = "standing", produces = { TEXT_HTML_VALUE, ALL_VALUE }) public String standingHtml(@PathVariable("contestId") long id, Model model, Locale locale) { Contest contest = contestMapper.findOneByIdAndDisabledFalse(id); // TODO// w w w. ja va2s . c om model.addAttribute("contestId", id); model.addAttribute("contest", contest); if (contest == null) { throw new MessageException("onlinejudge.contest.nosuchcontest", HttpStatus.NOT_FOUND); } if (!contest.isStarted()) { throw new MessageException("Contest not started yet", HttpStatus.OK); } // TODO user is empty List<Problem> problems = contestMapper.getProblems(id, null, locale.getLanguage()); model.addAttribute("id", id); model.addAttribute("problems", problems); model.addAttribute("standing", standing(id)); return "contests/standing"; }
From source file:org.magnum.dataup.VideoSvcUp.java
@RequestMapping(value = VideoSvcApi.VIDEO_DATA_PATH, method = RequestMethod.GET) public @ResponseBody void getVideoData(@PathVariable(VideoSvcApi.ID_PARAMETER) long id, HttpServletResponse response) throws IOException { if (!videos.containsKey(id)) { response.setStatus(HttpStatus.NOT_FOUND.value()); } else {/*from w w w . java 2 s . c o m*/ Video v = videos.get(id); videoDataMgr.copyVideoData(v, response.getOutputStream()); } }