use of com.linkedin.restli.examples.greetings.client.ValidationDemosBuilders in project rest.li by linkedin.
the class TestRestLiValidation method testBatchCreateManualFailure.
@Test(dataProvider = "batchCreateFailureData")
public void testBatchCreateManualFailure(List<ValidationDemo> validationDemos, List<String> errorMessages) throws RemoteInvocationException {
Response<CollectionResponse<CreateStatus>> response = _restClientManual.sendRequest(new RootBuilderWrapper<Integer, ValidationDemo>(new ValidationDemosBuilders()).batchCreate().inputs(validationDemos).build()).getResponse();
List<CreateStatus> results = response.getEntity().getElements();
int i = 0;
for (CreateStatus result : results) {
Assert.assertEquals((int) result.getStatus(), HttpStatus.S_422_UNPROCESSABLE_ENTITY.getCode());
Assert.assertTrue(result.getError().getMessage().contains(errorMessages.get(i++)));
}
response = _restClientManual.sendRequest(new RootBuilderWrapper<Integer, ValidationDemo>(new ValidationDemosRequestBuilders()).batchCreate().inputs(validationDemos).build()).getResponse();
@SuppressWarnings("unchecked") List<CreateIdStatus<Integer>> results2 = ((BatchCreateIdResponse<Integer>) (Object) response.getEntity()).getElements();
i = 0;
for (CreateIdStatus<Integer> result : results2) {
Assert.assertEquals((int) result.getStatus(), HttpStatus.S_422_UNPROCESSABLE_ENTITY.getCode());
Assert.assertTrue(result.getError().getMessage().contains(errorMessages.get(i++)));
}
}
use of com.linkedin.restli.examples.greetings.client.ValidationDemosBuilders in project rest.li by linkedin.
the class TestRestLiValidation method testBatchGet.
@Test
public void testBatchGet() throws RemoteInvocationException {
BatchGetRequest<ValidationDemo> request = new ValidationDemosBuilders().batchGet().ids(1, 2, 3).build();
Response<BatchResponse<ValidationDemo>> response = _restClientManual.sendRequest(request).getResponse();
Assert.assertEquals(response.getStatus(), HttpStatus.S_200_OK.getCode());
BatchGetEntityRequest<Integer, ValidationDemo> request2 = new ValidationDemosRequestBuilders().batchGet().ids(1, 2, 3).build();
Response<BatchKVResponse<Integer, EntityResponse<ValidationDemo>>> response2 = _restClientManual.sendRequest(request2).getResponse();
Assert.assertEquals(response2.getStatus(), HttpStatus.S_200_OK.getCode());
}
Aggregations