Search in sources :

Example 1 with ComplexArray

use of com.linkedin.restli.examples.greetings.api.ComplexArray in project rest.li by linkedin.

the class TestComplexArrayResource method testGet.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testGet(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException, CloneNotSupportedException {
    // all array are singletons with single element
    LongArray singleton = new LongArray();
    singleton.add(1L);
    ComplexArray next = new ComplexArray().setArray(singleton);
    ComplexArray key = new ComplexArray().setArray(singleton).setNext(next);
    ComplexArray params = new ComplexArray().setArray(singleton).setNext(next);
    ComplexResourceKey<ComplexArray, ComplexArray> complexKey = new ComplexResourceKey<ComplexArray, ComplexArray>(key, params);
    Request<Greeting> request = builders.get().id(complexKey).build();
    getClient().sendRequest(request).getResponse().getEntity();
}
Also used : LongArray(com.linkedin.data.template.LongArray) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) ComplexArray(com.linkedin.restli.examples.greetings.api.ComplexArray) Test(org.testng.annotations.Test)

Example 2 with ComplexArray

use of com.linkedin.restli.examples.greetings.api.ComplexArray in project rest.li by linkedin.

the class TestComplexArrayResource method testAction.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testAction(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException {
    LongArray singleton = new LongArray();
    singleton.add(1L);
    ComplexArray next = new ComplexArray().setArray(singleton);
    ComplexArray array = new ComplexArray().setArray(singleton).setNext(next);
    Request<Integer> request = builders.<Integer>action("Action").setActionParam("Array", array).build();
    getClient().sendRequest(request).getResponse().getEntity();
}
Also used : LongArray(com.linkedin.data.template.LongArray) ComplexArray(com.linkedin.restli.examples.greetings.api.ComplexArray) Test(org.testng.annotations.Test)

Example 3 with ComplexArray

use of com.linkedin.restli.examples.greetings.api.ComplexArray in project rest.li by linkedin.

the class TestComplexArrayResource method testBatchGetEntity.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versionWithRequestOptionsDataProvider")
public void testBatchGetEntity(ProtocolVersion version, RestliRequestOptions options) throws RemoteInvocationException {
    List<ComplexResourceKey<ComplexArray, ComplexArray>> complexKeys = getBatchCompleKeys();
    ComplexArrayRequestBuilders builders = new ComplexArrayRequestBuilders(options);
    Request<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, EntityResponse<Greeting>>> request2 = builders.batchGet().ids(complexKeys).build();
    Response<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, EntityResponse<Greeting>>> response2 = getClient().sendRequest(request2).getResponse();
    EntityResponse<Greeting> greeting1 = response2.getEntity().getResults().get(complexKeys.get(0));
    Assert.assertNotNull(greeting1);
    EntityResponse<Greeting> greeting2 = response2.getEntity().getResults().get(complexKeys.get(1));
    Assert.assertNotNull(greeting2);
}
Also used : ComplexArrayRequestBuilders(com.linkedin.restli.examples.greetings.client.ComplexArrayRequestBuilders) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) ComplexArray(com.linkedin.restli.examples.greetings.api.ComplexArray) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Example 4 with ComplexArray

use of com.linkedin.restli.examples.greetings.api.ComplexArray in project rest.li by linkedin.

the class TestComplexArrayResource method testBatchGetKV.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versionWithRequestOptionsDataProvider")
public void testBatchGetKV(ProtocolVersion version, RestliRequestOptions options) throws RemoteInvocationException {
    List<ComplexResourceKey<ComplexArray, ComplexArray>> complexKeys = getBatchCompleKeys();
    ComplexArrayBuilders builders = new ComplexArrayBuilders(options);
    Request<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting>> request2 = builders.batchGet().ids(complexKeys).buildKV();
    Response<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting>> response2 = getClient().sendRequest(request2).getResponse();
    Greeting greeting1 = response2.getEntity().getResults().get(complexKeys.get(0));
    Assert.assertNotNull(greeting1);
    Greeting greeting2 = response2.getEntity().getResults().get(complexKeys.get(1));
    Assert.assertNotNull(greeting2);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ComplexArrayBuilders(com.linkedin.restli.examples.greetings.client.ComplexArrayBuilders) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) ComplexArray(com.linkedin.restli.examples.greetings.api.ComplexArray) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Example 5 with ComplexArray

use of com.linkedin.restli.examples.greetings.api.ComplexArray in project rest.li by linkedin.

the class TestComplexArrayResource method getBatchCompleKeys.

private static List<ComplexResourceKey<ComplexArray, ComplexArray>> getBatchCompleKeys() {
    LongArray singleton1 = new LongArray();
    singleton1.add(1L);
    ComplexArray next1 = new ComplexArray().setArray(singleton1);
    ComplexArray key1 = new ComplexArray().setArray(singleton1).setNext(next1);
    ComplexArray params1 = new ComplexArray().setArray(singleton1).setNext(next1);
    ComplexResourceKey<ComplexArray, ComplexArray> complexKey1 = new ComplexResourceKey<ComplexArray, ComplexArray>(key1, params1);
    LongArray singleton2 = new LongArray();
    singleton2.add(2L);
    ComplexArray next2 = new ComplexArray().setArray(singleton2);
    ComplexArray key2 = new ComplexArray().setArray(singleton2).setNext(next2);
    ComplexArray params2 = new ComplexArray().setArray(singleton2).setNext(next2);
    ComplexResourceKey<ComplexArray, ComplexArray> complexKey2 = new ComplexResourceKey<ComplexArray, ComplexArray>(key2, params2);
    List<ComplexResourceKey<ComplexArray, ComplexArray>> complexKeys = new ArrayList<ComplexResourceKey<ComplexArray, ComplexArray>>();
    complexKeys.add(complexKey1);
    complexKeys.add(complexKey2);
    return complexKeys;
}
Also used : LongArray(com.linkedin.data.template.LongArray) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) ArrayList(java.util.ArrayList) ComplexArray(com.linkedin.restli.examples.greetings.api.ComplexArray)

Aggregations

ComplexArray (com.linkedin.restli.examples.greetings.api.ComplexArray)7 Test (org.testng.annotations.Test)6 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)5 LongArray (com.linkedin.data.template.LongArray)4 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)4 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)3 ComplexArrayBuilders (com.linkedin.restli.examples.greetings.client.ComplexArrayBuilders)2 CollectionResponse (com.linkedin.restli.common.CollectionResponse)1 ComplexArrayRequestBuilders (com.linkedin.restli.examples.greetings.client.ComplexArrayRequestBuilders)1 ArrayList (java.util.ArrayList)1