Search in sources :

Example 16 with ResourceSpec

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();
}
Also used : CollectionRequest(com.linkedin.restli.common.CollectionRequest) EmptyRecord(com.linkedin.restli.common.EmptyRecord) CompoundKey(com.linkedin.restli.common.CompoundKey) ResourcePropertiesImpl(com.linkedin.restli.internal.common.ResourcePropertiesImpl) ResourceSpec(com.linkedin.restli.common.ResourceSpec) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl)

Example 17 with ResourceSpec

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);
}
Also used : HashMap(java.util.HashMap) ResourcePropertiesImpl(com.linkedin.restli.internal.common.ResourcePropertiesImpl) ResourceSpec(com.linkedin.restli.common.ResourceSpec) ResourceProperties(com.linkedin.restli.common.ResourceProperties) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) TestRecord(com.linkedin.restli.client.test.TestRecord) ResourceMethod(com.linkedin.restli.common.ResourceMethod) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 18 with ResourceSpec

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");
}
Also used : ResourceSpec(com.linkedin.restli.common.ResourceSpec) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) TestRecord(com.linkedin.restli.client.test.TestRecord) ResourceMethod(com.linkedin.restli.common.ResourceMethod) Test(org.testng.annotations.Test)

Example 19 with ResourceSpec

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");
}
Also used : ResourceSpec(com.linkedin.restli.common.ResourceSpec) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) TestRecord(com.linkedin.restli.client.test.TestRecord) ResourceMethod(com.linkedin.restli.common.ResourceMethod) Test(org.testng.annotations.Test)

Example 20 with ResourceSpec

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}}");
}
Also used : ResourceSpec(com.linkedin.restli.common.ResourceSpec) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) TestRecord(com.linkedin.restli.client.test.TestRecord) ResourceMethod(com.linkedin.restli.common.ResourceMethod) Test(org.testng.annotations.Test)

Aggregations

ResourceSpec (com.linkedin.restli.common.ResourceSpec)21 Test (org.testng.annotations.Test)15 TestRecord (com.linkedin.restli.client.test.TestRecord)14 ResourceSpecImpl (com.linkedin.restli.common.ResourceSpecImpl)9 HashMap (java.util.HashMap)7 ByteString (com.linkedin.data.ByteString)5 CompoundKey (com.linkedin.restli.common.CompoundKey)5 ResourceMethod (com.linkedin.restli.common.ResourceMethod)5 DynamicRecordMetadata (com.linkedin.data.template.DynamicRecordMetadata)4 FieldDef (com.linkedin.data.template.FieldDef)4 DataMap (com.linkedin.data.DataMap)2 DynamicRecordTemplate (com.linkedin.data.template.DynamicRecordTemplate)2 ResourcePropertiesImpl (com.linkedin.restli.internal.common.ResourcePropertiesImpl)2 CollectionRequest (com.linkedin.restli.common.CollectionRequest)1 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)1 EmptyRecord (com.linkedin.restli.common.EmptyRecord)1 ResourceProperties (com.linkedin.restli.common.ResourceProperties)1 RichResourceSchema (com.linkedin.restli.common.util.RichResourceSchema)1 RestLiTestAttachmentDataSource (com.linkedin.restli.internal.testutils.RestLiTestAttachmentDataSource)1 ResourceSchema (com.linkedin.restli.restspec.ResourceSchema)1