Search in sources :

Example 1 with MessageCriteriaArray

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

the class TestParseqBasedFluentClientApi method testAssociationBatchFinderUsingAssocKey.

@Test
public void testAssociationBatchFinderUsingAssocKey() throws Exception {
    AssociationsFluentClient associations = new AssociationsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    MessageCriteriaArray criteriaArray = new MessageCriteriaArray();
    criteriaArray.add(new MessageCriteria().setTone(Tone.FRIENDLY));
    criteriaArray.add(new MessageCriteria().setTone(Tone.INSULTING));
    BatchCollectionResponse<Message> messages = associations.findBySearchMessages(AssociationResourceHelpers.URL_COMPOUND_KEY.getPartAsString("src"), criteriaArray).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(messages.getResults().size(), 2);
    BatchFinderCriteriaResult<Message> friendly = messages.getResults().get(0);
    Assert.assertFalse(friendly.isError());
    for (Message message : friendly.getElements()) {
        Assert.assertEquals(message.getTone(), Tone.FRIENDLY);
    }
    BatchFinderCriteriaResult<Message> insulting = messages.getResults().get(1);
    Assert.assertTrue(insulting.isError());
    Assert.assertEquals((int) insulting.getError().getStatus(), 404);
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) MessageCriteria(com.linkedin.restli.examples.greetings.api.MessageCriteria) MessageCriteriaArray(com.linkedin.restli.examples.greetings.api.MessageCriteriaArray) AssociationsAssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsFluentClient) AssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsFluentClient) Test(org.testng.annotations.Test)

Aggregations

Message (com.linkedin.restli.examples.greetings.api.Message)1 MessageCriteria (com.linkedin.restli.examples.greetings.api.MessageCriteria)1 MessageCriteriaArray (com.linkedin.restli.examples.greetings.api.MessageCriteriaArray)1 AssociationsAssociationsFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsAssociationsFluentClient)1 AssociationsFluentClient (com.linkedin.restli.examples.greetings.client.AssociationsFluentClient)1 Test (org.testng.annotations.Test)1