Search in sources :

Example 1 with ValidateEmptyUnion

use of com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion in project rest.li by linkedin.

the class TestEmptyUnionValidation method testUnionEmptyWithProjection.

@Test
public void testUnionEmptyWithProjection() throws RemoteInvocationException {
    ValidateEmptyUnion expected = new ValidateEmptyUnion();
    expected.setFoo(new ValidateEmptyUnion.Foo());
    List<PathSpec> spec = Collections.singletonList(ValidateEmptyUnion.fields().foo().Fuzz());
    EmptyUnionRequestBuilders requestBuilders = new EmptyUnionRequestBuilders();
    GetRequest<ValidateEmptyUnion> req = requestBuilders.get().id(1L).fields(spec.toArray(new PathSpec[spec.size()])).build();
    ValidateEmptyUnion actual = getClient().sendRequest(req).getResponse().getEntity();
    Assert.assertEquals(actual, expected);
}
Also used : ValidateEmptyUnion(com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion) EmptyUnionRequestBuilders(com.linkedin.restli.examples.greetings.client.EmptyUnionRequestBuilders) PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 2 with ValidateEmptyUnion

use of com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion in project rest.li by linkedin.

the class TestEmptyUnionValidation method testUnionEmptyWithoutProjection.

@Test(expectedExceptions = RestLiResponseException.class)
public void testUnionEmptyWithoutProjection() throws RemoteInvocationException {
    String expectedSuffix = "projection";
    EmptyUnionRequestBuilders requestBuilders = new EmptyUnionRequestBuilders();
    GetRequest<ValidateEmptyUnion> req = requestBuilders.get().id(1L).build();
    ValidateEmptyUnion res = getClient().sendRequest(req).getResponse().getEntity();
}
Also used : ValidateEmptyUnion(com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion) EmptyUnionRequestBuilders(com.linkedin.restli.examples.greetings.client.EmptyUnionRequestBuilders) Test(org.testng.annotations.Test)

Example 3 with ValidateEmptyUnion

use of com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion in project rest.li by linkedin.

the class ValidateEmptyUnionResource method get.

// write some resource method to provide the data of the ValidateEmptyUnion record
@Override
public ValidateEmptyUnion get(Long keyId) {
    ValidateEmptyUnion union = new ValidateEmptyUnion();
    ValidateEmptyUnion.Foo foo = new ValidateEmptyUnion.Foo();
    union.setFoo(foo);
    return union;
}
Also used : ValidateEmptyUnion(com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion)

Example 4 with ValidateEmptyUnion

use of com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion in project rest.li by linkedin.

the class TestEmptyUnionValidation method testFailValidationWithFullUnionMemberProjection.

@Test(expectedExceptions = RestLiResponseException.class)
public void testFailValidationWithFullUnionMemberProjection() throws RemoteInvocationException {
    ValidateEmptyUnion expected = new ValidateEmptyUnion();
    expected.setFoo(new ValidateEmptyUnion.Foo());
    List<PathSpec> spec = Arrays.asList(ValidateEmptyUnion.fields().foo().Fuzz(), ValidateEmptyUnion.fields().foo().Bar());
    EmptyUnionRequestBuilders requestBuilders = new EmptyUnionRequestBuilders();
    GetRequest<ValidateEmptyUnion> req = requestBuilders.get().id(1L).fields(spec.toArray(new PathSpec[spec.size()])).build();
    ValidateEmptyUnion actual = getClient().sendRequest(req).getResponse().getEntity();
}
Also used : ValidateEmptyUnion(com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion) EmptyUnionRequestBuilders(com.linkedin.restli.examples.greetings.client.EmptyUnionRequestBuilders) PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Aggregations

ValidateEmptyUnion (com.linkedin.restli.examples.greetings.api.ValidateEmptyUnion)4 EmptyUnionRequestBuilders (com.linkedin.restli.examples.greetings.client.EmptyUnionRequestBuilders)3 Test (org.testng.annotations.Test)3 PathSpec (com.linkedin.data.schema.PathSpec)2