use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestPatchRequestRecorder method testPatchGenerateAndPatchRequestRecorderGenerateIdenticalPatches.
@Test
public void testPatchGenerateAndPatchRequestRecorderGenerateIdenticalPatches() throws CloneNotSupportedException {
TestRecord t1 = new TestRecord();
TestRecord t2 = new TestRecord(t1.data().copy());
t2.setId(1L);
t2.setMessage("Foo Bar Baz");
PatchRequest<TestRecord> patchFromGenerator = PatchGenerator.diff(t1, t2);
PatchRequestRecorder<TestRecord> patchRecorder = new PatchRequestRecorder<TestRecord>(TestRecord.class);
patchRecorder.getRecordingProxy().setId(1L).setMessage("Foo Bar Baz");
PatchRequest<TestRecord> patchFromRecorder = patchRecorder.generatePatchRequest();
Assert.assertEquals(patchFromRecorder.getPatchDocument(), patchFromGenerator.getPatchDocument());
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testComplexKeyGetRequestBuilder.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "complexKeyAndParam")
public void testComplexKeyGetRequestBuilder(URIDetails expectedURIDetails) throws Exception {
GetRequestBuilder<ComplexResourceKey<TestRecord, TestRecord>, TestRecord> builder = new GetRequestBuilder<ComplexResourceKey<TestRecord, TestRecord>, TestRecord>(TEST_URI, TestRecord.class, _COMPLEX_KEY_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
ComplexResourceKey<TestRecord, TestRecord> id = buildComplexKey(1L, "KeyMessage", 10L, "ParamMessage");
RecordTemplate param1 = buildComplexParam(123, "ParamMessage");
GetRequest<TestRecord> request = builder.id(id).setParam("testParam", param1).build();
Assert.assertTrue(request.isSafe());
Assert.assertTrue(request.isIdempotent());
checkBasicRequest(request, expectedURIDetails, ResourceMethod.GET, null, Collections.<String, String>emptyMap(), null);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testUpdateRequestBuilderWithKeylessResource.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "noEntity")
public void testUpdateRequestBuilderWithKeylessResource(URIDetails expectedURIDetails) {
UpdateRequestBuilder<Void, TestRecord> builder = new UpdateRequestBuilder<Void, TestRecord>(TEST_URI, TestRecord.class, _SIMPLE_RESOURCE_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
UpdateRequest<TestRecord> request = builder.input(new TestRecord()).build();
Assert.assertEquals(request.isSafe(), false);
Assert.assertEquals(request.isIdempotent(), true);
checkBasicRequest(request, expectedURIDetails, ResourceMethod.UPDATE, new TestRecord(), Collections.<String, String>emptyMap(), null);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testBatchUpdateRequestBuilder.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "batch")
public void testBatchUpdateRequestBuilder(URIDetails expectedURIDetails) {
BatchUpdateRequestBuilder<Long, TestRecord> builder = new BatchUpdateRequestBuilder<Long, TestRecord>(TEST_URI, TestRecord.class, _COLL_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
Map<Long, TestRecord> updates = new HashMap<Long, TestRecord>();
updates.put(1L, new TestRecord());
updates.put(2L, new TestRecord());
updates.put(3L, new TestRecord());
BatchUpdateRequest<Long, TestRecord> request = builder.inputs(updates).appendSingleAttachment(_dataSourceWriterA).appendMultipleAttachments(_dataSourceIterator).appendSingleAttachment(_dataSourceWriterB).build();
testBaseUriGeneration(request, expectedURIDetails.getProtocolVersion());
Assert.assertEquals(request.getObjectIds(), new HashSet<Long>(Arrays.asList(1L, 2L, 3L)));
Assert.assertEquals(request.isSafe(), false);
Assert.assertEquals(request.isIdempotent(), true);
BatchRequest<TestRecord> expectedRequest = new BatchRequest<TestRecord>(new DataMap(), TestRecord.class);
expectedRequest.getEntities().put("1", new TestRecord());
expectedRequest.getEntities().put("2", new TestRecord());
expectedRequest.getEntities().put("3", new TestRecord());
@SuppressWarnings({ "unchecked", "rawtypes" }) KeyValueRecordFactory<Long, TestRecord> factory = new KeyValueRecordFactory<Long, TestRecord>(Long.class, null, null, null, TestRecord.class);
@SuppressWarnings({ "unchecked", "rawtypes" }) CollectionRequest<KeyValueRecord> collectionRequest = buildCollectionRequest(factory, new Long[] { 1L, 2L, 3L }, new TestRecord[] { new TestRecord(), new TestRecord(), new TestRecord() });
checkBasicRequest(request, expectedURIDetails, ResourceMethod.BATCH_UPDATE, collectionRequest, expectedRequest, Collections.<String, String>emptyMap(), _streamingDataSources);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testComplexKeyDeleteRequestBuilder.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "complexKeyAndParam")
public void testComplexKeyDeleteRequestBuilder(URIDetails expectedURIDetails) throws Exception {
DeleteRequestBuilder<ComplexResourceKey<TestRecord, TestRecord>, TestRecord> builder = new DeleteRequestBuilder<ComplexResourceKey<TestRecord, TestRecord>, TestRecord>(TEST_URI, TestRecord.class, _COMPLEX_KEY_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
ComplexResourceKey<TestRecord, TestRecord> id = buildComplexKey(1L, "KeyMessage", 10L, "ParamMessage");
RecordTemplate param = buildComplexParam(123, "ParamMessage");
DeleteRequest<TestRecord> request = builder.id(id).setParam("testParam", param).build();
Assert.assertFalse(request.isSafe());
Assert.assertTrue(request.isIdempotent());
checkBasicRequest(request, expectedURIDetails, ResourceMethod.DELETE, null, Collections.<String, String>emptyMap(), null);
}
Aggregations