use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestAsyncExceptions method testTask.
@Test(dataProvider = "exceptionProvider")
public void testTask(String key, int expectedStatus) throws RemoteInvocationException {
AsyncErrorsBuilders builder = new AsyncErrorsBuilders();
Request<Greeting> request = builder.actionTask().paramId(key).build();
try {
getClient().sendRequest(request).getResponse();
Assert.fail("This request should have failed.");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), expectedStatus);
}
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestAsyncExceptions method testCallback.
@Test(dataProvider = "exceptionProvider")
public void testCallback(String key, int expectedStatus) throws RemoteInvocationException {
AsyncErrorsBuilders builder = new AsyncErrorsBuilders();
Request<Greeting> request = builder.actionCallback().paramId(key).build();
try {
getClient().sendRequest(request).getResponse();
Assert.fail("This request should have failed.");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), expectedStatus);
}
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestComplexArrayResource method testGet.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testGet(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException, CloneNotSupportedException {
// all array are singletons with single element
LongArray singleton = new LongArray();
singleton.add(1L);
ComplexArray next = new ComplexArray().setArray(singleton);
ComplexArray key = new ComplexArray().setArray(singleton).setNext(next);
ComplexArray params = new ComplexArray().setArray(singleton).setNext(next);
ComplexResourceKey<ComplexArray, ComplexArray> complexKey = new ComplexResourceKey<ComplexArray, ComplexArray>(key, params);
Request<Greeting> request = builders.get().id(complexKey).build();
getClient().sendRequest(request).getResponse().getEntity();
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestScatterGather method testBuildSGRequests.
public static void testBuildSGRequests(int endPointsNum, int partitionNum, RootBuilderWrapper<Long, Greeting> builders) throws URISyntaxException, RestException, ServiceUnavailableException {
final int NUM_ENDPOINTS = endPointsNum;
ConsistentHashKeyMapper mapper;
if (partitionNum > 0) {
mapper = getKeyToHostMapper(endPointsNum, partitionNum);
} else {
mapper = getKeyToHostMapper(endPointsNum);
}
ScatterGatherBuilder<Greeting> sg = new ScatterGatherBuilder<Greeting>(mapper);
final int NUM_IDS = 100;
Long[] ids = generateIds(NUM_IDS);
Map<Long, Greeting> updates = generateUpdates(ids);
testBuildSGGetRequests(NUM_ENDPOINTS, sg, ids);
testBuildSGDeleteRequests(NUM_ENDPOINTS, sg, ids, builders);
testBuildSGUpdateRequests(NUM_ENDPOINTS, sg, updates, builders);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestScatterGather method testBuildSGGetKVRequests.
private static void testBuildSGGetKVRequests(int numEndpoints, ScatterGatherBuilder<Greeting> sg, Long[] ids) throws ServiceUnavailableException {
Collection<ScatterGatherBuilder.KVRequestInfo<Long, Greeting>> requests = buildScatterGatherGetKVRequests(sg, ids);
Assert.assertEquals(requests.size(), numEndpoints);
Set<Set<String>> requestIdSets = new HashSet<Set<String>>();
Set<Long> requestIds = new HashSet<Long>();
for (ScatterGatherBuilder.KVRequestInfo<Long, Greeting> requestInfo : requests) {
//URI will be something like "greetings/?ids=21&ids=4&ids=53&ids=60&ids=66&ids=88&ids=93&foo=bar"
BatchRequest<BatchKVResponse<Long, Greeting>> request = requestInfo.getRequest();
Set<String> expectedParams = new HashSet<String>();
expectedParams.add(RestConstants.QUERY_BATCH_IDS_PARAM);
expectedParams.add("foo");
expectedParams.add(RestConstants.FIELDS_PARAM);
Set<PathSpec> expectedFields = Collections.singleton(new PathSpec("message"));
testRequest(request, expectedParams, expectedFields, null, requestIdSets, requestIds);
}
Assert.assertTrue(requestIds.containsAll(Arrays.asList(ids)));
Assert.assertEquals(requestIds.size(), ids.length);
}
Aggregations