use of com.linkedin.restli.examples.greetings.client.AssociationsFluentClient 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);
}
use of com.linkedin.restli.examples.greetings.client.AssociationsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testAssociationFinderUsingAssocKey.
@Test
public void testAssociationFinderUsingAssocKey() throws Exception {
AssociationsFluentClient associations = new AssociationsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CollectionResponse<Message> messages = associations.findByAssocKeyFinder(AssociationResourceHelpers.URL_COMPOUND_KEY.getPartAsString("src")).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(messages.getElements().size() > 0);
for (Message message : messages.getElements()) {
Assert.assertEquals(message.getId(), AssociationResourceHelpers.URL_MESSAGE.getId());
}
}
use of com.linkedin.restli.examples.greetings.client.AssociationsFluentClient 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");
}
use of com.linkedin.restli.examples.greetings.client.AssociationsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testAssociateResourceGet.
@Test
public void testAssociateResourceGet() throws Exception {
Associations associations = new AssociationsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Message response = associations.get(getAssociateResourceUrlKey(associations)).toCompletableFuture().get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(response.hasId());
}
use of com.linkedin.restli.examples.greetings.client.AssociationsFluentClient 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);
}
Aggregations