use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class TestTyperefPrimitiveLongAssociationKeyResource method testGet.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testGet(RestliRequestOptions requestOptions) throws RemoteInvocationException {
GetRequest<Message> req = new TyperefPrimitiveLongAssociationKeyResourceBuilders(requestOptions).get().id(new CompoundKey().append("src", 1).append("dest", 2)).build();
Response<Message> resp = REST_CLIENT.sendRequest(req).getResponse();
Message result = resp.getEntity();
Assert.assertEquals(result.getId(), "1->2");
Assert.assertEquals(result.getMessage(), "I need some $20");
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class ComplexKeysDataProvider method batchUpdate.
public BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> batchUpdate(BatchUpdateRequest<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entities) {
final Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, UpdateResponse> results = new HashMap<ComplexResourceKey<TwoPartKey, TwoPartKey>, UpdateResponse>();
final Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, RestLiServiceException> errors = new HashMap<ComplexResourceKey<TwoPartKey, TwoPartKey>, RestLiServiceException>();
for (Map.Entry<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entry : entities.getData().entrySet()) {
if (_db.containsKey(keyToString(entry.getKey().getKey()))) {
_db.put(keyToString(entry.getKey().getKey()), entry.getValue());
results.put(entry.getKey(), new UpdateResponse(HttpStatus.S_200_OK));
} else {
errors.put(entry.getKey(), new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
}
}
return new BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(results, errors);
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class ComplexKeysResource method batchCreate.
@Override
public BatchCreateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> batchCreate(final BatchCreateRequest<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entities) {
List<CreateResponse> createResponses = new ArrayList<CreateResponse>(entities.getInput().size());
for (Message message : entities.getInput()) {
ComplexResourceKey<TwoPartKey, TwoPartKey> key = _dataProvider.create(message);
CreateResponse createResponse = new CreateResponse(key);
createResponses.add(createResponse);
}
return new BatchCreateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(createResponses);
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class AssociationsSubResource method get.
public Message get(String key) {
PathKeys pathKeys = getContext().getPathKeys();
String srcKey = pathKeys.getAsString("src");
String destKey = pathKeys.getAsString("dest");
Message message = new Message();
message.setId(srcKey);
message.setTone(Tone.FRIENDLY);
message.setMessage(destKey);
return message;
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class AssociationsSubResource method findByTone.
@Finder("tone")
public List<Message> findByTone(@QueryParam("tone") Tone tone) {
List<Message> messages = new ArrayList<Message>(2);
Message message1 = new Message();
message1.setId("one");
message1.setMessage("one");
message1.setTone(tone);
Message message2 = new Message();
message2.setId("two");
message2.setMessage("two");
message2.setTone(tone);
messages.add(message1);
messages.add(message2);
return messages;
}
Aggregations