Search in sources :

Example 6 with MutablePathKeys

use of com.linkedin.restli.internal.server.MutablePathKeys in project rest.li by linkedin.

the class TestArgumentBuilder method testPathKeyParameterType.

@Test
@SuppressWarnings("deprecation")
public void testPathKeyParameterType() {
    String testParamKey = "testParam";
    String expectedTestParamValue = "testParamValue";
    // mock setup
    ServerResourceContext mockResourceContext = EasyMock.createMock(ServerResourceContext.class);
    MutablePathKeys mockPathKeys = EasyMock.createMock(MutablePathKeys.class);
    EasyMock.expect(mockPathKeys.get(testParamKey)).andReturn(expectedTestParamValue).anyTimes();
    EasyMock.expect(mockResourceContext.getPathKeys()).andReturn(mockPathKeys).anyTimes();
    EasyMock.expect(mockResourceContext.getRequestAttachmentReader()).andReturn(null);
    EasyMock.replay(mockResourceContext, mockPathKeys);
    List<Parameter<?>> parameters = new ArrayList<Parameter<?>>();
    Parameter<String> param1 = new Parameter<String>(testParamKey, String.class, null, false, null, Parameter.ParamType.KEY, false, AnnotationSet.EMPTY);
    Parameter<String> param2 = new Parameter<String>(testParamKey, String.class, null, false, null, Parameter.ParamType.ASSOC_KEY_PARAM, false, AnnotationSet.EMPTY);
    Parameter<PathKeys> param3 = new Parameter<PathKeys>(testParamKey, PathKeys.class, null, false, null, Parameter.ParamType.PATH_KEYS, false, AnnotationSet.EMPTY);
    Parameter<PathKeys> param4 = new Parameter<PathKeys>(testParamKey, PathKeys.class, null, false, null, Parameter.ParamType.PATH_KEYS_PARAM, false, AnnotationSet.EMPTY);
    parameters.add(param1);
    parameters.add(param2);
    parameters.add(param3);
    parameters.add(param4);
    Object[] results = ArgumentBuilder.buildArgs(new Object[0], getMockResourceMethod(parameters), mockResourceContext, null);
    Assert.assertEquals(results[0], expectedTestParamValue);
    Assert.assertEquals(results[1], expectedTestParamValue);
    Assert.assertEquals(results[2], mockPathKeys);
    Assert.assertEquals(results[3], mockPathKeys);
}
Also used : PathKeys(com.linkedin.restli.server.PathKeys) MutablePathKeys(com.linkedin.restli.internal.server.MutablePathKeys) MutablePathKeys(com.linkedin.restli.internal.server.MutablePathKeys) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) ArrayList(java.util.ArrayList) Parameter(com.linkedin.restli.internal.server.model.Parameter) Test(org.testng.annotations.Test)

Aggregations

MutablePathKeys (com.linkedin.restli.internal.server.MutablePathKeys)6 Test (org.testng.annotations.Test)4 DataMap (com.linkedin.data.DataMap)3 PathKeysImpl (com.linkedin.restli.internal.server.PathKeysImpl)3 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)3 Parameter (com.linkedin.restli.internal.server.model.Parameter)3 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)2 ArrayList (java.util.ArrayList)2 BeforeTest (org.testng.annotations.BeforeTest)2 ByteString (com.linkedin.data.ByteString)1 DataList (com.linkedin.data.DataList)1 DynamicRecordTemplate (com.linkedin.data.template.DynamicRecordTemplate)1 StringArray (com.linkedin.data.template.StringArray)1 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)1 RequestContext (com.linkedin.r2.message.RequestContext)1 ProtocolVersion (com.linkedin.restli.common.ProtocolVersion)1 ResourceMethod (com.linkedin.restli.common.ResourceMethod)1 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)1 PathKeys (com.linkedin.restli.server.PathKeys)1 ProjectionMode (com.linkedin.restli.server.ProjectionMode)1