Search in sources :

Example 1 with AutoValidationWithProjectionFluentClient

use of com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient 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);
    }
}
Also used : AutoValidationWithProjectionFluentClient(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) ExecutionException(java.util.concurrent.ExecutionException) AutoValidationWithProjection(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection) ValidationDemo(com.linkedin.restli.examples.greetings.api.ValidationDemo) Test(org.testng.annotations.Test)

Example 2 with AutoValidationWithProjectionFluentClient

use of com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient 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);
}
Also used : AutoValidationWithProjectionFluentClient(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient) PagingMetadataProjections(com.linkedin.restli.examples.greetings.client.PagingMetadataProjections) Arrays(java.util.Arrays) RestLiValidationFilter(com.linkedin.restli.server.validation.RestLiValidationFilter) CollectionResponse(com.linkedin.restli.common.CollectionResponse) AutoValidationWithProjectionFluentClient(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient) Test(org.testng.annotations.Test) PatchGenerator(com.linkedin.restli.client.util.PatchGenerator) EntityResponse(com.linkedin.restli.common.EntityResponse) Map(java.util.Map) CreateIdEntityStatus(com.linkedin.restli.common.CreateIdEntityStatus) CreateIdStatus(com.linkedin.restli.common.CreateIdStatus) BatchfindersFluentClient(com.linkedin.restli.examples.greetings.client.BatchfindersFluentClient) ManualProjections(com.linkedin.restli.examples.greetings.client.ManualProjections) Greetings(com.linkedin.restli.examples.greetings.client.Greetings) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) CollectionMetadata(com.linkedin.restli.common.CollectionMetadata) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) ParSeqRestliClientBuilder(com.linkedin.restli.client.ParSeqRestliClientBuilder) CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) AutoValidationWithProjection(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection) GreetingsFluentClient(com.linkedin.restli.examples.greetings.client.GreetingsFluentClient) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) com.linkedin.restli.examples.greetings.api.myRecord(com.linkedin.restli.examples.greetings.api.myRecord) PatchRequest(com.linkedin.restli.common.PatchRequest) Assert(org.testng.Assert) UpdateEntityStatus(com.linkedin.restli.common.UpdateEntityStatus) ManualProjectionsFluentClient(com.linkedin.restli.examples.greetings.client.ManualProjectionsFluentClient) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ParSeqUnitTestHelper(com.linkedin.parseq.ParSeqUnitTestHelper) Tone(com.linkedin.restli.examples.greetings.api.Tone) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) IdEntityResponse(com.linkedin.restli.common.IdEntityResponse) AfterClass(org.testng.annotations.AfterClass) ValidationDemo(com.linkedin.restli.examples.greetings.api.ValidationDemo) BatchFinderCriteriaResult(com.linkedin.restli.common.BatchFinderCriteriaResult) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) GreetingCriteria(com.linkedin.restli.examples.greetings.api.GreetingCriteria) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CreateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient) PagingMetadataProjectionsFluentClient(com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient) ParSeqRestliClient(com.linkedin.restli.client.ParSeqRestliClient) BatchCollectionResponse(com.linkedin.restli.common.BatchCollectionResponse) com.linkedin.restli.examples.greetings.api.myItem(com.linkedin.restli.examples.greetings.api.myItem) Batchfinders(com.linkedin.restli.examples.greetings.client.Batchfinders) Sets(org.testng.collections.Sets) com.linkedin.restli.examples.greetings.api.myItem(com.linkedin.restli.examples.greetings.api.myItem) AutoValidationWithProjection(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection) ValidationDemo(com.linkedin.restli.examples.greetings.api.ValidationDemo) Test(org.testng.annotations.Test)

Aggregations

RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)2 ValidationDemo (com.linkedin.restli.examples.greetings.api.ValidationDemo)2 AutoValidationWithProjection (com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection)2 AutoValidationWithProjectionFluentClient (com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient)2 ParSeqUnitTestHelper (com.linkedin.parseq.ParSeqUnitTestHelper)1 ParSeqRestliClient (com.linkedin.restli.client.ParSeqRestliClient)1 ParSeqRestliClientBuilder (com.linkedin.restli.client.ParSeqRestliClientBuilder)1 ParSeqRestliClientConfigBuilder (com.linkedin.restli.client.ParSeqRestliClientConfigBuilder)1 PatchGenerator (com.linkedin.restli.client.util.PatchGenerator)1 BatchCollectionResponse (com.linkedin.restli.common.BatchCollectionResponse)1 BatchFinderCriteriaResult (com.linkedin.restli.common.BatchFinderCriteriaResult)1 CollectionMetadata (com.linkedin.restli.common.CollectionMetadata)1 CollectionResponse (com.linkedin.restli.common.CollectionResponse)1 CreateIdEntityStatus (com.linkedin.restli.common.CreateIdEntityStatus)1 CreateIdStatus (com.linkedin.restli.common.CreateIdStatus)1 EntityResponse (com.linkedin.restli.common.EntityResponse)1 IdEntityResponse (com.linkedin.restli.common.IdEntityResponse)1 PatchRequest (com.linkedin.restli.common.PatchRequest)1 UpdateEntityStatus (com.linkedin.restli.common.UpdateEntityStatus)1 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)1