Search in sources :

Example 1 with ComplexKeysSubFluentClient

use of com.linkedin.restli.examples.greetings.client.ComplexKeysSubFluentClient in project rest.li by linkedin.

the class TestParseqBasedFluentClientApi method testSubResource_complexKeyParentResource.

/**
 * Test {@link com.linkedin.restli.server.resources.ComplexKeyResource}
 *
 * A complete set of request tests were tested in {@link TestComplexKeysResource}
 */
@Test
public void testSubResource_complexKeyParentResource() throws Exception {
    TwoPartKey key = new TwoPartKey();
    key.setMajor("a");
    key.setMinor("b");
    TwoPartKey param = new TwoPartKey();
    param.setMajor("c");
    param.setMinor("d");
    ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey = new ComplexResourceKey<>(key, param);
    ComplexKeysSubFluentClient subFluentClient = new ComplexKeysSubFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    subFluentClient.withKeys(complexKey);
    TwoPartKey response = subFluentClient.get("stringKey").toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getMajor(), "aANDc");
    Assert.assertEquals(response.getMinor(), "bANDd");
    // Repeat using sub client generated from parent
    ComplexKeys.ComplexKeysSub subFluentClient2 = new ComplexKeysFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine()).complexKeysSubOf(complexKey);
    response = subFluentClient2.get("stringKey").toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getMajor(), "aANDc");
    Assert.assertEquals(response.getMinor(), "bANDd");
}
Also used : TwoPartKey(com.linkedin.restli.examples.greetings.api.TwoPartKey) ComplexKeys(com.linkedin.restli.examples.greetings.client.ComplexKeys) ComplexKeysFluentClient(com.linkedin.restli.examples.greetings.client.ComplexKeysFluentClient) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) ComplexKeysSubFluentClient(com.linkedin.restli.examples.greetings.client.ComplexKeysSubFluentClient) Test(org.testng.annotations.Test)

Aggregations

ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)1 TwoPartKey (com.linkedin.restli.examples.greetings.api.TwoPartKey)1 ComplexKeys (com.linkedin.restli.examples.greetings.client.ComplexKeys)1 ComplexKeysFluentClient (com.linkedin.restli.examples.greetings.client.ComplexKeysFluentClient)1 ComplexKeysSubFluentClient (com.linkedin.restli.examples.greetings.client.ComplexKeysSubFluentClient)1 Test (org.testng.annotations.Test)1