use of org.testng.annotations.DataProvider in project pinot by linkedin.
the class TestWeekOverWeekRuleFunction method timeSeriesDataProvider.
@DataProvider(name = "timeSeriesDataProvider")
public Object[][] timeSeriesDataProvider() {
// The properties for the testing time series
Properties properties = new Properties();
long bucketSizeInMS = TimeUnit.SECONDS.toMillis(1);
// Set up time series key for the testing time series
TimeSeriesKey timeSeriesKey = new TimeSeriesKey();
String metric = mainMetric;
timeSeriesKey.setMetricName(metric);
DimensionMap dimensionMap = new DimensionMap();
dimensionMap.put("dimensionName1", "dimensionValue1");
dimensionMap.put("dimensionName2", "dimensionValue2");
timeSeriesKey.setDimensionMap(dimensionMap);
TimeSeries observedTimeSeries = new TimeSeries();
{
observedTimeSeries.set(observedStartTime, 10d);
observedTimeSeries.set(observedStartTime + bucketMillis, 15d);
observedTimeSeries.set(observedStartTime + bucketMillis * 2, 13d);
observedTimeSeries.set(observedStartTime + bucketMillis * 3, 27d);
observedTimeSeries.set(observedStartTime + bucketMillis * 4, 10d);
Interval observedTimeSeriesInterval = new Interval(observedStartTime, observedStartTime + bucketMillis * 5);
observedTimeSeries.setTimeSeriesInterval(observedTimeSeriesInterval);
}
List<TimeSeries> baselines = new ArrayList<>();
TimeSeries baseline1TimeSeries = new TimeSeries();
{
baseline1TimeSeries.set(baseline1StartTime, 10d);
baseline1TimeSeries.set(baseline1StartTime + bucketMillis, 20d);
baseline1TimeSeries.set(baseline1StartTime + bucketMillis * 2, 15d);
baseline1TimeSeries.set(baseline1StartTime + bucketMillis * 3, 24d);
baseline1TimeSeries.set(baseline1StartTime + bucketMillis * 4, 14d);
Interval baseline1Interval = new Interval(baseline1StartTime, baseline1StartTime + bucketMillis * 5);
baseline1TimeSeries.setTimeSeriesInterval(baseline1Interval);
}
baselines.add(baseline1TimeSeries);
TimeSeries baseline2TimeSeries = new TimeSeries();
{
baseline2TimeSeries.set(baseline2StartTime, 10d);
baseline2TimeSeries.set(baseline2StartTime + bucketMillis, 10d);
baseline2TimeSeries.set(baseline2StartTime + bucketMillis * 2, 5d);
baseline2TimeSeries.set(baseline2StartTime + bucketMillis * 3, 20d);
baseline2TimeSeries.set(baseline2StartTime + bucketMillis * 4, 10d);
Interval baseline2Interval = new Interval(baseline2StartTime, baseline2StartTime + bucketMillis * 5);
baseline2TimeSeries.setTimeSeriesInterval(baseline2Interval);
}
baselines.add(baseline2TimeSeries);
return new Object[][] { { properties, timeSeriesKey, bucketSizeInMS, observedTimeSeries, baselines } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestMIMEInputStream method timeoutDataSources.
///////////////////////////////////////////////////////////////////////////////////////
//This test will verify that timeouts on reads are handled properly.
@DataProvider(name = "timeoutDataSources")
public Object[][] timeoutDataSources() throws Exception {
final StringBuilder builder = new StringBuilder();
final Random rand = new Random();
//Create some large data
for (int i = 0; i < (TEST_CHUNK_SIZE * 120); i++) {
//Randomly populate
char c = (char) (rand.nextInt(26) + 'a');
builder.append(c);
}
final byte[] largeInputData = builder.toString().getBytes();
final CountDownLatch timeoutFirstLatch = new CountDownLatch(1);
final CountDownLatch timeoutSubsequentlyLatch = new CountDownLatch(1);
final TimeoutByteArrayInputStream timeoutFirst = new TimeoutByteArrayInputStream(largeInputData, 0, timeoutFirstLatch);
final TimeoutByteArrayInputStream timeoutSubsequently = new TimeoutByteArrayInputStream(largeInputData, 5, timeoutSubsequentlyLatch);
//TEST_CHUNK_SIZE * 5 writes should be how much data was copied over
final byte[] largeInputDataPartial = Arrays.copyOf(largeInputData, TEST_CHUNK_SIZE * 5);
return new Object[][] { //Timeout on first read. Nothing should have been read. One call on writeHandle.remaining() should have been seen.
{ timeoutFirst, 0, 1, new byte[0], timeoutFirstLatch }, //Timeout on the 6th read. We should expect 5 writes. Six calls on writeHandle.remaining() should have been seen.
{ timeoutSubsequently, 5, 6, largeInputDataPartial, timeoutSubsequentlyLatch } };
}
use of org.testng.annotations.DataProvider in project weixin-java-tools by chanjarster.
the class WxMpBusyRetryTest method getService.
@DataProvider(name = "getService")
public Object[][] getService() {
WxMpService service = new WxMpServiceImpl() {
@Override
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
WxError error = new WxError();
error.setErrorCode(-1);
throw new WxErrorException(error);
}
};
service.setMaxRetryTimes(3);
service.setRetrySleepMillis(500);
return new Object[][] { new Object[] { service } };
}
use of org.testng.annotations.DataProvider in project weixin-java-tools by chanjarster.
the class WxMpMenuAPITest method getMenu.
@DataProvider(name = "menu")
public Object[][] getMenu() {
WxMenu menu = new WxMenu();
WxMenuButton button1 = new WxMenuButton();
button1.setType(WxConsts.BUTTON_CLICK);
button1.setName("今日歌曲");
button1.setKey("V1001_TODAY_MUSIC");
WxMenuButton button2 = new WxMenuButton();
button2.setType(WxConsts.BUTTON_CLICK);
button2.setName("歌手简介");
button2.setKey("V1001_TODAY_SINGER");
WxMenuButton button3 = new WxMenuButton();
button3.setName("菜单");
menu.getButtons().add(button1);
menu.getButtons().add(button2);
menu.getButtons().add(button3);
WxMenuButton button31 = new WxMenuButton();
button31.setType(WxConsts.BUTTON_VIEW);
button31.setName("搜索");
button31.setUrl("http://www.soso.com/");
WxMenuButton button32 = new WxMenuButton();
button32.setType(WxConsts.BUTTON_VIEW);
button32.setName("视频");
button32.setUrl("http://v.qq.com/");
WxMenuButton button33 = new WxMenuButton();
button33.setType(WxConsts.BUTTON_CLICK);
button33.setName("赞一下我们");
button33.setKey("V1001_GOOD");
button3.getSubButtons().add(button31);
button3.getSubButtons().add(button32);
button3.getSubButtons().add(button33);
return new Object[][] { new Object[] { menu } };
}
use of org.testng.annotations.DataProvider in project weixin-java-tools by chanjarster.
the class WxMpMessageRouterTest method standardSessionManager.
@DataProvider
public Object[][] standardSessionManager() {
// 故意把session存活时间变短,清理更频繁
StandardSessionManager ism = new StandardSessionManager();
ism.setMaxInactiveInterval(1);
ism.setProcessExpiresFrequency(1);
ism.setBackgroundProcessorDelay(1);
return new Object[][] { new Object[] { ism } };
}
Aggregations