Search in sources :

Example 11 with CustomLong

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

the class TestCustomTypesClient method testCollectionCreate.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testCollectionCreate(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    CreateRequest<Greeting> request = new CustomTypes2Builders(requestOptions).create().input(new Greeting().setId(10)).build();
    Response<EmptyRecord> response = getClient().sendRequest(request).getResponse();
    Assert.assertEquals(response.getStatus(), HttpStatus.S_201_CREATED.getCode());
    @SuppressWarnings("unchecked") CreateResponse<CustomLong> createResponse = (CreateResponse<CustomLong>) response.getEntity();
    Assert.assertEquals(createResponse.getId(), new CustomLong(10L));
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) EmptyRecord(com.linkedin.restli.common.EmptyRecord) CreateResponse(com.linkedin.restli.client.response.CreateResponse) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomTypes2Builders(com.linkedin.restli.examples.greetings.client.CustomTypes2Builders) Test(org.testng.annotations.Test)

Example 12 with CustomLong

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

the class TestCustomTypesRequestBuilders method testCollectionBatchGetKey.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BatchDataProvider")
public void testCollectionBatchGetKey(ProtocolVersion version, String expectedUri) throws IOException, RestException {
    Request<BatchResponse<Greeting>> request = new CustomTypes2Builders().batchGet().ids(new CustomLong(1L), new CustomLong(2L), new CustomLong(3L)).build();
    checkRequestBuilder(request, ResourceMethod.BATCH_GET, BatchResponseDecoder.class, expectedUri, null, version);
}
Also used : BatchResponse(com.linkedin.restli.common.BatchResponse) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomTypes2Builders(com.linkedin.restli.examples.greetings.client.CustomTypes2Builders) Test(org.testng.annotations.Test)

Example 13 with CustomLong

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

the class TestCustomTypesClient method testCollectionBatchGet.

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

Example 14 with CustomLong

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

the class TestCustomTypesClient method testAssociationGet.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProvider")
public void testAssociationGet(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException {
    Long lo = 5L;
    Long date = 13L;
    CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(lo)).setDateId(new Date(date));
    Request<Greeting> request = builders.get().id(key).build();
    Greeting result = getClient().sendRequest(request).getResponse().getEntity();
    Assert.assertEquals(result.getId(), new Long(lo + date));
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypes3Builders(com.linkedin.restli.examples.greetings.client.CustomTypes3Builders) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CompoundKey(com.linkedin.restli.common.CompoundKey) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 15 with CustomLong

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

the class TestCustomTypesClient method testCollectionCreateId.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testCollectionCreateId(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    CreateIdRequest<CustomLong, Greeting> request = new CustomTypes2RequestBuilders(requestOptions).create().input(new Greeting().setId(10)).build();
    Response<IdResponse<CustomLong>> response = getClient().sendRequest(request).getResponse();
    Assert.assertEquals(response.getStatus(), HttpStatus.S_201_CREATED.getCode());
    Assert.assertEquals(response.getEntity().getId(), new CustomLong(10L));
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) BatchCreateIdResponse(com.linkedin.restli.common.BatchCreateIdResponse) IdResponse(com.linkedin.restli.common.IdResponse) CustomTypes2RequestBuilders(com.linkedin.restli.examples.greetings.client.CustomTypes2RequestBuilders) 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