SpaceController { @RequestMapping(value = "/{token:.+}", method = RequestMethod.GET) public ResponseEntity<Space> getSpace( @PathVariable String token, @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { Tenant t = null; try { t = this.tenantRepository.getTenant(tenant); } catch (Exception e) { log.error("Error retrieving tenant: " + e); return new ResponseEntity<Space>(HttpStatus.NOT_FOUND); } try { final Space s = SpaceRepository.FILTER.findOne( this.spaceRepository.findBySecondaryKey(t.getTenantToken(), token)); return new ResponseEntity<Space>(s, HttpStatus.OK); } catch (EntityNotFoundException enfe) { return new ResponseEntity<Space>(HttpStatus.NOT_FOUND); } } @Autowired  SpaceController(
      TenantRepository tenantRepository,
      SpaceRepository spaceRepository,
      ApplicationRepository appRepository,
      ApplicationExporter appExporter,
      Filter cacheFilter); @RequestMapping( value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Collection<Space>> getAllSpaces(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "default", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> getDefaultSpace(
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "search", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) ResponseEntity<List<Space>> searchSpaces(
      @RequestParam(value = "propertyName", required = true) String propertyName,
      @RequestParam(value = "mode", required = false, defaultValue = "EQUALS") ComparisonMode mode,
      @RequestParam(value = "caseSensitivity", required = false, defaultValue = "CASE_SENSITIVE")
          CaseSensitivity caseSensitivity,
      @RequestParam(value = "value", required = true) String[] value,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.OPTIONS) ResponseEntity<Space> isSpaceExisting(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.GET) ResponseEntity<Space> getSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> createSpace(
      @RequestBody Space space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping( value = "/{token:.+}", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Space> modifySpace(
      @PathVariable String token,
      @RequestBody Space new_space,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.POST) ResponseEntity<Space> cleanSpace(
      @PathVariable String token,
      @RequestParam(value = "clean", required = true) Boolean clean,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}", method = RequestMethod.DELETE) ResponseEntity<Space> deleteSpace(
      @PathVariable String token,
      @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false)
          String tenant); @RequestMapping(value = "/{token:.+}/apps", method = RequestMethod.GET) void getApplications(
      @PathVariable String token,
      @RequestParam(value = "includeSpaceProperties", required = false, defaultValue = "")
          final String[] includeSpaceProperties,
      @RequestParam(value = "includeGoalConfiguration", required = false, defaultValue = "")
          final String[] includeGoalConfiguration,
      @RequestParam(value = "includeGoalSystemInfo", required = false, defaultValue = "")
          final String[] includeGoalSystemInfo,
      @RequestParam(value = "includeBugs", required = false, defaultValue = "false")
          final String includeBugs,
      @RequestParam(value = "includeExemptions", required = false, defaultValue = "false")
          final String includeExemptions,
      @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) final String tenant,
      HttpServletRequest request,
      HttpServletResponse response);  }
@Test public void testGetSpace() throws Exception { assertEquals(0, this.spaceRepository.count()); final Tenant d_tenant = this.createDefaultTenant(); final Space d_space = this.createSpace(d_tenant, TEST_DEFAULT_SPACE, true); assertEquals(1, this.spaceRepository.count()); MockHttpServletRequestBuilder opts_builder = options("/spaces/" + TEST_DEFAULT_SPACE) .header(Constants.HTTP_TENANT_HEADER, TEST_DEFAULT_TENANT); mockMvc.perform(opts_builder).andExpect(status().isOk()); MockHttpServletRequestBuilder get_builder = get("/spaces/" + TEST_DEFAULT_SPACE) .header(Constants.HTTP_TENANT_HEADER, TEST_DEFAULT_TENANT) .accept(MediaType.APPLICATION_JSON); mockMvc .perform(get_builder) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.spaceToken", is(TEST_DEFAULT_SPACE))) .andExpect(jsonPath("$.spaceName", is(TEST_DEFAULT_SPACE))); }