Search in sources :

Example 1 with AssociationsAssociationsSubFluentClient

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

the class TestParseqBasedFluentClientApi method testSubResource_twoLayerAssociationPathKey.

/**
 * Test {@link com.linkedin.restli.examples.greetings.server.AssociationsAssociationsSubResource}
 */
@Test
public void testSubResource_twoLayerAssociationPathKey() throws Exception {
    // AssociationsAssociations
    String src = "src";
    String anotherSrc = "anotherSrc";
    String dest = "dest";
    String anotherDest = "anotherDest";
    String subKey = "subKey";
    CompoundKey key1 = new AssociationsFluentClient.Key().setSrc(src).setDest(dest);
    CompoundKey key2 = new AssociationsAssociationsFluentClient.Key().setAnotherSrc(anotherSrc).setAnotherDest(anotherDest);
    AssociationsAssociationsSubFluentClient subFluentClient = new AssociationsAssociationsSubFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    Message response = subFluentClient.withAssociationsId(key1).withAssociationsAssociationsId(key2).get(subKey).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getId(), src + anotherSrc + subKey);
    Assert.assertEquals(response.getMessage(), dest + anotherDest);
    // Repeat using sub client generated from parent
    Associations.AssociationsAssociations.AssociationsAssociationsSub subFluentClient2 = new AssociationsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine()).associationsAssociationsOf(key1).associationsAssociationsSubOf(key2);
    response = subFluentClient2.get(subKey).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getId(), src + anotherSrc + subKey);
    Assert.assertEquals(response.getMessage(), dest + anotherDest);
}
Also used : AssociationsAssociationsSubFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsSubFluentClient) Message(com.linkedin.restli.examples.greetings.api.Message) CompoundKey(com.linkedin.restli.common.CompoundKey) AssociationsAssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsFluentClient) AssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsFluentClient) AssociationAltKey(com.linkedin.restli.examples.greetings.client.AssociationAltKey) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) TwoPartKey(com.linkedin.restli.examples.greetings.api.TwoPartKey) CompoundKey(com.linkedin.restli.common.CompoundKey) Test(org.testng.annotations.Test)

Aggregations

ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)1 CompoundKey (com.linkedin.restli.common.CompoundKey)1 Message (com.linkedin.restli.examples.greetings.api.Message)1 TwoPartKey (com.linkedin.restli.examples.greetings.api.TwoPartKey)1 AssociationAltKey (com.linkedin.restli.examples.greetings.client.AssociationAltKey)1 AssociationsAssociationsFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsAssociationsFluentClient)1 AssociationsAssociationsSubFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsAssociationsSubFluentClient)1 AssociationsFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsFluentClient)1 Test (org.testng.annotations.Test)1