@Test(groups = "slow") public void testTenant() throws Exception { final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "er44TT-yy4r", "TTR445ee2", "dskjhfs^^54R"); tenantUserApi.createTenant(tenantdata, callContext); final Tenant tenant = tenantUserApi.getTenantByApiKey(tenantdata.getApiKey()); Assert.assertEquals(tenant.getApiKey(), tenantdata.getApiKey()); Assert.assertEquals(tenant.getExternalKey(), tenantdata.getExternalKey()); // The second time, the value is already in the cache so the TenantCacheLoader is not invoked final Tenant tenant2 = tenantUserApi.getTenantByApiKey(tenantdata.getApiKey()); Assert.assertEquals(tenant2.getApiKey(), tenantdata.getApiKey()); Assert.assertEquals(tenant2.getExternalKey(), tenantdata.getExternalKey()); }
@TimedResource @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Retrieve a tenant by its API key", response = TenantJson.class) @ApiResponses(value = {@ApiResponse(code = 404, message = "Tenant not found")}) public Response getTenantByApiKey(@QueryParam(QUERY_API_KEY) final String externalKey) throws TenantApiException { final Tenant tenant = tenantApi.getTenantByApiKey(externalKey); return Response.status(Status.OK).entity(new TenantJson(tenant)).build(); }
@Test(groups = "slow") public void testTenant() throws Exception { final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "er44TT-yy4r", "TTR445ee2", "dskjhfs^^54R"); tenantUserApi.createTenant(tenantdata, callContext); final Tenant tenant = tenantUserApi.getTenantByApiKey(tenantdata.getApiKey()); Assert.assertEquals(tenant.getApiKey(), tenantdata.getApiKey()); Assert.assertEquals(tenant.getExternalKey(), tenantdata.getExternalKey()); // The second time, the value is already in the cache so the TenantCacheLoader is not invoked final Tenant tenant2 = tenantUserApi.getTenantByApiKey(tenantdata.getApiKey()); Assert.assertEquals(tenant2.getApiKey(), tenantdata.getApiKey()); Assert.assertEquals(tenant2.getExternalKey(), tenantdata.getExternalKey()); }