use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestAssociationsResource method testCreate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider", expectedExceptions = UnsupportedOperationException.class)
@SuppressWarnings("deprecation")
public void testCreate(RootBuilderWrapper<CompoundKey, Message> builders) throws Exception {
// Associations should never support create operations. This is a bug in Rest.li that will be fixed. For now we want
// to make sure that creating and then calling getId() on the response throws an exception.
Request<EmptyRecord> request = builders.create().input(new Message().setMessage("foo")).build();
getClient().sendRequest(request).getResponse().getId();
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestAssociationsResource method testSubresourceGet.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubBuilderDataProvider")
public void testSubresourceGet(RootBuilderWrapper<String, Message> builders) throws RemoteInvocationException {
Request<Message> request = builders.get().setPathKey("dest", "dest").setPathKey("src", "src").id("id").build();
Message message = getClient().sendRequest(request).getResponse().getEntity();
Assert.assertEquals(message.getId(), "src");
Assert.assertEquals(message.getMessage(), "dest");
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestEscapeCharsInStringKeys method testGetWithComplexKey.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestComplexKeysBuilderDataProvider")
public void testGetWithComplexKey(RootBuilderWrapper<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> builders) throws Exception {
TwoPartKey key = new TwoPartKey();
key.setMajor(key1());
key.setMinor(key2());
TwoPartKey params = new TwoPartKey();
params.setMajor(key1());
params.setMinor(key3());
ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey = new ComplexResourceKey<TwoPartKey, TwoPartKey>(key, params);
Request<Message> request = builders.get().id(complexKey).build();
Message response = getClient().sendRequest(request).get().getEntity();
Assert.assertNotNull(response);
Assert.assertEquals(response.getId(), key.getMajor() + " " + key.getMinor(), "Message should be key1 + ' ' + key2 for complexKey(key1,key2)");
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestEscapeCharsInStringKeys method testBatchGetKVWithSimpleKey.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestStringKeysOptionsDataProvider")
public void testBatchGetKVWithSimpleKey(RestliRequestOptions requestOptions) throws Exception {
Set<String> keys = new HashSet<String>();
keys.add(key1());
keys.add(key2());
Request<BatchKVResponse<String, Message>> req = new StringKeysBuilders(requestOptions).batchGet().ids(keys).buildKV();
BatchKVResponse<String, Message> response = getClient().sendRequest(req).get().getEntity();
Map<String, Message> results = response.getResults();
Assert.assertEquals(results.get(key1()).getMessage(), key1(), "Message should match key for key1");
Assert.assertEquals(results.get(key2()).getMessage(), key2(), "Message should match key for key2");
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestEscapeCharsInStringKeys method testGetWithAssociationKey.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestAssociationsSubBuilderDataProvider")
public void testGetWithAssociationKey(RootBuilderWrapper<CompoundKey, Message> builders) throws Exception {
CompoundKey key = new CompoundKey();
key.append("src", key1());
key.append("dest", key2());
Request<Message> request = builders.get().id(key).build();
Message response = getClient().sendRequest(request).get().getEntity();
Assert.assertNotNull(response);
Assert.assertEquals(response.getId(), key.getPart("src") + " " + key.getPart("dest"), "Message should be key1 + ' ' + key2 for associationKey(key1,key2)");
}
Aggregations