@Test public void testGetResourceTickets() throws IOException { ResourceTicket resourceTicket1 = new ResourceTicket(); resourceTicket1.setId("resourceTicket1"); ResourceTicket resourceTicket2 = new ResourceTicket(); resourceTicket2.setId("resourceTicket2"); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>( Arrays.asList(resourceTicket1, resourceTicket2)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(resourceTicketResourceList); setupMocks(serializedTask, HttpStatus.SC_OK); TenantsApi tenantsApi = new TenantsRestApi(restClient); ResourceList<ResourceTicket> response = tenantsApi.getResourceTickets("foo"); assertEquals(response.getItems().size(), resourceTicketResourceList.getItems().size()); assertTrue(response.getItems().containsAll(resourceTicketResourceList.getItems())); }
@Override public ResourceList<ResourceTicket> getResourceTickets(String tenantId) throws IOException { String path = String.format("%s/%s/resource-tickets", getBasePath(), tenantId); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>(); ResourceList<ResourceTicket> resourceList = getResourceTicketResourceList(path); resourceTicketResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getResourceTicketResourceList(resourceList.getNextPageLink()); resourceTicketResourceList.getItems().addAll(resourceList.getItems()); } return resourceTicketResourceList; }
TenantsRestApi extends ApiBase implements TenantsApi { @Override public ResourceList<ResourceTicket> getResourceTickets(String tenantId) throws IOException { String path = String.format("%s/%s/resource-tickets", getBasePath(), tenantId); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>(); ResourceList<ResourceTicket> resourceList = getResourceTicketResourceList(path); resourceTicketResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getResourceTicketResourceList(resourceList.getNextPageLink()); resourceTicketResourceList.getItems().addAll(resourceList.getItems()); } return resourceTicketResourceList; } }
TenantsRestApi extends ApiBase implements TenantsApi { @Override public ResourceList<ResourceTicket> getResourceTickets(String tenantId) throws IOException { String path = String.format("%s/%s/resource-tickets", getBasePath(), tenantId); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>(); ResourceList<ResourceTicket> resourceList = getResourceTicketResourceList(path); resourceTicketResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getResourceTicketResourceList(resourceList.getNextPageLink()); resourceTicketResourceList.getItems().addAll(resourceList.getItems()); } return resourceTicketResourceList; } TenantsRestApi(RestClient restClient); }
TenantsRestApi extends ApiBase implements TenantsApi { @Override public ResourceList<ResourceTicket> getResourceTickets(String tenantId) throws IOException { String path = String.format("%s/%s/resource-tickets", getBasePath(), tenantId); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>(); ResourceList<ResourceTicket> resourceList = getResourceTicketResourceList(path); resourceTicketResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getResourceTicketResourceList(resourceList.getNextPageLink()); resourceTicketResourceList.getItems().addAll(resourceList.getItems()); } return resourceTicketResourceList; } 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); }
TenantsRestApi extends ApiBase implements TenantsApi { @Override public ResourceList<ResourceTicket> getResourceTickets(String tenantId) throws IOException { String path = String.format("%s/%s/resource-tickets", getBasePath(), tenantId); ResourceList<ResourceTicket> resourceTicketResourceList = new ResourceList<>(); ResourceList<ResourceTicket> resourceList = getResourceTicketResourceList(path); resourceTicketResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getResourceTicketResourceList(resourceList.getNextPageLink()); resourceTicketResourceList.getItems().addAll(resourceList.getItems()); } return resourceTicketResourceList; } 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);  }