use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootManualMetadataAutomaticNoFields.
/**
* Calls the resource method rootManualMetadataAutomatic with no fields specified in any projection
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootManualMetadataAutomaticNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootManualMetadataAutomatic").build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
true, /*hasMessage*/
true);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataAutomaticAllFields.
/**
* Calls the resource method rootAutomaticMetadataAutomatic with all custom metadata fields and a single
* root object entity projection field
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataAutomaticAllFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootAutomaticMetadataAutomatic").fields(Greeting.fields().tone()).metadataFields(Greeting.fields().tone(), Greeting.fields().id(), Greeting.fields().message()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
false, /*hasMessage*/
false);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootManualMetadataAutomaticAllFields.
/**
* Calls the resource method rootManualMetadataAutomatic with all custom metadata fields and a single
* root object entity projection field
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootManualMetadataAutomaticAllFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootManualMetadataAutomatic").fields(Greeting.fields().tone()).metadataFields(Greeting.fields().tone(), Greeting.fields().id(), Greeting.fields().message()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
//Manual projection on the resource method only works if it sees the message field in the projection
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
true, /*hasMessage*/
true);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataAutomaticSingleRootSingleMeta.
//The following tests operate on rootAutomaticMetadataAutomatic
/**
* Calls the resource method rootAutomaticMetadataAutomatic with a single metadata field and a single root object
* entity field
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataAutomaticSingleRootSingleMeta(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("rootAutomaticMetadataAutomatic").fields(Greeting.fields().tone()).metadataFields(Greeting.fields().message()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
false, /*hasMessage*/
false);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertCustomMetadata(metadataGreeting, false, /*hasTone*/
true, /*hasMessage*/
false);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataManualAllFields.
/**
* Calls the resource method rootAutomaticMetadataManual with all custom metadata fields and a single
* root object entity projection field
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataManualAllFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootAutomaticMetadataManual").fields(Greeting.fields().tone()).metadataFields(Greeting.fields().tone(), Greeting.fields().id(), Greeting.fields().message()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
false, /*hasMessage*/
false);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//Note here the resource method is doing manual projection, but not removing anything, so we should get all
//the fields back
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
Aggregations