I want to provide data in my dataProvider using json file which has Array in one parameter.
For single ID it works fine
But
ex. JsonFile
{
"dataSet": [
{
"testCase": "Verify the limit of IDListwith 11 IDList",
"IDList": ["1000394","1000418","1000438","1000463","1000464","1000491","1000519","1000525","1000526","1000537","1000549"]
},
{
"testCase": "Verify the limit of ksnList with ksn",
"ksnList":[ "1234" ]
}
]
}
Testng Dataprovider:
// Multiple Ids
@DataProvider
public static Object[][] getDataMul() throws FileNotFoundException, Exception {
String path = System.getProperty("user.dir") + "\\input\\MultipleID_ValidJson.json";
JsonElement jsonData = new JsonParser().parse(new FileReader(path));
JsonElement dataSet = jsonData.getAsJsonObject().get("dataset");
List<TestData_Json> testData = new Gson().fromJson(dataSet, new TypeToken<List<TestData_Json>>() {
}.getType());
Object[][] returnValue = new Object[testData.size()][1];
int index = 0;
for (Object[] each : returnValue) {
each[0] = testData.get(index++);
}
return returnValue;
}