Search in sources :

Example 1 with ServerCompatModule

use of com.walmartlabs.concord.it.common.ServerCompatModule in project concord by walmartlabs.

the class ProcessMetadataIT method list.

private List<ProcessEntry> list(String orgName, String projectName, String... kv) throws Exception {
    ApiClient apiClient = getApiClient();
    HttpUrl.Builder b = HttpUrl.parse(apiClient.getBasePath() + "/api/v2/process").newBuilder().addQueryParameter("orgName", orgName).addQueryParameter("projectName", projectName);
    for (int i = 0; i < kv.length - 1; i += 2) {
        b.addQueryParameter(kv[i], kv[i + 1]);
    }
    Request req = new Request.Builder().url(b.build()).header("Authorization", ServerClient.DEFAULT_API_KEY).build();
    OkHttpClient httpClient = apiClient.getHttpClient();
    Response resp = null;
    try {
        resp = httpClient.newCall(req).execute();
        if (!resp.isSuccessful()) {
            throw new RuntimeException("Request failed: " + resp);
        }
        ObjectMapper om = new ObjectMapper();
        // to parse timestamps
        om.registerModule(new ServerCompatModule());
        return om.readValue(resp.body().byteStream(), LIST_OF_PROCESS_ENTRIES);
    } finally {
        if (resp != null && resp.body() != null) {
            resp.body().close();
        }
    }
}
Also used : Response(com.squareup.okhttp.Response) OkHttpClient(com.squareup.okhttp.OkHttpClient) ServerCompatModule(com.walmartlabs.concord.it.common.ServerCompatModule) Request(com.squareup.okhttp.Request) ApiClient(com.walmartlabs.concord.ApiClient) HttpUrl(com.squareup.okhttp.HttpUrl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpUrl (com.squareup.okhttp.HttpUrl)1 OkHttpClient (com.squareup.okhttp.OkHttpClient)1 Request (com.squareup.okhttp.Request)1 Response (com.squareup.okhttp.Response)1 ApiClient (com.walmartlabs.concord.ApiClient)1 ServerCompatModule (com.walmartlabs.concord.it.common.ServerCompatModule)1