Search in sources :

Example 51 with Response

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

the class StatusResourceIntegrationTest method isHealthy.

private boolean isHealthy() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/_status")).build();
    okhttp3.Response statusResponse = httpsClient.newCall(get).execute();
    return statusResponse.code() == 200;
}
Also used : okhttp3(okhttp3) Request(okhttp3.Request) Response(okhttp3.Response)

Example 52 with Response

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

the class AutomationClientResourceIntegrationTest method addClients.

@Test
public void addClients() throws Exception {
    CreateClientRequest request = new CreateClientRequest("User1");
    String requestJSON = mapper.writeValueAsString(request);
    RequestBody body = RequestBody.create(KeywhizClient.JSON, requestJSON);
    Request post = new Request.Builder().post(body).url(testUrl("/automation/clients")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
    Response httpResponse = mutualSslClient.newCall(post).execute();
    assertThat(httpResponse.code()).isEqualTo(200);
}
Also used : ClientDetailResponse(keywhiz.api.ClientDetailResponse) Response(okhttp3.Response) CreateClientRequest(keywhiz.api.CreateClientRequest) Request(okhttp3.Request) CreateClientRequest(keywhiz.api.CreateClientRequest) RequestBody(okhttp3.RequestBody) Test(org.junit.Test)

Example 53 with Response

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

the class AutomationClientResourceIntegrationTest method addClientRedundant.

@Test
public void addClientRedundant() throws Exception {
    CreateClientRequest request = new CreateClientRequest("CN=User1");
    String json = mapper.writeValueAsString(request);
    Request post = new Request.Builder().post(RequestBody.create(KeywhizClient.JSON, json)).url(testUrl("/automation/clients")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
    Response httpResponse = mutualSslClient.newCall(post).execute();
    assertThat(httpResponse.code()).isEqualTo(409);
}
Also used : ClientDetailResponse(keywhiz.api.ClientDetailResponse) Response(okhttp3.Response) CreateClientRequest(keywhiz.api.CreateClientRequest) Request(okhttp3.Request) CreateClientRequest(keywhiz.api.CreateClientRequest) Test(org.junit.Test)

Example 54 with Response

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

the class AutomationGroupResourceIntegrationTest method findGroup.

@Test
public void findGroup() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/automation/groups?name=Web")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
    Response response = mutualSslClient.newCall(get).execute();
    assertThat(response.code()).isEqualTo(200);
    GroupDetailResponse groupResponse = mapper.readValue(response.body().string(), GroupDetailResponse.class);
    assertThat(groupResponse.getId()).isEqualTo(918);
}
Also used : Response(okhttp3.Response) GroupDetailResponse(keywhiz.api.GroupDetailResponse) Request(okhttp3.Request) CreateGroupRequest(keywhiz.api.CreateGroupRequest) GroupDetailResponse(keywhiz.api.GroupDetailResponse) Test(org.junit.Test)

Example 55 with Response

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

the class AutomationGroupResourceIntegrationTest method deleteGroup.

@Test
public void deleteGroup() throws Exception {
    String body = mapper.writeValueAsString(new CreateGroupRequest("short-lived", "group-description", ImmutableMap.of("app", "short")));
    Request post = new Request.Builder().post(RequestBody.create(KeywhizClient.JSON, body)).url(testUrl("/automation/groups")).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
    Response response = mutualSslClient.newCall(post).execute();
    assertThat(response.code()).isEqualTo(200);
    long groupId = mapper.readValue(response.body().string(), Group.class).getId();
    Request delete = new Request.Builder().delete().url(testUrl("/automation/groups/" + groupId)).build();
    response = mutualSslClient.newCall(delete).execute();
    assertThat(response.code()).isEqualTo(200);
    Request lookup = new Request.Builder().get().url(testUrl("/automation/groups/" + groupId)).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
    response = mutualSslClient.newCall(lookup).execute();
    assertThat(response.code()).isEqualTo(404);
}
Also used : Response(okhttp3.Response) GroupDetailResponse(keywhiz.api.GroupDetailResponse) Group(keywhiz.api.model.Group) CreateGroupRequest(keywhiz.api.CreateGroupRequest) Request(okhttp3.Request) CreateGroupRequest(keywhiz.api.CreateGroupRequest) 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