Search in sources :

Example 6 with RestLiDataValidator

use of com.linkedin.restli.common.validation.RestLiDataValidator in project rest.li by linkedin.

the class TestRestLiValidationFromClient method testInvalidOutputEntityValidation.

@Test
public void testInvalidOutputEntityValidation() {
    RestLiDataValidator validator = new RestLiDataValidator(Collections.<String, List<String>>emptyMap(), ValidationDemo.class, ResourceMethod.GET);
    try {
        validator.validateOutput(null);
        Assert.fail("Expected IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        Assert.assertEquals(e.getMessage(), "Record template is null.");
    }
    try {
        validator.validateOutput(new ValidationDemo(null));
        Assert.fail("Expected IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        Assert.assertEquals(e.getMessage(), "Record template does not have data.");
    }
}
Also used : RestLiDataValidator(com.linkedin.restli.common.validation.RestLiDataValidator) ValidationDemo(com.linkedin.restli.examples.greetings.api.ValidationDemo) Test(org.testng.annotations.Test)

Aggregations

RestLiDataValidator (com.linkedin.restli.common.validation.RestLiDataValidator)6 ValidationDemo (com.linkedin.restli.examples.greetings.api.ValidationDemo)3 Test (org.testng.annotations.Test)3 DataMap (com.linkedin.data.DataMap)2 ValidationResult (com.linkedin.data.schema.validation.ValidationResult)2 ResourceMethod (com.linkedin.restli.common.ResourceMethod)2 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)2 Message (com.linkedin.data.message.Message)1 AbstractValidator (com.linkedin.data.schema.validator.AbstractValidator)1 Validator (com.linkedin.data.schema.validator.Validator)1 RecordTemplate (com.linkedin.data.template.RecordTemplate)1 TemplateRuntimeException (com.linkedin.data.template.TemplateRuntimeException)1 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)1 PatchRequest (com.linkedin.restli.common.PatchRequest)1 QueryParamsDataMap (com.linkedin.restli.internal.common.QueryParamsDataMap)1 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)1 AnyRecord (com.linkedin.restli.internal.server.methods.AnyRecord)1 Parameter (com.linkedin.restli.internal.server.model.Parameter)1 PagingContext (com.linkedin.restli.server.PagingContext)1 ResourceConfigException (com.linkedin.restli.server.ResourceConfigException)1