use of com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testValidationWithNoProjection.
@Test
public void testValidationWithNoProjection() throws Exception {
AutoValidationWithProjection validationDemos = new AutoValidationWithProjectionFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<ValidationDemo> result = validationDemos.get(1);
try {
CompletableFuture<ValidationDemo> future = result.toCompletableFuture();
future.get(5000, TimeUnit.MILLISECONDS);
Assert.fail("Request should have failed validation");
} catch (ExecutionException e) {
Assert.assertTrue(e.getCause() instanceof RestLiResponseException);
RestLiResponseException responseException = (RestLiResponseException) e.getCause();
Assert.assertEquals(responseException.getServiceErrorMessage(), TestRestLiValidationWithProjection.EXPECTED_VALIDATION_DEMO_FAILURE_MESSAGE);
}
}
use of com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testValidationWithOnlyValidFieldsProjected.
@Test
public void testValidationWithOnlyValidFieldsProjected() throws Exception {
AutoValidationWithProjection validationDemos = new AutoValidationWithProjectionFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<ValidationDemo> result = validationDemos.get(1, optionalParams -> optionalParams.withMask(mask -> mask.withStringB().withIncludedB().withUnionFieldWithInlineRecord(m1 -> m1.withMyRecord(myRecord.ProjectionMask::withFoo2)).withArrayWithInlineRecord(itemMask -> itemMask.withItems(myItem.ProjectionMask::withBar1)).withMapWithTyperefs(m -> m.withValues(Greeting.ProjectionMask::withId)).withValidationDemoNext(ValidationDemo.ProjectionMask::withIntB)));
CompletableFuture<ValidationDemo> future = result.toCompletableFuture();
ValidationDemo validationDemo = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertNotNull(validationDemo);
}
Aggregations