Search in sources :

Example 1 with CustomNonNegativeLong

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

the class ChainedTyperefResource method get.

@Override
public Greeting get(CompoundKey key) {
    CustomNonNegativeLong age = (CustomNonNegativeLong) key.getPart("age");
    Date birthday = (Date) key.getPart("birthday");
    return new Greeting().setId(age.toLong() + birthday.getTime());
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) Date(java.util.Date)

Example 2 with CustomNonNegativeLong

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

the class TestCustomTypesClient method testBatchUpdateForChainedRefs.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestChainedTyperefsBuilderDataProvider")
public void testBatchUpdateForChainedRefs(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException {
    Long lo = 29L;
    Long date = 10L;
    ChainedTyperefsBuilders.Key key = new ChainedTyperefsBuilders.Key().setAge(new CustomNonNegativeLong(lo)).setBirthday(new Date(date));
    RequestBuilder<? extends Request<BatchKVResponse<CompoundKey, UpdateStatus>>> batchUpdateRequest = builders.batchUpdate().input(key, new Greeting().setId(1).setMessage("foo")).getBuilder();
    BatchKVResponse<CompoundKey, UpdateStatus> response = getClient().sendRequest(batchUpdateRequest).getResponse().getEntity();
    Assert.assertEquals(1, response.getResults().keySet().size());
    CompoundKey expected = new CompoundKey();
    expected.append("birthday", new Date(date));
    expected.append("age", new CustomNonNegativeLong(lo));
    CompoundKey result = response.getResults().keySet().iterator().next();
    Assert.assertEquals(result, expected);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) UpdateStatus(com.linkedin.restli.common.UpdateStatus) CompoundKey(com.linkedin.restli.common.CompoundKey) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) ChainedTyperefsBuilders(com.linkedin.restli.examples.greetings.client.ChainedTyperefsBuilders) CompoundKey(com.linkedin.restli.common.CompoundKey) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) Date(java.util.Date) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Aggregations

CustomNonNegativeLong (com.linkedin.restli.examples.custom.types.CustomNonNegativeLong)2 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)2 Date (java.util.Date)2 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1 CompoundKey (com.linkedin.restli.common.CompoundKey)1 UpdateStatus (com.linkedin.restli.common.UpdateStatus)1 CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)1 ChainedTyperefsBuilders (com.linkedin.restli.examples.greetings.client.ChainedTyperefsBuilders)1 Test (org.testng.annotations.Test)1