TenantController { @RequestMapping( value = "/{token:.+}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) public ResponseEntity<Tenant> getTenant(@PathVariable String token) { try { try { final Tenant tenant = TenantRepository.FILTER.findOne(this.tenantRepository.findBySecondaryKey(token)); return new ResponseEntity<Tenant>(tenant, HttpStatus.OK); } catch (EntityNotFoundException enfe) { return new ResponseEntity<Tenant>(HttpStatus.NOT_FOUND); } } catch (Exception enfe) { return new ResponseEntity<Tenant>(HttpStatus.INTERNAL_SERVER_ERROR); } } @Autowired  TenantController(TenantRepository tenantRepository, Filter cacheFilter); @RequestMapping( value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<Iterable<Tenant>> getAllTenants(); @RequestMapping( value = "default", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<Tenant> getDefaultTenant(); @RequestMapping(value = "/{token:.+}", method = RequestMethod.OPTIONS) @JsonView(Views.Default.class) ResponseEntity<Tenant> isTenantExisting(@PathVariable String token); @RequestMapping( value = "", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<Tenant> createTenant(@RequestBody Tenant tenant); @RequestMapping( value = "/{token:.+}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<Tenant> getTenant(@PathVariable String token); @RequestMapping( value = "/{token:.+}", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<Tenant> modifyTenant(
      @PathVariable String token, @RequestBody Tenant new_tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.DELETE) @JsonView(Views.Default.class) ResponseEntity<Tenant> deleteTenant(@PathVariable String token);  }
@Test public void testGetTenant() throws Exception { createDefaultTenant(); final Tenant tenant = TenantRepository.FILTER.findOne( this.tenantRepository.findBySecondaryKey(TEST_DEFAULT_TENANT)); final Tenant default_tenant = this.tenantRepository.findDefault(); MockHttpServletRequestBuilder opts_builder = options("/tenants/" + TEST_DEFAULT_TENANT); mockMvc.perform(opts_builder).andExpect(status().isOk()); MockHttpServletRequestBuilder get_builder = get("/tenants/" + TEST_DEFAULT_TENANT).accept(MediaType.APPLICATION_JSON); mockMvc .perform(get_builder) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.default", is(true))) .andExpect(jsonPath("$.spaces").doesNotExist()) .andExpect(jsonPath("$.tenantToken", is(TEST_DEFAULT_TENANT))) .andExpect(jsonPath("$.tenantName", is(TEST_DEFAULT_TENANT))); }