Search in sources :

Example 46 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class SecretDeliveryResourceIntegrationTest method returnsNotFoundWhenSecretUnspecified.

@Test
public void returnsNotFoundWhenSecretUnspecified() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/secret/")).build();
    Response response = client.newCall(get).execute();
    assertThat(response.code()).isEqualTo(404);
}
Also used : SecretDeliveryResponse(keywhiz.api.SecretDeliveryResponse) Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 47 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class SecretsDeliveryResourceIntegrationTest method returnsUnauthorizedWhenUnauthenticated.

@Test
public void returnsUnauthorizedWhenUnauthenticated() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/secrets")).build();
    Response response = clientNoClientCert.newCall(get).execute();
    assertThat(response.code()).isEqualTo(401);
}
Also used : SecretDeliveryResponse(keywhiz.api.SecretDeliveryResponse) Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 48 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class SecretsDeliveryResourceIntegrationTest method returnsEmptyJsonArrayWhenUserHasNoSecrets.

@Test
public void returnsEmptyJsonArrayWhenUserHasNoSecrets() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/secrets")).build();
    Response response = noSecretsClient.newCall(get).execute();
    assertThat(response.code()).isEqualTo(200);
    assertThat(response.body().string()).isEqualTo("[]");
}
Also used : SecretDeliveryResponse(keywhiz.api.SecretDeliveryResponse) Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 49 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class SecretsDeliveryResourceIntegrationTest method returnsJsonArray.

@Test
public void returnsJsonArray() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/secrets")).build();
    Response response = client.newCall(get).execute();
    assertThat(response.code()).isEqualTo(200);
    assertThat(response.body().string()).startsWith("[").endsWith("]");
}
Also used : SecretDeliveryResponse(keywhiz.api.SecretDeliveryResponse) Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 50 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class StatusResourceIntegrationTest method successWhenHealthy.

@Test
public void successWhenHealthy() throws Exception {
    Request request = new Request.Builder().url("http://localhost:8081/status/enable").post(RequestBody.create(MediaType.parse("text/plain"), "")).build();
    Response disableResponse = httpClient.newCall(request).execute();
    assertThat(disableResponse.code()).isEqualTo(200);
    Thread.sleep(3500);
    assertThat(isHealthy()).isTrue();
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Aggregations

Response (okhttp3.Response)478 Request (okhttp3.Request)354 Test (org.junit.Test)213 IOException (java.io.IOException)177 Response (retrofit2.Response)156 ResponseBody (okhttp3.ResponseBody)137 ServiceResponse (com.microsoft.rest.ServiceResponse)114 Call (okhttp3.Call)104 Observable (rx.Observable)98 MockResponse (okhttp3.mockwebserver.MockResponse)76 RequestBody (okhttp3.RequestBody)71 OkHttpClient (okhttp3.OkHttpClient)67 Callback (okhttp3.Callback)44 List (java.util.List)39 TestClients.clientRequest (keywhiz.TestClients.clientRequest)37 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)32 MediaType (okhttp3.MediaType)27 HttpUrl (okhttp3.HttpUrl)26 Interceptor (okhttp3.Interceptor)26 ANResponse (com.androidnetworking.common.ANResponse)23