@Test(groups = "slow", description = "Test Tenant creation with External Key over limit") public void testCreateTenantWithExternalKeyOverLimit() throws Exception { final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,.", "TTR445ee2", "dskjhfs^^54R"); try { tenantUserApi.createTenant(tenantdata, callContext); Assert.fail(); } catch (final TenantApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode()); } } }
@Override public Response toResponse(final TenantApiException exception) { if (exception.getCode() == ErrorCode.TENANT_ALREADY_EXISTS.getCode()) { return buildConflictingRequestResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_ID.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_KEY.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_API_KEY.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_CREATION_FAILED.getCode()) { return buildInternalErrorResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_UPDATE_FAILED.getCode()) { return buildInternalErrorResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TENANT_NO_SUCH_KEY.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else { return fallback(exception, uriInfo); } } }
@Test(groups = "slow", description = "Test Tenant creation with External Key over limit") public void testCreateTenantWithExternalKeyOverLimit() throws Exception { final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,.", "TTR445ee2", "dskjhfs^^54R"); try { tenantUserApi.createTenant(tenantdata, callContext); Assert.fail(); } catch (final TenantApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode()); } } }