use of com.linkedin.restli.internal.common.ResourcePropertiesImpl in project rest.li by linkedin.
the class TestRestClientRequestBuilder method setResourceMethodExpectations.
private void setResourceMethodExpectations(final ResourceMethod method, final Request<?> mockRequest, final RecordTemplate mockRecordTemplate, final DataMap entityBody) {
if (method == ResourceMethod.BATCH_PARTIAL_UPDATE || method == ResourceMethod.BATCH_UPDATE) {
buildInputForBatchPatchAndUpdate(mockRequest);
} else {
EasyMock.expect(mockRequest.getInputRecord()).andReturn(mockRecordTemplate).times(2);
}
if (method == ResourceMethod.GET) {
EasyMock.expect(((GetRequest) mockRequest).getObjectId()).andReturn(null).once();
EasyMock.expect(mockRequest.getResourceProperties()).andReturn(new ResourcePropertiesImpl(Collections.<ResourceMethod>emptySet(), null, null, null, Collections.<String, CompoundKey.TypeInfo>emptyMap())).once();
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else if (method == ResourceMethod.BATCH_GET) {
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else if (method == ResourceMethod.ACTION) {
EasyMock.expect(((ActionRequest) mockRequest).getId()).andReturn(null);
EasyMock.expect(mockRequest.getMethodName()).andReturn("testAction");
} else if (method == ResourceMethod.FINDER) {
EasyMock.expect(((FindRequest) mockRequest).getAssocKey()).andReturn(new CompoundKey());
EasyMock.expect(mockRequest.getMethodName()).andReturn("testFinder");
} else if (method == ResourceMethod.GET_ALL) {
EasyMock.expect(((GetAllRequest) mockRequest).getAssocKey()).andReturn(new CompoundKey());
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else if (method == ResourceMethod.UPDATE) {
EasyMock.expect(mockRequest.getResourceProperties()).andReturn(new ResourcePropertiesImpl(Collections.<ResourceMethod>emptySet(), null, null, null, Collections.<String, CompoundKey.TypeInfo>emptyMap())).once();
EasyMock.expect(((UpdateRequest) mockRequest).getId()).andReturn(null);
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else if (method == ResourceMethod.PARTIAL_UPDATE) {
EasyMock.expect(mockRequest.getResourceProperties()).andReturn(new ResourcePropertiesImpl(Collections.<ResourceMethod>emptySet(), null, null, null, Collections.<String, CompoundKey.TypeInfo>emptyMap())).once();
EasyMock.expect(((PartialUpdateRequest) mockRequest).getId()).andReturn(null);
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else if (method == ResourceMethod.DELETE) {
EasyMock.expect(mockRequest.getResourceProperties()).andReturn(new ResourcePropertiesImpl(Collections.<ResourceMethod>emptySet(), null, null, null, Collections.<String, CompoundKey.TypeInfo>emptyMap())).once();
EasyMock.expect(((DeleteRequest) mockRequest).getId()).andReturn(null);
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
} else {
EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
}
EasyMock.expect(mockRecordTemplate.data()).andReturn(entityBody).once();
}
use of com.linkedin.restli.internal.common.ResourcePropertiesImpl 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.internal.common.ResourcePropertiesImpl 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);
}
Aggregations