use of com.linkedin.restli.internal.server.model.AnnotationSet in project rest.li by linkedin.
the class TestCollectionArgumentBuilder method complexArrayArgument.
@DataProvider(name = "complexArrayArgument")
private Object[][] complexArrayArgument() {
Map<String, String> map1 = new HashMap<String, String>();
map1.put("a", "A1");
map1.put("b", "111");
Map<String, String> map2 = new HashMap<String, String>();
map2.put("a", "A2");
map2.put("b", "222");
Map<String, String> map3 = new HashMap<String, String>();
map3.put("a", "A3");
map3.put("b", "333");
DataList data = new DataList();
data.add(new DataMap(map1));
data.add(new DataMap(map2));
data.add(new DataMap(map3));
return new Object[][] { { new Parameter<MyComplexKey[]>("myComplexKeys", MyComplexKey[].class, new ArrayDataSchema(DataTemplateUtil.getSchema(MyComplexKey.class)), false, null, Parameter.ParamType.QUERY, true, new AnnotationSet(new Annotation[] {})), "myComplexKeys", "{b=111, a=A1}", data, new Object[] { new MyComplexKey[] { new MyComplexKey().setA("A1").setB(111L), new MyComplexKey().setA("A2").setB(222L), new MyComplexKey().setA("A3").setB(333L) } } } };
}
use of com.linkedin.restli.internal.server.model.AnnotationSet in project rest.li by linkedin.
the class TestCollectionArgumentBuilder method argumentData.
@DataProvider(name = "argumentData")
private Object[][] argumentData() {
List<Parameter<?>> getAllParams = new ArrayList<Parameter<?>>();
getAllParams.add(getPagingContextParam());
Map<String, String> getAllContextParams = new HashMap<String, String>();
getAllContextParams.put("start", "33");
getAllContextParams.put("count", "444");
Map<String, String> finderContextParams = new HashMap<String, String>();
finderContextParams.put("start", "33");
finderContextParams.put("count", "444");
finderContextParams.put("required", "777");
finderContextParams.put("optional", null);
Map<String, String> finderContextParamsWithOptionalString = new HashMap<String, String>(finderContextParams);
finderContextParamsWithOptionalString.put("optional", "someString");
List<Parameter<?>> finderWithAssocKeyParams = new ArrayList<Parameter<?>>();
finderWithAssocKeyParams.add(new Parameter<String>("string1", String.class, new StringDataSchema(), false, null, Parameter.ParamType.ASSOC_KEY_PARAM, true, new AnnotationSet(new Annotation[] {})));
return new Object[][] { { getAllParams, getAllContextParams, null, new Object[] { new PagingContext(33, 444) } }, { getFinderParams(), finderContextParams, null, new Object[] { new PagingContext(33, 444), new Integer(777), null } }, { getFinderParams(), finderContextParamsWithOptionalString, null, new Object[] { new PagingContext(33, 444), new Integer(777), "someString" } }, { finderWithAssocKeyParams, null, new PathKeysImpl().append("string1", "testString"), new Object[] { "testString" } } };
}
use of com.linkedin.restli.internal.server.model.AnnotationSet in project rest.li by linkedin.
the class TestUpdateArgumentBuilder method argumentData.
@DataProvider(name = "argumentData")
private Object[][] argumentData() {
Parameter<?> myComplexKeyParam = new Parameter<MyComplexKey>("", MyComplexKey.class, DataTemplateUtil.getSchema(MyComplexKey.class), false, null, Parameter.ParamType.POST, false, new AnnotationSet(new Annotation[] {}));
List<Parameter<?>> collectionResourceParams = new ArrayList<Parameter<?>>();
collectionResourceParams.add(new Parameter<Integer>("myComplexKeyCollectionId", Integer.class, new IntegerDataSchema(), false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
collectionResourceParams.add(myComplexKeyParam);
List<Parameter<?>> simpleResourceParams = new ArrayList<Parameter<?>>();
simpleResourceParams.add(myComplexKeyParam);
List<Parameter<?>> associationResourceParams = new ArrayList<Parameter<?>>();
associationResourceParams.add(new Parameter<CompoundKey>("myComplexKeyAssociationId", CompoundKey.class, null, false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
associationResourceParams.add(myComplexKeyParam);
List<Parameter<?>> complexResourceKeyParams = new ArrayList<Parameter<?>>();
@SuppressWarnings("rawtypes") Parameter<ComplexResourceKey> complexResourceKeyParam = new Parameter<ComplexResourceKey>("complexKeyTestId", ComplexResourceKey.class, null, false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {}));
complexResourceKeyParams.add(complexResourceKeyParam);
complexResourceKeyParams.add(myComplexKeyParam);
return new Object[][] { { collectionResourceParams, new Key("myComplexKeyCollectionId", Integer.class, new IntegerDataSchema()), "myComplexKeyCollectionId", 4545 }, { simpleResourceParams, null, null, null }, { associationResourceParams, new Key("myComplexKeyAssociationId", CompoundKey.class, null), "myComplexKeyAssociationId", new CompoundKey().append("string1", "apples").append("string2", "oranges") }, { complexResourceKeyParams, new Key("complexKeyTestId", ComplexResourceKey.class, null), "complexKeyTestId", new ComplexResourceKey<MyComplexKey, EmptyRecord>(new MyComplexKey().setA("keyString").setB(1234L), new EmptyRecord()) } };
}
use of com.linkedin.restli.internal.server.model.AnnotationSet in project rest.li by linkedin.
the class TestCollectionArgumentBuilder method testProjectionParams.
@Test
public void testProjectionParams() {
List<Parameter<?>> finderWithProjectionParams = new ArrayList<Parameter<?>>();
finderWithProjectionParams.add(new Parameter<String>("key", String.class, new StringDataSchema(), false, null, Parameter.ParamType.QUERY, true, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<PagingContext>("", PagingContext.class, null, false, new PagingContext(0, 10), Parameter.ParamType.PAGING_CONTEXT_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.METADATA_PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.PAGING_PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
Map<String, String> finderWithProjectionContextParams = new HashMap<String, String>();
finderWithProjectionContextParams.put("start", "100");
finderWithProjectionContextParams.put("count", "15");
finderWithProjectionContextParams.put("key", "keyString");
Map<String, Integer> projectionMap = new HashMap<String, Integer>();
projectionMap.put("a", 1);
Map<String, Integer> metadataMap = new HashMap<String, Integer>();
metadataMap.put("intField", 1);
metadataMap.put("booleanField", 1);
Map<String, Integer> pagingMap = new HashMap<String, Integer>();
pagingMap.put("total", 1);
MaskTree projectionMask = new MaskTree(new DataMap(projectionMap));
MaskTree metadataMask = new MaskTree(new DataMap(metadataMap));
MaskTree pagingMask = new MaskTree(new DataMap(pagingMap));
Object[] expectedArgs = new Object[] { "keyString", new PagingContext(100, 15), projectionMask, metadataMask, pagingMask };
ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(null, 1, finderWithProjectionParams);
ResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(finderWithProjectionContextParams, projectionMask, metadataMask, pagingMask, true);
RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 1, context, 1);
RestRequest request = RestLiArgumentBuilderTestHelper.getMockRequest(false, null, 0);
RestLiArgumentBuilder argumentBuilder = new CollectionArgumentBuilder();
RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, request);
Object[] args = argumentBuilder.buildArguments(requestData, routingResult);
assertEquals(args, expectedArgs);
verify(descriptor, context, routingResult, request);
}
use of com.linkedin.restli.internal.server.model.AnnotationSet in project rest.li by linkedin.
the class TestCollectionArgumentBuilder method getFinderParams.
private List<Parameter<?>> getFinderParams() {
List<Parameter<?>> finderParams = new ArrayList<Parameter<?>>();
finderParams.add(getPagingContextParam());
Parameter<Integer> requiredIntParam = new Parameter<Integer>("required", Integer.class, new IntegerDataSchema(), false, null, Parameter.ParamType.QUERY, true, new AnnotationSet(new Annotation[] {}));
finderParams.add(requiredIntParam);
Parameter<String> optionalStringParam = new Parameter<String>("optional", String.class, new StringDataSchema(), true, null, Parameter.ParamType.QUERY, true, new AnnotationSet(new Annotation[] {}));
finderParams.add(optionalStringParam);
return finderParams;
}
Aggregations