use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.
the class RestLiArgumentBuilderTestHelper method getMockResourceContext.
static ServerResourceContext getMockResourceContext(Set<Object> batchKeys, boolean attachmentReaderGetExpected, boolean hasAlternateKeyParam) {
ServerResourceContext context = createMock(ServerResourceContext.class);
if (batchKeys != null) {
PathKeysImpl pathKeys = new PathKeysImpl();
if (batchKeys != null) {
pathKeys.setBatchKeys(batchKeys);
}
expect(context.getPathKeys()).andReturn(pathKeys);
}
if (attachmentReaderGetExpected) {
expect(context.getRequestAttachmentReader()).andReturn(null);
}
expect(context.getParameter(RestConstants.ALT_KEY_PARAM)).andReturn(hasAlternateKeyParam ? "" : null).anyTimes();
replay(context);
return context;
}
use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.
the class RestLiArgumentBuilderTestHelper method getMockResourceContext.
public static ServerResourceContext getMockResourceContext(String keyName, Object keyValue, Set<Object> batchKeys, Map<String, String> headers, boolean attachmentReaderGetExpected) {
ServerResourceContext context = createMock(ServerResourceContext.class);
if (keyName != null || batchKeys != null) {
PathKeysImpl pathKeys = new PathKeysImpl();
if (keyName != null) {
pathKeys.append(keyName, keyValue);
}
if (batchKeys != null) {
pathKeys.setBatchKeys(batchKeys);
}
expect(context.getPathKeys()).andReturn(pathKeys);
}
if (headers != null) {
expect(context.getRequestHeaders()).andReturn(headers);
}
if (attachmentReaderGetExpected) {
expect(context.getRequestAttachmentReader()).andReturn(null);
}
replay(context);
return context;
}
use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.
the class RestLiArgumentBuilderTestHelper method getMockResourceContext.
public static ServerResourceContext getMockResourceContext(String parameterKey, List<String> parameterValues, boolean attachmentReaderGetExpected) {
ServerResourceContext context = createMock(ServerResourceContext.class);
expect(context.getParameter(parameterKey)).andReturn(parameterValues.get(0));
expect(context.getParameterValues(parameterKey)).andReturn(parameterValues);
if (attachmentReaderGetExpected) {
expect(context.getRequestAttachmentReader()).andReturn(null);
}
replay(context);
return context;
}
use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.
the class TestBatchUpdateResponseBuilder method getMockResourceContext.
private static ResourceContext getMockResourceContext(ProtocolVersion protocolVersion, String altKeyName) {
ServerResourceContext mockContext = EasyMock.createMock(ServerResourceContext.class);
EasyMock.expect(mockContext.getBatchKeyErrors()).andReturn(Collections.<Object, RestLiServiceException>emptyMap()).once();
EasyMock.expect(mockContext.getRestliProtocolVersion()).andReturn(protocolVersion).once();
EasyMock.expect(mockContext.hasParameter(RestConstants.ALT_KEY_PARAM)).andReturn(altKeyName != null).anyTimes();
if (altKeyName != null) {
EasyMock.expect(mockContext.getParameter(RestConstants.ALT_KEY_PARAM)).andReturn(altKeyName).atLeastOnce();
}
EasyMock.replay(mockContext);
return mockContext;
}
use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.
the class TestRestUtils method testValidateRequestHeadersWithValidAcceptHeaderAndMatch.
@Test()
public void testValidateRequestHeadersWithValidAcceptHeaderAndMatch() throws Exception {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Accept", "application/json");
ServerResourceContext resourceContext = new ResourceContextImpl();
RestUtils.validateRequestHeadersAndUpdateResourceContext(headers, resourceContext);
Assert.assertEquals(resourceContext.getResponseMimeType(), "application/json");
}
Aggregations