use of com.linkedin.restli.test.util.RootBuilderWrapper in project rest.li by linkedin.
the class TestRestLiValidationWithProjection method provideProjectionWithNonexistentFieldsData.
@DataProvider
private Object[][] provideProjectionWithNonexistentFieldsData() {
RootBuilderWrapper<Integer, ValidationDemo> wrapper = new RootBuilderWrapper<>(new AutoValidationWithProjectionBuilders());
Request<ValidationDemo> getRequest = wrapper.get().id(1).fields(new PathSpec("nonexistentFieldFooBar")).build();
Request<CollectionResponse<ValidationDemo>> getAllRequest = wrapper.getAll().fields(new PathSpec("nonexistentFieldFooBar")).build();
Request<CollectionResponse<ValidationDemo>> findRequest = wrapper.findBy("searchWithProjection").fields(new PathSpec("nonexistentFieldFooBar")).build();
return new Object[][] { { getRequest }, { getAllRequest }, { findRequest } };
}
use of com.linkedin.restli.test.util.RootBuilderWrapper in project rest.li by linkedin.
the class TestRestLiValidationFromClient method testCreateFailure.
@Test(dataProvider = "provideCreateFailureData")
public void testCreateFailure(Object builder, ValidationDemo validationDemo, String errorMessage) {
ValidationResult result = new RootBuilderWrapper<Integer, ValidationDemo>(builder, ValidationDemo.class).create().validateInput(validationDemo);
Assert.assertEquals(result.isValid(), false);
Assert.assertTrue(result.getMessages().toString().contains(errorMessage));
}
use of com.linkedin.restli.test.util.RootBuilderWrapper in project rest.li by linkedin.
the class TestRestLiValidationFromClient method testUpdateFailure.
@Test(dataProvider = "provideUpdateFailureData")
public void testUpdateFailure(Object builder, ValidationDemo validationDemo, String errorMessage) {
ValidationResult result = new RootBuilderWrapper<Integer, ValidationDemo>(builder, ValidationDemo.class).update().validateInput(validationDemo);
Assert.assertEquals(result.isValid(), false);
Assert.assertTrue(result.getMessages().toString().contains(errorMessage));
}
use of com.linkedin.restli.test.util.RootBuilderWrapper in project rest.li by linkedin.
the class TestRestLiValidationFromClient method testPartialUpdateFailure.
@Test(dataProvider = "providePartialUpdateFailureData")
public void testPartialUpdateFailure(Object builder, String patch, String errorMessage) {
PatchRequest<ValidationDemo> patchRequest = PatchBuilder.buildPatchFromString(patch);
ValidationResult result = new RootBuilderWrapper<Integer, ValidationDemo>(builder, ValidationDemo.class).partialUpdate().validateInput(patchRequest);
Assert.assertEquals(result.isValid(), false);
Assert.assertEquals(result.getMessages().toString(), errorMessage);
}
use of com.linkedin.restli.test.util.RootBuilderWrapper in project rest.li by linkedin.
the class TestStreamingGreetings method resourceMethodDoesNotAcceptAttachments.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void resourceMethodDoesNotAcceptAttachments(final RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
// Resource method does not desire request attachments. Assert that all the attachments are drained and that a 400
// bad request is observed.
final RestLiTestAttachmentDataSource greetingAttachment = new RestLiTestAttachmentDataSource("1", ByteString.copyString("clientData", Charset.defaultCharset()));
RootBuilderWrapper.MethodBuilderWrapper<Long, Greeting, Object> methodBuilderWrapper = builders.action("actionNoAttachmentsAllowed");
methodBuilderWrapper.appendSingleAttachment(greetingAttachment);
final Request<Object> request = methodBuilderWrapper.build();
try {
getClient().sendRequest(request).getResponse().getEntity();
Assert.fail();
} catch (final RestLiResponseException responseException) {
Assert.assertEquals(responseException.getStatus(), 400);
Assert.assertEquals(responseException.getServiceErrorMessage(), "Resource method endpoint invoked does not accept any request attachments.");
}
// Then verify the response and request attachments were fully absorbed.
Assert.assertTrue(greetingAttachment.finished());
}
Aggregations