Search in sources :

Example 1 with ResourceServersPage

use of com.auth0.json.mgmt.ResourceServersPage in project auth0-java by auth0.

the class ResourceServerEntityTest method shouldListResourceServerWithPage.

@Test
public void shouldListResourceServerWithPage() throws Exception {
    ResourceServersFilter filter = new ResourceServersFilter().withPage(23, 5);
    Request<ResourceServersPage> request = api.resourceServers().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_RESOURCE_SERVERS_LIST, 200);
    ResourceServersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/resource-servers"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("page", "23"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "5"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ResourceServersFilter(com.auth0.client.mgmt.filter.ResourceServersFilter) ResourceServersPage(com.auth0.json.mgmt.ResourceServersPage) Test(org.junit.Test)

Example 2 with ResourceServersPage

use of com.auth0.json.mgmt.ResourceServersPage in project auth0-java by auth0.

the class ResourceServerEntityTest method shouldListResourceServerWithTotals.

@Test
public void shouldListResourceServerWithTotals() throws Exception {
    ResourceServersFilter filter = new ResourceServersFilter().withTotals(true);
    Request<ResourceServersPage> request = api.resourceServers().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_RESOURCE_SERVERS_PAGED_LIST, 200);
    ResourceServersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/resource-servers"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
    assertThat(response.getStart(), is(0));
    assertThat(response.getLength(), is(14));
    assertThat(response.getTotal(), is(14));
    assertThat(response.getLimit(), is(50));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ResourceServersFilter(com.auth0.client.mgmt.filter.ResourceServersFilter) ResourceServersPage(com.auth0.json.mgmt.ResourceServersPage) Test(org.junit.Test)

Example 3 with ResourceServersPage

use of com.auth0.json.mgmt.ResourceServersPage in project auth0-java by auth0.

the class ResourceServerEntityTest method shouldListResourceServerWithoutFilter.

@Test
public void shouldListResourceServerWithoutFilter() throws Exception {
    Request<ResourceServersPage> request = api.resourceServers().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_RESOURCE_SERVERS_LIST, 200);
    ResourceServersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/resource-servers"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ResourceServersPage(com.auth0.json.mgmt.ResourceServersPage) Test(org.junit.Test)

Aggregations

ResourceServersPage (com.auth0.json.mgmt.ResourceServersPage)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 Test (org.junit.Test)3 ResourceServersFilter (com.auth0.client.mgmt.filter.ResourceServersFilter)2