Search in sources :

Example 1 with BatchUpdateEntityResponse

use of com.linkedin.restli.internal.client.response.BatchUpdateEntityResponse in project rest.li by linkedin.

the class TestDefaultScatterGatherStrategy method createBatchUpdateEntityResponse.

private static Response<BatchKVResponse<Long, UpdateEntityStatus<TestRecord>>> createBatchUpdateEntityResponse(ProtocolVersion version, Set<Long> resultKeys, Set<Long> errorKeys) {
    DataMap resultMap = new DataMap();
    DataMap errorMap = new DataMap();
    for (Long id : resultKeys) {
        resultMap.put(id.toString(), new UpdateEntityStatus<>(HttpStatus.S_200_OK.getCode(), new TestRecord().setId(id)).data());
    }
    for (Long id : errorKeys) {
        ErrorResponse err = new ErrorResponse().setStatus(HttpStatus.S_404_NOT_FOUND.getCode());
        errorMap.put(id.toString(), err.data());
    }
    DataMap responseMap = new DataMap();
    responseMap.put(BatchResponse.RESULTS, resultMap);
    responseMap.put(BatchResponse.ERRORS, errorMap);
    DataMap mergedMap = ResponseDecoderUtil.mergeUpdateStatusResponseData(responseMap);
    BatchUpdateEntityResponse<Long, TestRecord> response = new BatchUpdateEntityResponse<>(mergedMap, new TypeSpec<>(Long.class), new TypeSpec<>(TestRecord.class), Collections.emptyMap(), null, version);
    return new ResponseImpl<>(HttpStatus.S_200_OK.getCode(), Collections.emptyMap(), Collections.emptyList(), response, null);
}
Also used : UpdateEntityStatus(com.linkedin.restli.common.UpdateEntityStatus) TestRecord(com.linkedin.restli.client.test.TestRecord) BatchUpdateEntityResponse(com.linkedin.restli.internal.client.response.BatchUpdateEntityResponse) ResponseImpl(com.linkedin.restli.internal.client.ResponseImpl) DataMap(com.linkedin.data.DataMap) ErrorResponse(com.linkedin.restli.common.ErrorResponse)

Aggregations

DataMap (com.linkedin.data.DataMap)1 TestRecord (com.linkedin.restli.client.test.TestRecord)1 ErrorResponse (com.linkedin.restli.common.ErrorResponse)1 UpdateEntityStatus (com.linkedin.restli.common.UpdateEntityStatus)1 ResponseImpl (com.linkedin.restli.internal.client.ResponseImpl)1 BatchUpdateEntityResponse (com.linkedin.restli.internal.client.response.BatchUpdateEntityResponse)1