Search in sources :

Example 26 with Message

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();
}
Also used : EmptyRecord(com.linkedin.restli.common.EmptyRecord) Message(com.linkedin.restli.examples.greetings.api.Message) Test(org.testng.annotations.Test)

Example 27 with Message

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");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) Test(org.testng.annotations.Test)

Example 28 with Message

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)");
}
Also used : TwoPartKey(com.linkedin.restli.examples.greetings.api.TwoPartKey) Message(com.linkedin.restli.examples.greetings.api.Message) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) Test(org.testng.annotations.Test)

Example 29 with Message

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");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) StringKeysBuilders(com.linkedin.restli.examples.greetings.client.StringKeysBuilders) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 30 with Message

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)");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) CompoundKey(com.linkedin.restli.common.CompoundKey) Test(org.testng.annotations.Test)

Aggregations

Message (com.linkedin.restli.examples.greetings.api.Message)38 Test (org.testng.annotations.Test)17 TwoPartKey (com.linkedin.restli.examples.greetings.api.TwoPartKey)13 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)11 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 EntityResponse (com.linkedin.restli.common.EntityResponse)6 HashSet (java.util.HashSet)6 CompoundKey (com.linkedin.restli.common.CompoundKey)5 DataMap (com.linkedin.data.DataMap)4 EmptyRecord (com.linkedin.restli.common.EmptyRecord)4 Map (java.util.Map)4 CollectionResponse (com.linkedin.restli.common.CollectionResponse)3 UpdateStatus (com.linkedin.restli.common.UpdateStatus)3 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)3 UpdateResponse (com.linkedin.restli.server.UpdateResponse)3 BatchCreateIdResponse (com.linkedin.restli.common.BatchCreateIdResponse)2 StringKeysBuilders (com.linkedin.restli.examples.greetings.client.StringKeysBuilders)2 StringKeysRequestBuilders (com.linkedin.restli.examples.greetings.client.StringKeysRequestBuilders)2