Search in sources :

Example 16 with CustomLong

use of com.linkedin.restli.examples.custom.types.CustomLong in project rest.li by linkedin.

the class TestCustomTypesClient method testCollectionBatchGetKV.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testCollectionBatchGetKV(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    Request<BatchKVResponse<CustomLong, Greeting>> request = new CustomTypes2Builders(requestOptions).batchGet().ids(new CustomLong(1L), new CustomLong(2L), new CustomLong(3L)).buildKV();
    Map<CustomLong, Greeting> greetings = getClient().sendRequest(request).getResponse().getEntity().getResults();
    Assert.assertEquals(greetings.size(), 3);
    Assert.assertEquals(greetings.get(new CustomLong(1L)).getId().longValue(), 1L);
    Assert.assertEquals(greetings.get(new CustomLong(2L)).getId().longValue(), 2L);
    Assert.assertEquals(greetings.get(new CustomLong(3L)).getId().longValue(), 3L);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) CustomTypes2Builders(com.linkedin.restli.examples.greetings.client.CustomTypes2Builders) Test(org.testng.annotations.Test)

Example 17 with CustomLong

use of com.linkedin.restli.examples.custom.types.CustomLong in project rest.li by linkedin.

the class TestCustomTypesClient method testCollectionBatchPartialUpdate.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BuilderDataProvider")
public void testCollectionBatchPartialUpdate(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
    RequestBuilder<? extends Request<BatchKVResponse<CustomLong, UpdateStatus>>> request = builders.batchPartialUpdate().input(new CustomLong(1L), new PatchRequest<Greeting>()).input(new CustomLong(2L), new PatchRequest<Greeting>()).getBuilder();
    Map<CustomLong, UpdateStatus> statuses = getClient().sendRequest(request).getResponse().getEntity().getResults();
    Assert.assertEquals(statuses.size(), 2);
    Assert.assertEquals(statuses.get(new CustomLong(1L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
    Assert.assertEquals(statuses.get(new CustomLong(2L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) UpdateStatus(com.linkedin.restli.common.UpdateStatus) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) PatchRequest(com.linkedin.restli.common.PatchRequest) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Example 18 with CustomLong

use of com.linkedin.restli.examples.custom.types.CustomLong in project rest.li by linkedin.

the class TestCustomTypesClient method testCollectionBatchUpdate.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BuilderDataProvider")
public void testCollectionBatchUpdate(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
    RequestBuilder<? extends Request<BatchKVResponse<CustomLong, UpdateStatus>>> request = builders.batchUpdate().input(new CustomLong(1L), new Greeting().setId(1)).input(new CustomLong(2L), new Greeting().setId(2)).getBuilder();
    Map<CustomLong, UpdateStatus> statuses = getClient().sendRequest(request).getResponse().getEntity().getResults();
    Assert.assertEquals(statuses.size(), 2);
    Assert.assertEquals(statuses.get(new CustomLong(1L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
    Assert.assertEquals(statuses.get(new CustomLong(2L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) UpdateStatus(com.linkedin.restli.common.UpdateStatus) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Example 19 with CustomLong

use of com.linkedin.restli.examples.custom.types.CustomLong in project rest.li by linkedin.

the class TestCustomTypesClient method testCollectionGet.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BuilderDataProvider")
public void testCollectionGet(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
    Long lo = 5L;
    Request<Greeting> request = builders.get().id(new CustomLong(lo)).build();
    Greeting result = getClient().sendRequest(request).getResponse().getEntity();
    Assert.assertEquals(result.getId(), lo);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) Test(org.testng.annotations.Test)

Example 20 with CustomLong

use of com.linkedin.restli.examples.custom.types.CustomLong in project rest.li by linkedin.

the class TestCustomTypesClient method testAction.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testAction(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    Long lo = 5L;
    Request<Long> request = builders.<Long>action("Action").setActionParam("L", new CustomLong(lo)).build();
    Long result = getClient().sendRequest(request).getResponse().getEntity();
    Assert.assertEquals(result, lo);
}
Also used : CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) Test(org.testng.annotations.Test)

Aggregations

CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)23 Test (org.testng.annotations.Test)22 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)19 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)6 CustomNonNegativeLong (com.linkedin.restli.examples.custom.types.CustomNonNegativeLong)5 CustomTypes2Builders (com.linkedin.restli.examples.greetings.client.CustomTypes2Builders)5 CollectionResponse (com.linkedin.restli.common.CollectionResponse)4 CustomTypes2RequestBuilders (com.linkedin.restli.examples.greetings.client.CustomTypes2RequestBuilders)4 Date (java.util.Date)4 ByteString (com.linkedin.data.ByteString)3 CompoundKey (com.linkedin.restli.common.CompoundKey)3 UpdateStatus (com.linkedin.restli.common.UpdateStatus)3 CustomTypes3Builders (com.linkedin.restli.examples.greetings.client.CustomTypes3Builders)3 BatchCreateIdResponse (com.linkedin.restli.common.BatchCreateIdResponse)2 BatchResponse (com.linkedin.restli.common.BatchResponse)2 CreateIdStatus (com.linkedin.restli.common.CreateIdStatus)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 CreateResponse (com.linkedin.restli.client.response.CreateResponse)1 CreateStatus (com.linkedin.restli.common.CreateStatus)1