use of com.linkedin.restli.common.ResourceSpec in project rest.li by linkedin.
the class TestRestClientRequestBuilder method buildInputForBatchPatchAndUpdate.
@SuppressWarnings({ "rawtypes", "deprecation" })
private void buildInputForBatchPatchAndUpdate(Request mockRequest) {
CollectionRequest mockCollectionRequest = EasyMock.createMock(CollectionRequest.class);
EasyMock.expect(mockCollectionRequest.getElements()).andReturn(Collections.emptyList()).once();
EasyMock.expect(mockRequest.getInputRecord()).andReturn(mockCollectionRequest).times(2);
EasyMock.replay(mockCollectionRequest);
ResourceSpec resourceSpec = new ResourceSpecImpl(Collections.<ResourceMethod>emptySet(), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), null, null, null, EmptyRecord.class, Collections.<String, CompoundKey.TypeInfo>emptyMap());
EasyMock.expect(mockRequest.getResourceProperties()).andReturn(new ResourcePropertiesImpl(Collections.<ResourceMethod>emptySet(), null, null, TypeSpec.forClassMaybeNull(EmptyRecord.class), Collections.<String, CompoundKey.TypeInfo>emptyMap())).once();
}
use of com.linkedin.restli.common.ResourceSpec in project rest.li by linkedin.
the class TestRequest method testResourceProperties.
@Test
public void testResourceProperties() {
Set<ResourceMethod> expectedSupportedMethods = new HashSet<ResourceMethod>();
expectedSupportedMethods.add(ResourceMethod.GET);
expectedSupportedMethods.add(ResourceMethod.BATCH_PARTIAL_UPDATE);
ResourceSpec expectedResourceSpec = new ResourceSpecImpl(expectedSupportedMethods, null, null, ComplexResourceKey.class, TestRecord.class, TestRecord.class, TestRecord.class, Collections.<String, Object>emptyMap());
Map<String, Object> pathKeys = new HashMap<String, Object>();
pathKeys.put("id", new ComplexResourceKey<TestRecord, TestRecord>(new TestRecord(), new TestRecord()));
Request<TestRecord> request = new Request<TestRecord>(ResourceMethod.GET, null, Collections.<String, String>emptyMap(), Collections.<HttpCookie>emptyList(), new EntityResponseDecoder<TestRecord>(TestRecord.class), expectedResourceSpec, Collections.<String, Object>emptyMap(), Collections.<String, Class<?>>emptyMap(), null, "testRecord", pathKeys, RestliRequestOptions.DEFAULT_OPTIONS, null);
ResourceProperties expectedResourceProperties = new ResourcePropertiesImpl(expectedResourceSpec.getSupportedMethods(), expectedResourceSpec.getKeyType(), expectedResourceSpec.getComplexKeyType(), expectedResourceSpec.getValueType(), expectedResourceSpec.getKeyParts());
Assert.assertEquals(request.getResourceProperties(), expectedResourceProperties);
}
use of com.linkedin.restli.common.ResourceSpec in project rest.li by linkedin.
the class TestRequest method testHeadersCaseInsensitiveSet.
@Test
public void testHeadersCaseInsensitiveSet() {
final long id = 42l;
final ResourceSpec spec = new ResourceSpecImpl(EnumSet.allOf(ResourceMethod.class), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), Long.class, null, null, TestRecord.class, Collections.<String, Class<?>>emptyMap());
GetRequestBuilder<Long, TestRecord> builder = new GetRequestBuilder<Long, TestRecord>("abc", TestRecord.class, spec, RestliRequestOptions.DEFAULT_OPTIONS);
Request<TestRecord> request = builder.id(id).setHeader("header", "value1").setHeader("HEADER", "value2").build();
Assert.assertEquals(request.getHeaders().get("header"), "value2");
}
use of com.linkedin.restli.common.ResourceSpec in project rest.li by linkedin.
the class TestRequest method testHeadersCaseInsensitiveAdd.
@Test
public void testHeadersCaseInsensitiveAdd() {
final long id = 42l;
final ResourceSpec spec = new ResourceSpecImpl(EnumSet.allOf(ResourceMethod.class), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), Long.class, null, null, TestRecord.class, Collections.<String, Class<?>>emptyMap());
GetRequestBuilder<Long, TestRecord> builder = new GetRequestBuilder<Long, TestRecord>("abc", TestRecord.class, spec, RestliRequestOptions.DEFAULT_OPTIONS);
Request<TestRecord> request = builder.id(id).addHeader("header", "value1").addHeader("HEADER", "value2").build();
Assert.assertEquals(request.getHeaders().get("HEADER"), "value1,value2");
}
use of com.linkedin.restli.common.ResourceSpec in project rest.li by linkedin.
the class TestRequest method testToSecureString.
@Test
public void testToSecureString() {
final ResourceSpec spec = new ResourceSpecImpl(EnumSet.allOf(ResourceMethod.class), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), Long.class, null, null, TestRecord.class, Collections.<String, Class<?>>emptyMap());
GetRequestBuilder<Long, TestRecord> builder = new GetRequestBuilder<Long, TestRecord>("abc", TestRecord.class, spec, RestliRequestOptions.DEFAULT_OPTIONS);
Request<TestRecord> request = builder.id(5L).build();
Assert.assertEquals(request.toSecureString(), "com.linkedin.restli.client.GetRequest{_method=get, _baseUriTemplate=abc, _methodName=null, " + "_requestOptions=RestliRequestOptions{_protocolVersionOption=USE_LATEST_IF_AVAILABLE, " + "_requestCompressionOverride=null, _responseCompressionOverride=null, _contentType=null, " + "_acceptTypes=null, _acceptResponseAttachments=false}}");
}
Aggregations