TenantHandler extends HttpHandler { @Override protected HttpResponse handleGET(HttpRequest request) { if (isGetTenantRequest(request)) { final TenantName tenantName = getTenantNameFromRequest(request); Utils.checkThatTenantExists(tenantRepository, tenantName); return new TenantGetResponse(tenantName); } else if (isListTenantsRequest(request)) { return new ListTenantsResponse(ImmutableSet.copyOf(tenantRepository.getAllTenantNames())); } else { throw new BadRequestException(request.getUri().toString()); } } @Inject  TenantHandler(Context ctx, ApplicationRepository applicationRepository);   }
@Test(expected=NotFoundException.class) public void testGetNonExisting() { handler.handleGET(HttpRequest.createTestRequest("http: }
@Test public void testGetAndList() throws Exception { tenantRepository.addTenant(a); assertResponseEquals((TenantGetResponse) handler.handleGET( HttpRequest.createTestRequest("http: "{\"message\":\"Tenant 'a' exists.\"}"); assertResponseEquals((ListTenantsResponse) handler.handleGET( HttpRequest.createTestRequest("http: "{\"tenants\":[\"default\",\"a\"]}"); }