Search in sources :

Example 56 with Response

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

the class SecretDeliveryResourceIntegrationTest method returnsUnauthorizedWhenDenied.

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

Example 57 with Response

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

the class SecretDeliveryResourceIntegrationTest method returnsNotFoundWhenSecretDoesNotExist.

@Test
public void returnsNotFoundWhenSecretDoesNotExist() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/secret/nonexistent")).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 58 with Response

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

the class ClientResourceTest method modifyClient_notFound.

@Test
public void modifyClient_notFound() throws Exception {
    ModifyClientRequestV2 request = ModifyClientRequestV2.forName("non-existent");
    RequestBody body = RequestBody.create(JSON, mapper.writeValueAsString(request));
    Request post = clientRequest("/automation/v2/clients/non-existent").post(body).build();
    Response httpResponse = mutualSslClient.newCall(post).execute();
    assertThat(httpResponse.code()).isEqualTo(404);
}
Also used : Response(okhttp3.Response) ModifyClientRequestV2(keywhiz.api.automation.v2.ModifyClientRequestV2) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest) RequestBody(okhttp3.RequestBody) Test(org.junit.Test)

Example 59 with Response

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

the class ClientResourceTest method groupListing.

List<String> groupListing(String client) throws IOException {
    Request get = clientRequest(format("/automation/v2/clients/%s/groups", client)).get().build();
    Response httpResponse = mutualSslClient.newCall(get).execute();
    assertThat(httpResponse.code()).isEqualTo(200);
    return mapper.readValue(httpResponse.body().byteStream(), new TypeReference<List<String>>() {
    });
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest) List(java.util.List)

Example 60 with Response

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

the class ClientResourceTest method clientGroupsListing_notFound.

@Test
public void clientGroupsListing_notFound() throws Exception {
    Request get = clientRequest("/automation/v2/clients/non-existent/groups").get().build();
    Response httpResponse = mutualSslClient.newCall(get).execute();
    assertThat(httpResponse.code()).isEqualTo(404);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest) 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