Search in sources :

Example 1 with FieldsFilter

use of com.auth0.client.mgmt.filter.FieldsFilter in project auth0-java by auth0.

the class OrganizationEntityTest method shouldGetInvitationWithFilter.

@Test
public void shouldGetInvitationWithFilter() throws Exception {
    Request<Invitation> request = api.organizations().getInvitation("org_123", "invitation_id", new FieldsFilter().withFields("id,invitation_url,invitee", true));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(INVITATION, 200);
    Invitation response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_123/invitations/invitation_id"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("fields", "id,invitation_url,invitee"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) FieldsFilter(com.auth0.client.mgmt.filter.FieldsFilter) Test(org.junit.Test)

Example 2 with FieldsFilter

use of com.auth0.client.mgmt.filter.FieldsFilter in project auth0-java by auth0.

the class TenantsEntityTest method shouldGetTenantSettingsWithFields.

@Test
public void shouldGetTenantSettingsWithFields() throws Exception {
    FieldsFilter filter = new FieldsFilter().withFields("some,random,fields", true);
    Request<Tenant> request = api.tenants().get(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_TENANT, 200);
    Tenant response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/tenants/settings"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Tenant(com.auth0.json.mgmt.tenants.Tenant) FieldsFilter(com.auth0.client.mgmt.filter.FieldsFilter) Test(org.junit.Test)

Example 3 with FieldsFilter

use of com.auth0.client.mgmt.filter.FieldsFilter in project auth0-java by auth0.

the class EmailProviderEntityTest method shouldGetEmailProviderWithFields.

@Test
public void shouldGetEmailProviderWithFields() throws Exception {
    FieldsFilter filter = new FieldsFilter().withFields("some,random,fields", true);
    Request<EmailProvider> request = api.emailProvider().get(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
    EmailProvider response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/emails/provider"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) EmailProvider(com.auth0.json.mgmt.emailproviders.EmailProvider) FieldsFilter(com.auth0.client.mgmt.filter.FieldsFilter) Test(org.junit.Test)

Example 4 with FieldsFilter

use of com.auth0.client.mgmt.filter.FieldsFilter in project auth0-java by auth0.

the class UsersEntityTest method shouldListUsersByEmailWithFields.

@Test
public void shouldListUsersByEmailWithFields() throws Exception {
    FieldsFilter filter = new FieldsFilter().withFields("some,random,fields", true);
    Request<List<User>> request = api.users().listByEmail("johndoe@auth0.com", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USERS_LIST, 200);
    List<User> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users-by-email"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("email", "johndoe@auth0.com"));
    assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) User(com.auth0.json.mgmt.users.User) FieldsFilter(com.auth0.client.mgmt.filter.FieldsFilter) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

FieldsFilter (com.auth0.client.mgmt.filter.FieldsFilter)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)4 Test (org.junit.Test)4 EmailProvider (com.auth0.json.mgmt.emailproviders.EmailProvider)1 Tenant (com.auth0.json.mgmt.tenants.Tenant)1 User (com.auth0.json.mgmt.users.User)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1