TenantsRestApi extends ApiBase implements TenantsApi { @Override public void createProjectAsync(String tenantId, ProjectCreateSpec projectCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { String path = String.format("%s/%s/projects", getBasePath(), tenantId); createObjectAsync(path, serializeObjectAsJson(projectCreateSpec), responseCallback); } TenantsRestApi(RestClient restClient); @Override String getBasePath(); @Override Task create(String name); @Override void createAsync(final String name, final FutureCallback<Task> responseCallback); @Override ResourceList<Tenant> listAll(); @Override void listAllAsync(final FutureCallback<ResourceList<Tenant>> responseCallback); @Override ResourceList<Tenant> listByName(String name); @Override Tenant getTenant(String tenantId); @Override void listByNameAsync(final String name, final FutureCallback<ResourceList<Tenant>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback); @Override Task createResourceTicket(String tenantId, ResourceTicketCreateSpec resourceTicketCreateSpec); @Override void createResourceTicketAsync(String tenantId, ResourceTicketCreateSpec resourceTicketCreateSpec,
                                        final FutureCallback<Task> responseCallback); @Override ResourceList<ResourceTicket> getResourceTickets(String tenantId); @Override void getResourceTicketsAsync(final String tenantId, final FutureCallback<ResourceList<ResourceTicket>>
      responseCallback); @Override Task createProject(String tenantId, ProjectCreateSpec projectCreateSpec); @Override void createProjectAsync(String tenantId, ProjectCreateSpec projectCreateSpec,
                                 final FutureCallback<Task> responseCallback); @Override ResourceList<Project> getProjects(String tenantId); @Override void getProjectsAsync(final String tenantId, final FutureCallback<ResourceList<Project>>
      responseCallback);  }
@Test public void testCreateProjectAsync() throws IOException, InterruptedException { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); TenantsApi tenantsApi = new TenantsRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); tenantsApi.createProjectAsync("foo", new ProjectCreateSpec(), new FutureCallback<Task>() { @Override public void onSuccess(@Nullable Task result) { assertEquals(result, responseTask); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }