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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations