use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testCreateCompoundKeyRequestBuilder.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "noEntity")
public void testCreateCompoundKeyRequestBuilder(URIDetails expectedURIDetails) {
CreateRequestBuilder<CompoundKey, TestRecord> builder = new CreateRequestBuilder<CompoundKey, TestRecord>(TEST_URI, TestRecord.class, _ASSOC_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
TestRecord record = new TestRecord().setMessage("foo");
CreateRequest<TestRecord> request = builder.input(record).build();
Assert.assertEquals(request.isSafe(), false);
Assert.assertEquals(request.isIdempotent(), false);
testBaseUriGeneration(request, expectedURIDetails.getProtocolVersion());
checkBasicRequest(request, expectedURIDetails, ResourceMethod.CREATE, record, Collections.<String, String>emptyMap(), null);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method buildComplexKey.
/**
* Helper method to build complex key instance
*/
private ComplexResourceKey<TestRecord, TestRecord> buildComplexKey(long keyId, String keyMessage, long paramId, String paramMessage) {
ComplexResourceKey<TestRecord, TestRecord> id = new ComplexResourceKey<TestRecord, TestRecord>(new TestRecord(), new TestRecord());
id.getKey().setId(keyId);
id.getKey().setMessage(keyMessage);
id.getParams().setId(paramId);
id.getParams().setMessage(paramMessage);
return id;
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestSingleEntityRequestBuilder method testInputReadOnliness.
@Test()
public void testInputReadOnliness() {
SingleEntityRequestBuilder<Object, TestRecord, ?> builder = new DummySingleEntityRequestBuilder();
TestRecord originalInput = new TestRecord();
builder.input(originalInput);
Assert.assertNotSame(builder.buildReadOnlyInput(), originalInput);
originalInput.data().makeReadOnly();
Assert.assertSame(builder.buildReadOnlyInput(), originalInput);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestMultiplexedCallback method testSuccess.
@Test
public void testSuccess() throws Exception {
FutureCallback<RestResponse> callback1 = new FutureCallback<RestResponse>();
FutureCallback<RestResponse> callback2 = new FutureCallback<RestResponse>();
ImmutableMap<Integer, Callback<RestResponse>> individualCallbacks = ImmutableMap.<Integer, Callback<RestResponse>>of(ID1, callback1, ID2, callback2);
FutureCallback<MultiplexedResponse> aggregatedCallback = new FutureCallback<MultiplexedResponse>();
TestRecord entity1 = fakeEntity(ID1);
IndividualResponse ir1 = fakeIndividualResponse(entity1);
TestRecord entity2 = fakeEntity(ID2);
IndividualResponse ir2 = fakeIndividualResponse(entity2);
MultiplexedResponseContent responseContent = new MultiplexedResponseContent().setResponses(new IndividualResponseMap(ImmutableMap.of(Integer.toString(ID1), ir1, Integer.toString(ID2), ir2)));
MultiplexedCallback multiplexedCallback = new MultiplexedCallback(individualCallbacks, aggregatedCallback);
multiplexedCallback.onSuccess(fakeRestResponse(responseContent));
assertRestResponseEquals(callback1.get(), fakeRestResponse(entity1));
assertRestResponseEquals(callback2.get(), fakeRestResponse(entity2));
MultiplexedResponse multiplexedResponse = aggregatedCallback.get();
Assert.assertEquals(multiplexedResponse.getStatus(), HttpStatus.S_200_OK.getCode());
Assert.assertEquals(multiplexedResponse.getHeaders(), HEADERS);
}
Aggregations