Search in sources :

Example 76 with CollectionResponse

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

the class TestPagingProjection method testMetadataManualPagingFullyAutomaticSingleMetaPagingCount.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tests operate on the resource method metadataManualPagingFullyAutomatic
/**
   * Calls the resource method metadataManualPagingFullyAutomatic with a single metadata field and a single paging
   * field for 'count'.
   */
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataManualPagingFullyAutomaticSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataManualPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).build();
    final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
    final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
    //We should ideally only get back the message field in our metadata, but the resource method here intentionally
    //sends back the message and the ID to verify that restli doesn't interfere with a manual metadata projection.
    assertGreeting(metadataGreeting, false, /*hasTone*/
    true, /*hasMessage*/
    true);
    Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
    assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
    false, /*hasStart*/
    true, /*hasCount*/
    false);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Example 77 with CollectionResponse

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

the class TestPagingProjection method testMetadataAutomaticPagingFullyAutomaticSingleMetaMultiplePaging.

/**
   * Calls the resource method metadataAutomaticPagingFullyAutomatic with a single metadata field and multiple paging
   * fields using 'links' and 'total'.
   */
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingFullyAutomaticSingleMetaMultiplePaging(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().total(), CollectionMetadata.fields().links()).build();
    final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
    final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
    assertGreeting(metadataGreeting, false, /*hasTone*/
    true, /*hasMessage*/
    false);
    Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
    assertPaging(response.getEntity().getPaging(), true, /*hasTotal*/
    false, /*hasStart*/
    false, /*hasCount*/
    true);
    final int totalCount = response.getEntity().getPaging().getTotal();
    Assert.assertEquals(totalCount, 2, "We must have 2 in our count");
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Example 78 with CollectionResponse

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

the class TestPagingProjection method testMetadataManualPagingFullyAutomaticNoFields.

/**
   * Calls the resource method metadataManualPagingFullyAutomatic without any projection fields specified
   */
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataManualPagingFullyAutomaticNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataManualPagingFullyAutomatic").metadataFields().pagingFields().build();
    final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
    final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
    //This is manual on the server, so everything should be there
    assertGreeting(metadataGreeting, true, /*hasTone*/
    true, /*hasMessage*/
    true);
    assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
    false, /*hasStart*/
    false, /*hasCount*/
    false);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Example 79 with CollectionResponse

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

the class TestPagingProjection method testMetadataAutomaticPagingFullyAutomaticSingleMetaPagingCount.

//The following tests operate on the resource method metadataAutomaticPagingFullyAutomatic
/**
   * Calls the resource method metadataAutomaticPagingFullyAutomatic with a single metadata field and a single paging
   * field for 'count'.
   */
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingFullyAutomaticSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).build();
    final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
    final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
    assertGreeting(metadataGreeting, false, /*hasTone*/
    true, /*hasMessage*/
    false);
    Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
    assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
    false, /*hasStart*/
    true, /*hasCount*/
    false);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Example 80 with CollectionResponse

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

the class TestPagingProjection method testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingCount.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tests operate on the resource method metadataAutomaticPagingAutomaticPartialNullIncorrect
/**
   * Calls the resource method metadataAutomaticPagingAutomaticPartialNullIncorrect with a single metadata field
   * and a single paging field for 'count'.
   */
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingAutomaticPartialNullIncorrect").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).build();
    final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
    final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
    assertGreeting(metadataGreeting, false, /*hasTone*/
    true, /*hasMessage*/
    false);
    Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
    assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
    false, /*hasStart*/
    true, /*hasCount*/
    false);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Aggregations

CollectionResponse (com.linkedin.restli.common.CollectionResponse)85 Test (org.testng.annotations.Test)77 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)58 CreateStatus (com.linkedin.restli.common.CreateStatus)11 ArrayList (java.util.ArrayList)7 DataMap (com.linkedin.data.DataMap)6 CollectionMetadata (com.linkedin.restli.common.CollectionMetadata)6 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)5 CreateIdStatus (com.linkedin.restli.common.CreateIdStatus)5 UpdateStatus (com.linkedin.restli.common.UpdateStatus)5 HttpStatus (com.linkedin.restli.common.HttpStatus)4 CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)4 ValidationDemo (com.linkedin.restli.examples.greetings.api.ValidationDemo)4 RootBuilderWrapper (com.linkedin.restli.test.util.RootBuilderWrapper)4 HashMap (java.util.HashMap)4 RestResponse (com.linkedin.r2.message.rest.RestResponse)3 Link (com.linkedin.restli.common.Link)3 Message (com.linkedin.restli.examples.greetings.api.Message)3 AutoValidationWithProjectionBuilders (com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionBuilders)3 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)3