RegistriesController { @Rel("/rel/jsonhome/registry") @RequestMapping( value = "/registries/{registryName}", method = RequestMethod.GET, produces = "application/json") @ResponseBody public Map<String, ?> getRegistry(@PathVariable @Doc("The name of the requested registry.") final String registryName, final HttpServletResponse response) { final Registry registry = registryRepository.get(registryName); if (registry != null) { LOG.info("Returning links containing {} entries.", registry.getAll().size()); response.setHeader("Cache-Control", "max-age=3600"); return registryToJson(applicationBaseUri, registry); } else { LOG.info("Links {} does not exist", registryName); response.setStatus(SC_NOT_FOUND); return null; } }  @Value("${jsonhome.applicationBaseUri}") void setApplicationBaseUri(final String baseUri); @Autowired void setRegistryRepository(final RegistryRepository registryRepository); @Rel("/rel/jsonhome/registries") @RequestMapping( value = "/registries", method = RequestMethod.GET, produces = "application/json") @ResponseBody Map<String, ?> getRegistries(final HttpServletResponse response); @Rel("/rel/jsonhome/registry") @RequestMapping( value = "/registries/{registryName}", method = RequestMethod.GET, produces = "application/json") @ResponseBody Map<String, ?> getRegistry(@PathVariable
                                      @Doc("The name of the requested registry.")
                                      final String registryName,
                                      final HttpServletResponse response); @Rel("/rel/jsonhome/registry") @RequestMapping( value = "/registries/{registryName}", method = RequestMethod.PUT) void putRegistry(@PathVariable
                            @Doc("The name of registry.")
                            final String registryName,
                            @RequestBody
                            final Map<String, Object> registry,
                            final HttpServletResponse response); @Rel("/rel/jsonhome/registry") @RequestMapping( value = "/registries/{registryName}", method = RequestMethod.DELETE) void deleteRegistry(@PathVariable final String registryName,
                               final HttpServletResponse response); @ResponseStatus(value = BAD_REQUEST, reason = "Illegal resource format") @ExceptionHandler({IllegalArgumentException.class, NullPointerException.class}) void handleBadRequest();  }
@Test public void shouldReturnNotFoundWhenAccessingNonExistentRegistry() throws IOException { final MockHttpServletResponse response = new MockHttpServletResponse(); registriesController.getRegistry("foo", response); assertEquals(response.getStatus(), SC_NOT_FOUND); }