use of com.linkedin.restli.common.ComplexResourceKey in project rest.li by linkedin.
the class TestUpdateArgumentBuilder method argumentData.
@DataProvider(name = "argumentData")
private Object[][] argumentData() {
Parameter<?> myComplexKeyParam = new Parameter<>("", MyComplexKey.class, DataTemplateUtil.getSchema(MyComplexKey.class), false, null, Parameter.ParamType.POST, false, new AnnotationSet(new Annotation[] {}));
List<Parameter<?>> collectionResourceParams = new ArrayList<>();
collectionResourceParams.add(new Parameter<>("myComplexKeyCollectionId", Integer.class, new IntegerDataSchema(), false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
collectionResourceParams.add(myComplexKeyParam);
List<Parameter<?>> simpleResourceParams = new ArrayList<>();
simpleResourceParams.add(myComplexKeyParam);
List<Parameter<?>> associationResourceParams = new ArrayList<>();
associationResourceParams.add(new Parameter<>("myComplexKeyAssociationId", CompoundKey.class, null, false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
associationResourceParams.add(myComplexKeyParam);
List<Parameter<?>> complexResourceKeyParams = new ArrayList<>();
@SuppressWarnings("rawtypes") Parameter<ComplexResourceKey> complexResourceKeyParam = new Parameter<>("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<>(new MyComplexKey().setA("keyString").setB(1234L), new EmptyRecord()) } };
}
use of com.linkedin.restli.common.ComplexResourceKey in project rest.li by linkedin.
the class TestBatchUpdateArgumentBuilder method failureData.
@DataProvider(name = "failureData")
private Object[][] failureData() {
Object[] compoundKeys = new Object[] { new CompoundKey().append("string1", "XXX").append("string2", "oranges"), new CompoundKey().append("string1", "coffee").append("string2", "tea") };
Object[] complexResourceKeys = new Object[] { new ComplexResourceKey<>(new MyComplexKey().setA("A1").setB(111L), new EmptyRecord()), new ComplexResourceKey<>(new MyComplexKey().setA("A2").setB(222L), new EmptyRecord()) };
return new Object[][] { { AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("integerKey", Integer.class, new IntegerDataSchema()), null, "{\"entities\":{\"10001\":{\"b\":123,\"a\":\"abc\"}," + "\"10002\":{\"b\":456,\"a\":\"XY\"}}}", new Object[] { 10001, 99999 }, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("integerKey", Integer.class, new IntegerDataSchema()), null, "{\"entities\":{\"10001\":{\"b\":123,\"a\":\"abc\"}," + "\"99999\":{\"b\":456,\"a\":\"XY\"}}}", new Object[] { 10001, 10002 }, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("integerKey", Integer.class, new IntegerDataSchema()), null, "{\"entities\":{\"10001\":{\"b\":123,\"a\":\"abc\"}," + "\"10002\":{\"b\":456,\"a\":\"XY\"}}}", new Object[] { 10001, 10002, 10003 }, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("compoundKey", CompoundKey.class, null), new Key[] { new Key("string1", String.class), new Key("string2", String.class) }, "{\"entities\":{\"string1=apples&string2=oranges\":{\"b\":123,\"a\":\"abc\"}," + "\"string1=coffee&string2=tea\":{\"b\":456,\"a\":\"XY\"}}}", compoundKeys, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { // Duplicate key in the entities body
AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("compoundKey", CompoundKey.class, null), new Key[] { new Key("string1", String.class), new Key("string2", String.class) }, "{\"entities\":{\"string1=coffee&string2=tea\":{\"b\":123,\"a\":\"abc\"}," + "\"string2=tea&string1=coffee\":{\"b\":456,\"a\":\"XY\"}}}", compoundKeys, ERROR_MESSAGE_DUPLICATE_BATCH_KEYS }, { AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), new Key("compoundKey", CompoundKey.class, null), new Key[] { new Key("string1", String.class), new Key("string2", String.class) }, "{\"entities\":{\"(string1:coffee,string2:tea)\":{\"b\":456,\"a\":\"XY\"}," + "\"(string1:apples,string2:oranges)\":{\"b\":123,\"a\":\"abc\"}}}", compoundKeys, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { // Duplicate key in the entities body
AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), new Key("compoundKey", CompoundKey.class, null), new Key[] { new Key("string1", String.class), new Key("string2", String.class) }, "{\"entities\":{\"(string1:coffee,string2:tea)\":{\"b\":456,\"a\":\"XY\"}," + "\"(string2:tea,string1:coffee)\":{\"b\":123,\"a\":\"abc\"}}}", compoundKeys, ERROR_MESSAGE_DUPLICATE_BATCH_KEYS }, { AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("complexKey", ComplexResourceKey.class, null), null, "{\"entities\":{\"a=A1&b=999\":{\"b\":123,\"a\":\"abc\"}," + "\"a=A2&b=222\":{\"b\":456,\"a\":\"XY\"}}}", complexResourceKeys, ERROR_MESSAGE_BATCH_KEYS_MISMATCH }, { // Duplicate key in the entities body
AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), new Key("complexKey", ComplexResourceKey.class, null), null, "{\"entities\":{\"a=A1&b=111\":{\"b\":123,\"a\":\"abc\"}," + "\"b=111&a=A1\":{\"b\":456,\"a\":\"XY\"}}}", complexResourceKeys, ERROR_MESSAGE_DUPLICATE_BATCH_KEYS } };
}
use of com.linkedin.restli.common.ComplexResourceKey in project rest.li by linkedin.
the class TestPatchArgumentBuilder method argumentData.
@DataProvider(name = "argumentData")
private Object[][] argumentData() {
@SuppressWarnings("rawtypes") Parameter<?> patchParam = new Parameter<>("", PatchRequest.class, null, false, null, Parameter.ParamType.POST, false, new AnnotationSet(new Annotation[] {}));
List<Parameter<?>> collectionResourceParams = new ArrayList<>();
collectionResourceParams.add(new Parameter<>("myComplexKeyCollectionId", Integer.class, new IntegerDataSchema(), false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
collectionResourceParams.add(patchParam);
List<Parameter<?>> simpleResourceParams = new ArrayList<>();
simpleResourceParams.add(patchParam);
List<Parameter<?>> associationResourceParams = new ArrayList<>();
associationResourceParams.add(new Parameter<>("myComplexKeyAssociationId", CompoundKey.class, null, false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {})));
associationResourceParams.add(patchParam);
List<Parameter<?>> complexResourceKeyParams = new ArrayList<>();
@SuppressWarnings("rawtypes") Parameter<ComplexResourceKey> complexResourceKeyParam = new Parameter<>("complexKeyTestId", ComplexResourceKey.class, null, false, null, Parameter.ParamType.RESOURCE_KEY, false, new AnnotationSet(new Annotation[] {}));
complexResourceKeyParams.add(complexResourceKeyParam);
complexResourceKeyParams.add(patchParam);
return new Object[][] { { collectionResourceParams, new Key("myComplexKeyCollectionId", Integer.class, new IntegerDataSchema()), "myComplexKeyCollectionId", 1234 }, { 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<>(new MyComplexKey().setA("keyString").setB(1234L), new EmptyRecord()) } };
}
use of com.linkedin.restli.common.ComplexResourceKey in project rest.li by linkedin.
the class MockBatchEntityResponseFactory method createWithComplexKey.
/**
* Create a {@link BatchKVResponse} where the key is a {@link ComplexResourceKey}
*
* @param valueClass the value class
* @param keyKeyClass the class of the key part of the {@link ComplexResourceKey}
* @param keyParamsClass the class of the params part of the {@link ComplexResourceKey}
* @param recordTemplates the data that will be returned for a call to {@link com.linkedin.restli.client.response.BatchKVResponse#getResults()}
* NOTE: the params part of the {@link ComplexResourceKey} is removed in this map. A new
* instance of the params class is created with no data in it.
* @param statuses The HTTP status codes that will be returned as part of {@link EntityResponse}s
* returned in {@link com.linkedin.restli.client.response.BatchKVResponse#getResults()}
* @param errorResponses the data that will be returned for a call to {@link com.linkedin.restli.client.response.BatchKVResponse#getErrors()}
* NOTE: the params part of the {@link ComplexResourceKey} is removed in this map. A new
* instance of the params class is created with no data in it.
* @param <V>
*/
@SuppressWarnings("rawtypes")
public static <KK extends RecordTemplate, KP extends RecordTemplate, V extends RecordTemplate> BatchKVResponse<ComplexResourceKey<KK, KP>, EntityResponse<V>> createWithComplexKey(Class<V> valueClass, Class<KK> keyKeyClass, Class<KP> keyParamsClass, Map<ComplexResourceKey<KK, KP>, V> recordTemplates, Map<ComplexResourceKey<KK, KP>, HttpStatus> statuses, Map<ComplexResourceKey<KK, KP>, ErrorResponse> errorResponses) {
ProtocolVersion version = AllProtocolVersions.BASELINE_PROTOCOL_VERSION;
DataMap batchResponseDataMap = buildDataMap(recordTemplates, statuses, errorResponses, version);
@SuppressWarnings("unchecked") BatchKVResponse<ComplexResourceKey<KK, KP>, EntityResponse<V>> response = (BatchKVResponse<ComplexResourceKey<KK, KP>, EntityResponse<V>>) (Object) new BatchEntityResponse<>(batchResponseDataMap, new TypeSpec<>(ComplexResourceKey.class), TypeSpec.forClassMaybeNull(valueClass), null, ComplexKeySpec.forClassesMaybeNull(keyKeyClass, keyParamsClass), version);
return response;
}
use of com.linkedin.restli.common.ComplexResourceKey in project rest.li by linkedin.
the class TestMockBatchCreateIdResponseFactory method provideKeys.
@DataProvider
public Object[][] provideKeys() {
Greeting g1 = buildGreeting(1L);
Greeting g2 = buildGreeting(2L);
Greeting g3 = buildGreeting(3L);
return new Object[][] { new Object[] { new Long[] { 1L, 2L, 3L } }, new Object[] { new MyCustomString[] { new MyCustomString("1"), new MyCustomString("2"), new MyCustomString("3") } }, new Object[] { new CompoundKey[] { buildCompoundKey("c1", 1), buildCompoundKey("c2", 2), buildCompoundKey("c3", 3) } }, new Object[] { new ComplexResourceKey<?, ?>[] { new ComplexResourceKey<>(g1, g1), new ComplexResourceKey<>(g2, g2), new ComplexResourceKey<>(g3, g3) } } };
}
Aggregations