Search in sources :

Example 1 with CustomLong

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

the class TestCustomTypesRequestBuilders method testAssociationKeys.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProviderEntity")
public void testAssociationKeys(RootBuilderWrapper<CompoundKey, Greeting> builders, ProtocolVersion version, String expectedUri) throws IOException, RestException {
    // normally coercer registration is handled in RestliAnnotationReader,
    // but that isn't run here because this is just a unit test.  So, we need to
    // force registration of the DateCoercer because it isn't contained in Date itself.
    new DateCoercer();
    CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(5L)).setDateId(new Date(13L));
    Request<Greeting> request = builders.get().id(key).build();
    checkRequestBuilder(request, ResourceMethod.GET, EntityResponseDecoder.class, expectedUri, null, version);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypes3Builders(com.linkedin.restli.examples.greetings.client.CustomTypes3Builders) DateCoercer(com.linkedin.restli.examples.custom.types.DateCoercer) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CompoundKey(com.linkedin.restli.common.CompoundKey) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 2 with CustomLong

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

the class TestCustomTypesRequestBuilders method testCollectionChildGetKey.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request4BuilderDataProviderEntity")
public void testCollectionChildGetKey(RootBuilderWrapper<CustomLong, Greeting> builders, ProtocolVersion version, String expectedUri) throws IOException, RestException {
    Request<Greeting> request = builders.get().setPathKey("customTypes2Id", new CustomLong(1L)).id(new CustomLong(7L)).build();
    checkRequestBuilder(request, ResourceMethod.GET, EntityResponseDecoder.class, expectedUri, null, version);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) Test(org.testng.annotations.Test)

Example 3 with CustomLong

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

the class TestCustomTypesRequestBuilders method testFinderCustomLongArray.

// test correct request is built for customLongArray
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request1BuilderDataProviderCustomLongArrayFinder")
public void testFinderCustomLongArray(RootBuilderWrapper<Long, Greeting> builders, ProtocolVersion version, String expectedUri) throws IOException, RestException {
    List<CustomLong> ls = new ArrayList<CustomLong>(2);
    ls.add(new CustomLong(2L));
    ls.add(new CustomLong(4L));
    Request<CollectionResponse<Greeting>> request = builders.findBy("CustomLongArray").setQueryParam("ls", ls).build();
    checkRequestBuilder(request, ResourceMethod.FINDER, CollectionResponseDecoder.class, expectedUri, null, version);
}
Also used : CollectionResponse(com.linkedin.restli.common.CollectionResponse) ArrayList(java.util.ArrayList) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) Test(org.testng.annotations.Test)

Example 4 with CustomLong

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

the class TestCustomTypesClient method testCollectionSubResourceGet.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request4BuilderDataProvider")
public void testCollectionSubResourceGet(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
    Long id2 = 2L;
    Long id4 = 4L;
    Request<Greeting> request = builders.get().setPathKey("customTypes2Id", new CustomLong(id2)).id(new CustomLong(id4)).build();
    Greeting result = getClient().sendRequest(request).getResponse().getEntity();
    Assert.assertEquals(result.getId(), new Long(id2 * id4));
}
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 5 with CustomLong

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

the class TestCustomTypesClient method testCustomLongArrayOnAction.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testCustomLongArrayOnAction(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    CustomLongRefArray ls = new CustomLongRefArray();
    ls.add(new CustomLong(1L));
    ls.add(new CustomLong(2L));
    Request<CustomLongRefArray> request = builders.<CustomLongRefArray>action("ArrayAction").setActionParam("Ls", ls).build();
    CustomLongRefArray elements = getClient().sendRequest(request).getResponse().getEntity();
    Assert.assertEquals(elements.size(), 2);
    Assert.assertEquals(elements.get(0).toLong().longValue(), 1L);
    Assert.assertEquals(elements.get(1).toLong().longValue(), 2L);
}
Also used : CustomLongRefArray(com.linkedin.restli.examples.typeref.api.CustomLongRefArray) 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