use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestManualProjections method testDisableAutomaticProjection.
/**
* Hack to verify that the rest.li framework's automatic projection facility is disabled when
* "context.setProjectionMode(ProjectionMode.MANUAL)" is called by the server to disable automatic
* projection.
*
* @throws RemoteInvocationException
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testDisableAutomaticProjection(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Request<Greeting> request = builders.get().id(1L).setQueryParam("ignoreProjection", true).fields(Greeting.fields().message()).build();
Greeting greeting = getClient().sendRequest(request).getResponseEntity();
// these fields would have been excluded by the framework if automatic projection was enabled
Assert.assertTrue(greeting.hasId());
// " "
Assert.assertTrue(greeting.hasTone());
Assert.assertEquals(greeting.getMessage(), "Full greeting.");
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestNullGreetingsClient method testBatchUpdateUnsupportedNullKeyMap.
/*
* This test is one of the few areas in this test suite where we don't expect an exception.
* The purpose of this test is to make sure Rest.li can handle java.util.concurrent.ConcurrentHashMap(s) sent
* back by resource methods.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testBatchUpdateUnsupportedNullKeyMap(final RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Greeting someGreeting = new Greeting().setMessage("Hello").setTone(Tone.INSULTING);
Request<BatchKVResponse<Long, UpdateStatus>> writeRequest = builders.batchUpdate().input(7l, someGreeting).build();
Response<BatchKVResponse<Long, UpdateStatus>> response = getClient().sendRequest(writeRequest).getResponse();
Map<Long, ErrorResponse> actualErrors = response.getEntity().getErrors();
Assert.assertEquals(actualErrors.size(), 0, "Errors map should be empty");
Map<Long, UpdateStatus> actualResults = response.getEntity().getResults();
Map<Long, UpdateStatus> expectedResults = new HashMap<Long, UpdateStatus>();
UpdateStatus updateStatus = new UpdateStatus().setStatus(201);
expectedResults.put(3l, updateStatus);
Assert.assertEquals(actualResults, expectedResults, "The results map should be correct");
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestNullGreetingsClient method testNullCreateResponse.
/*
* Tests for nulls in CreateResponse
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testNullCreateResponse(final RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
//Forces the server to return a null CreateResponse
final RootBuilderWrapper.MethodBuilderWrapper<Long, Greeting, EmptyRecord> methodBuilderWrapper = builders.create();
final Greeting illGreeting = new Greeting().setMessage("nullCreateResponse").setTone(Tone.INSULTING);
createAndAssertNullMessages(methodBuilderWrapper, illGreeting);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestNullGreetingsClient method testBatchGetUnsupportedNullKeyMap.
/*
* This test is one of the few areas in this test suite where we don't expect an exception.
* The purpose of this test is to make sure Rest.li can handle java.util.concurrent.ConcurrentHashMap(s) sent
* back by resource methods.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "batchGetRequestBuilderDataProvider")
public void testBatchGetUnsupportedNullKeyMap(final BatchGetEntityRequestBuilder<Long, Greeting> builder) throws RemoteInvocationException, CloneNotSupportedException {
BatchGetEntityRequest<Long, Greeting> request = builder.ids(ImmutableSet.of(5l)).fields(Greeting.fields().id(), Greeting.fields().message()).build();
Response<BatchKVResponse<Long, EntityResponse<Greeting>>> response = getClient().sendRequest(request).getResponse();
final Greeting actualGreeting = response.getEntity().getResults().get(0l).getEntity();
Assert.assertEquals(actualGreeting.getMessage(), "Good morning!", "We should get the correct Greeting back");
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestNullGreetingsClient method sendBatchUpdateAndAssert.
private void sendBatchUpdateAndAssert(final RootBuilderWrapper<Long, Greeting> builders, Long id) throws RemoteInvocationException {
try {
final Greeting someGreeting = new Greeting().setMessage("Hello").setTone(Tone.INSULTING);
Request<BatchKVResponse<Long, UpdateStatus>> writeRequest = builders.batchUpdate().input(id, someGreeting).build();
getClient().sendRequest(writeRequest).getResponse();
} catch (final RestLiResponseException responseException) {
assertCorrectInternalServerMessageForNull(responseException, "batch_update");
}
}
Aggregations