Search in sources :

Example 61 with Response

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

the class ClientResourceTest method clientDelete_success.

@Test
public void clientDelete_success() throws Exception {
    // Sample client
    create(CreateClientRequestV2.builder().name("to-delete").build());
    // Deleting is successful
    Response httpResponse = delete("to-delete");
    assertThat(httpResponse.code()).isEqualTo(204);
    // Deleting again produces not-found
    httpResponse = delete("to-delete");
    assertThat(httpResponse.code()).isEqualTo(404);
}
Also used : Response(okhttp3.Response) Test(org.junit.Test)

Example 62 with Response

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

the class ClientResourceTest method lookup.

ClientDetailResponseV2 lookup(String client) throws IOException {
    Request get = clientRequest("/automation/v2/clients/" + client).get().build();
    Response httpResponse = mutualSslClient.newCall(get).execute();
    assertThat(httpResponse.code()).isEqualTo(200);
    return mapper.readValue(httpResponse.body().byteStream(), ClientDetailResponseV2.class);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest)

Example 63 with Response

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

the class ClientResourceTest method modifyGroups.

List<String> modifyGroups(String client, ModifyGroupsRequestV2 request) throws IOException {
    RequestBody body = RequestBody.create(JSON, mapper.writeValueAsString(request));
    Request put = clientRequest(format("/automation/v2/clients/%s/groups", client)).put(body).build();
    Response httpResponse = mutualSslClient.newCall(put).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) RequestBody(okhttp3.RequestBody)

Example 64 with Response

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

the class ClientResourceTest method modifyClientGroups_notFound.

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

Example 65 with Response

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

the class GroupResourceTest method secretsInfo.

Set<SanitizedSecret> secretsInfo(String group) throws IOException {
    Request get = clientRequest("/automation/v2/groups/" + group + "/secrets").get().build();
    Response httpResponse = mutualSslClient.newCall(get).execute();
    assertThat(httpResponse.code()).isEqualTo(200);
    return mapper.readValue(httpResponse.body().byteStream(), new TypeReference<Set<SanitizedSecret>>() {
    });
}
Also used : Response(okhttp3.Response) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest)

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