Search in sources :

Example 1 with AssociationsSubFluentClient

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

the class TestParseqBasedFluentClientApi method testSubResource_associationKey.

/**
 * Test {@link com.linkedin.restli.examples.greetings.server.AssociationsSubResource}
 *
 * A complete set of request tests were tested in {@link TestAssociationsResource}
 */
@Test
public void testSubResource_associationKey() throws Exception {
    // AssociationsSub
    String src = "src";
    String dest = "dest";
    String subKey = "subKey";
    CompoundKey key1 = new AssociationsFluentClient.Key().setSrc(src).setDest(dest);
    AssociationsSubFluentClient subFluentClient = new AssociationsSubFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    Message response = subFluentClient.withAssociationsId(key1).get(subKey).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getId(), "src");
    Assert.assertEquals(response.getMessage(), "dest");
    // Repeat using sub client generated from parent
    Associations.AssociationsSub subFluentClient2 = new AssociationsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine()).associationsSubOf(key1);
    response = subFluentClient2.get(subKey).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(response.getId(), "src");
    Assert.assertEquals(response.getMessage(), "dest");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) CompoundKey(com.linkedin.restli.common.CompoundKey) AssociationsSubFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsSubFluentClient) AssociationsAssociationsSubFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsSubFluentClient) Associations(com.linkedin.restli.examples.greetings.client.Associations) 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 Associations (com.linkedin.restli.examples.greetings.client.Associations)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 AssociationsSubFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsSubFluentClient)1 Test (org.testng.annotations.Test)1