use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testPartialUpdateRequestBuilderWithKeylessResource.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "noEntity")
public void testPartialUpdateRequestBuilderWithKeylessResource(URIDetails expectedURIDetails) throws Exception {
PartialUpdateRequestBuilder<Long, TestRecord> builder = new PartialUpdateRequestBuilder<Long, TestRecord>(TEST_URI, TestRecord.class, _SIMPLE_RESOURCE_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
TestRecord t1 = new TestRecord();
TestRecord t2 = new TestRecord(t1.data().copy());
t2.setId(1L);
t2.setMessage("Foo Bar Baz");
PatchRequest<TestRecord> patch = PatchGenerator.diff(t1, t2);
PartialUpdateRequest<TestRecord> request = builder.input(patch).build();
Assert.assertEquals(request.isSafe(), false);
Assert.assertEquals(request.isIdempotent(), false);
checkBasicRequest(request, expectedURIDetails, ResourceMethod.PARTIAL_UPDATE, patch, Collections.<String, String>emptyMap(), null);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testBuilderParam.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "builderParam")
public void testBuilderParam(URIDetails expectedURIDetails) {
final GetRequestBuilder<Long, TestRecord> builder = new GetRequestBuilder<Long, TestRecord>(TEST_URI, TestRecord.class, _COLL_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);
final Collection<Integer> coll = Arrays.asList(3, 4, 5);
final IntegerArray array = new IntegerArray(coll);
final GetRequest<TestRecord> request = builder.id(1L).setReqParam("simpleKey", 2).setParam("arrayKey1", coll).setParam("arrayKey2", array).build();
URIDetails.testUriGeneration(request, expectedURIDetails);
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method checkKeyValueMapIsReadOnly.
private void checkKeyValueMapIsReadOnly(ComplexResourceKey<TestRecord, TestRecord> id1, ComplexResourceKey<TestRecord, TestRecord> id2, RecordTemplate t1, RecordTemplate t2, Class<? extends RecordTemplate> valueClass, Map<ComplexResourceKey<TestRecord, TestRecord>, TestRecord> entries) {
for (Map.Entry<ComplexResourceKey<TestRecord, TestRecord>, TestRecord> entry : entries.entrySet()) {
ComplexResourceKey<TestRecord, TestRecord> generatedKey = entry.getKey();
if (generatedKey.equals(id1)) {
checkComplexKeyIsReadOnly(id1, generatedKey);
} else {
checkComplexKeyIsReadOnly(id2, generatedKey);
}
Assert.assertTrue(generatedKey.isReadOnly());
RecordTemplate value = entry.getValue();
if (value.equals(t1)) {
if (t1.data().isMadeReadOnly()) {
Assert.assertSame(t1, value);
} else {
Assert.assertNotSame(t1, value);
}
} else {
if (t2.data().isReadOnly()) {
Assert.assertSame(t2, value);
} else {
Assert.assertNotSame(t2, value);
}
}
Assert.assertTrue(value.data().isMadeReadOnly());
}
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testBuilderPathKeys11.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "subResourceAction2")
public void testBuilderPathKeys11(URIDetails expectedURIDetails) {
ResourceSpec resourceSpec = getResourceSpecForBuilderPathKeys();
Request<TestRecord> request = new ActionRequestBuilder<Void, TestRecord>(SUBRESOURCE_SIMPLE_ROOT_URI, TestRecord.class, resourceSpec, RestliRequestOptions.DEFAULT_OPTIONS).name("action").pathKey("key1", "http://example.com/images/1.png").build();
URIDetails.testUriGeneration(request, expectedURIDetails);
testPathKeys(request, SUBRESOURCE_SIMPLE_ROOT_URI, Collections.singletonMap("key1", "http://example.com/images/1.png"));
}
use of com.linkedin.restli.client.test.TestRecord in project rest.li by linkedin.
the class TestClientBuilders method testCrudBuilderParams8.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "noEntityWithParam")
public void testCrudBuilderParams8(URIDetails expectedURIDetails) {
Request<CollectionResponse<CreateStatus>> request = new BatchCreateRequestBuilder<Long, TestRecord>(TEST_URI, TestRecord.class, _COLL_SPEC, RestliRequestOptions.DEFAULT_OPTIONS).input(new TestRecord()).setParam("foo", "bar").build();
URIDetails.testUriGeneration(request, expectedURIDetails);
}
Aggregations