use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestUriParamUtils method unicode.
@DataProvider
public Object[][] unicode() {
// create objects
// test unicode encoding
DataMap japaneseMap = new DataMap();
// Japanese
japaneseMap.put("konnichiwa", "こんにちは");
DataMap emojiMap = new DataMap();
// Emoji
emojiMap.put("smiley", "☺");
DataMap surrogatePairMap = new DataMap();
// Emoji, but with surrogate pairs
surrogatePairMap.put("stickoutTongue", "😛");
return new Object[][] { { japaneseMap, "(konnichiwa:こんにちは)", "(konnichiwa:%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF)", "(konnichiwa:%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF)" }, { emojiMap, "(smiley:☺)", "(smiley:%E2%98%BA)", "(smiley:%E2%98%BA)" }, { surrogatePairMap, "(stickoutTongue:😛)", "(stickoutTongue:%F0%9F%98%9B)", "(stickoutTongue:%F0%9F%98%9B)" } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestURIElementParser method basicDecodable.
@DataProvider
private static Object[][] basicDecodable() {
DataMap simpleMap = new DataMap();
simpleMap.put("someString", "foo");
simpleMap.put("anotherString", "bar");
DataMap withEmptyString = new DataMap();
withEmptyString.put("empty", "");
DataMap nestedMap = new DataMap();
DataMap innerNestedMap = new DataMap();
innerNestedMap.put("bar", "baz");
nestedMap.put("foo", innerNestedMap);
DataList nestedList = new DataList();
DataList innerNestedList1 = new DataList();
innerNestedList1.add("a");
innerNestedList1.add("b");
DataList innerNestedList2 = new DataList();
innerNestedList2.add("c");
innerNestedList2.add("d");
innerNestedList2.add("e");
nestedList.add(innerNestedList1);
nestedList.add(innerNestedList2);
DataMap complexMap = new DataMap();
DataMap innerComplexMap = new DataMap();
innerComplexMap.put("foo", "bar");
complexMap.put("anObject", innerComplexMap);
DataList innerComplexList = new DataList();
innerComplexList.add("1");
innerComplexList.add("2");
innerComplexList.add("3");
innerComplexList.add("4");
complexMap.put("aList", innerComplexList);
complexMap.put("aString", "baz");
return new Object[][] { { "(someString:foo,anotherString:bar)", simpleMap }, { "()", new DataMap() }, { "List()", new DataList() }, { "(empty:'')", withEmptyString }, { "(foo:(bar:baz))", nestedMap }, { "List(List(a,b),List(c,d,e))", nestedList }, { "(anObject:(foo:bar),aList:List(1,2,3,4),aString:baz)", complexMap } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestRequestCompression method requestData.
@DataProvider(name = "requestData")
private Object[][] requestData() {
int tiny = 10;
int small = 100;
int large = 1000;
int huge = 10000;
CompressionConfig tinyThresholdConfig = new CompressionConfig(tiny);
CompressionConfig hugeThresholdConfig = new CompressionConfig(huge);
String encodings = "unsupportedEncoding, x-snappy-framed, snappy, gzip";
RestliRequestOptions forceOnOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setRequestCompressionOverride(CompressionOption.FORCE_ON).build();
RestliRequestOptions forceOffOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setRequestCompressionOverride(CompressionOption.FORCE_OFF).build();
return new Object[][] { // Compression depending on request size
{ null, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { null, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // Override the default threshold and cause even small requests to be compressed
{ tinyThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { tinyThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_COMPRESSION }, // Override the default threshold and causes even large requests to be NOT compressed.
{ hugeThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { hugeThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // Force on/off using RestliRequestOptions
{ null, encodings, forceOnOption, large, EXPECT_COMPRESSION }, { null, encodings, forceOnOption, small, EXPECT_COMPRESSION }, { hugeThresholdConfig, encodings, forceOnOption, small, EXPECT_COMPRESSION }, { null, encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, { null, encodings, forceOffOption, small, EXPECT_NO_COMPRESSION }, { tinyThresholdConfig, encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, // Force on/off using RequestCompressionConfig
{ new CompressionConfig(0), encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { new CompressionConfig(0), encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // RestliRequestOptions takes precedence over RequestCompressionConfig
{ new CompressionConfig(0), encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, forceOnOption, small, EXPECT_COMPRESSION }, // Can't compress if no encodings are available
{ null, "unsupportedEncoding", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { null, "", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(0), "unsupportedEncoding", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { null, "", forceOnOption, large, EXPECT_NO_COMPRESSION } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestResLiValidationWithProjection method provideProjectionWithValidFieldsBuilders.
@DataProvider
private Object[][] provideProjectionWithValidFieldsBuilders() throws DataProcessingException {
List<PathSpec> spec = Arrays.asList(ValidationDemo.fields().stringB(), ValidationDemo.fields().includedB(), ValidationDemo.fields().UnionFieldWithInlineRecord().MyRecord().foo2(), ValidationDemo.fields().ArrayWithInlineRecord().items().bar1(), ValidationDemo.fields().MapWithTyperefs().values().id(), ValidationDemo.fields().validationDemoNext().intB());
RootBuilderWrapper<Integer, ValidationDemo> wrapper = new RootBuilderWrapper<Integer, ValidationDemo>(new AutoValidationWithProjectionBuilders());
Request<CollectionResponse<ValidationDemo>> findRequest = wrapper.findBy("searchWithProjection").fields(spec.toArray(new PathSpec[spec.size()])).build();
Request<ValidationDemo> getRequest = wrapper.get().id(1).fields(spec.toArray(new PathSpec[spec.size()])).build();
Request<CollectionResponse<ValidationDemo>> getAllRequest = wrapper.getAll().fields(spec.toArray(new PathSpec[spec.size()])).build();
// Valid input for CreateAndGet
ValidationDemo.UnionFieldWithInlineRecord unionField = new ValidationDemo.UnionFieldWithInlineRecord();
unionField.setMyEnum(myEnum.FOOFOO);
ValidationDemo validDemo = new ValidationDemo().setStringB("b").setUnionFieldWithInlineRecord(unionField);
Request<IdEntityResponse<Integer, ValidationDemo>> createAndGetRequest = wrapper.createAndGet().input(validDemo).fields(spec.toArray(new PathSpec[spec.size()])).build();
Request<BatchCreateIdEntityResponse<Integer, ValidationDemo>> batchCreateAndGetRequest = wrapper.batchCreateAndGet().inputs(Arrays.asList(validDemo)).fields(spec.toArray(new PathSpec[spec.size()])).build();
return new Object[][] { { findRequest, HttpStatus.S_200_OK }, { getRequest, HttpStatus.S_200_OK }, { getAllRequest, HttpStatus.S_200_OK }, { createAndGetRequest, HttpStatus.S_201_CREATED }, { batchCreateAndGetRequest, HttpStatus.S_200_OK } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestResponseCompression method requestData.
@DataProvider(name = "requestData")
private Object[][] requestData() {
Integer zero = 0;
Integer tiny = 100;
Integer huge = 1000000;
Integer max = Integer.MAX_VALUE;
int largeIdCount = 100;
int smallIdCount = 1;
RestliRequestOptions forceOnOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setResponseCompressionOverride(CompressionOption.FORCE_ON).build();
RestliRequestOptions forceOffOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setResponseCompressionOverride(CompressionOption.FORCE_OFF).build();
return new Object[][] { // Large responses are compressed
{ true, null, RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, null, true }, { true, null, RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, null, false }, // Override the default threshold and cause small responses to be compressed
{ true, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, tiny.toString(), true }, { true, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, tiny.toString(), true }, // Override the default threshold and cause large responses to be NOT compressed
{ true, new CompressionConfig(huge), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, huge.toString(), false }, { true, new CompressionConfig(huge), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, huge.toString(), false }, // Force on/off using RestliRequestOptions
{ true, null, forceOnOption, largeIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, null, forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(huge), forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, null, forceOffOption, largeIdCount, NONE, null, false }, { true, null, forceOffOption, smallIdCount, NONE, null, false }, { true, new CompressionConfig(huge), forceOffOption, largeIdCount, NONE, null, false }, // Force on/off using ResponseCompressionConfig
{ true, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(Integer.MAX_VALUE), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, max.toString(), false }, { true, new CompressionConfig(Integer.MAX_VALUE), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, max.toString(), false }, // RestliRequestOptions takes precedence over ResponseCompressionConfig
{ true, new CompressionConfig(0), forceOffOption, largeIdCount, NONE, null, false }, { true, new CompressionConfig(Integer.MAX_VALUE), forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, // If http.useResponseCompression is false or null, Accept-Encoding header is not sent and response is not compressed
{ false, null, RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { false, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { false, null, forceOnOption, largeIdCount, NONE, null, false }, { null, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { null, new CompressionConfig(Integer.MAX_VALUE), forceOnOption, smallIdCount, NONE, null, false } };
}
Aggregations