public final class JsonDataProviderImpl extends Object implements SeLionDataProvider
Constructor and Description |
---|
JsonDataProviderImpl(DataResource resource) |
Modifier and Type | Method and Description |
---|---|
Object[][] |
getAllData()
Parses the JSON file as a 2D Object array for TestNg dataprovider usage.
|
Hashtable<String,Object> |
getDataAsHashtable()
A utility method to give out JSON data as HashTable.
|
Iterator<Object[]> |
getDataByFilter(DataProviderFilter dataFilter)
Gets JSON data from a resource by applying the given filter.
|
Object[][] |
getDataByIndex(int[] indexes)
Gets JSON data from a resource for the specified indexes.
|
Object[][] |
getDataByIndex(String indexes)
Gets JSON data from a resource for the specified indexes.
|
Object[][] |
getDataByKeys(String[] keys)
Generates a two dimensional array for TestNG DataProvider from the data representing a map of name value
collection filtered by keys.
|
public JsonDataProviderImpl(DataResource resource)
public Object[][] getAllData()
Array Of Objects mapped to a user defined type:
[
{
"name":"Optimus Prime",
"password":123456,
"accountNumber":999999999,
"amount":50000,
"areaCode":[{ "areaCode" :"area1"},
{ "areaCode" :"area2"}],
"bank":{
"name" : "Bank1",
"type" : "Savings",
"address" : {
"street":"1234 Some St"
}
},
"phoneNumber":"1111111111",
"preintTest":10
},
{
"name":"Megatron",
"password":123456,
"accountNumber":999999999,
"amount":80000,
"areaCode":[{ "areaCode" :"area3"},
{ "areaCode" :"area4"}],
"bank":{
"name" : "Bank2",
"type" : "Current",
"address" : {
"street":"1234 any St"
}
},
"phoneNumber":"1111111111",
"preintTest":100
}
]
Test Method Signature
public void readJsonArray(TestData testData)
getAllData
in interface SeLionDataProvider
public Object[][] getDataByIndex(String indexes)
getDataByIndex
in interface SeLionDataProvider
indexes
- The set of indexes to be fetched from the JSON file.public Object[][] getDataByIndex(int[] indexes)
getDataByIndex
in interface SeLionDataProvider
indexes
- The set of indexes to be fetched from the JSON file.public Iterator<Object[]> getDataByFilter(DataProviderFilter dataFilter)
getDataByFilter
in interface SeLionDataProvider
dataFilter
- an implementation class of DataProviderFilter
public Hashtable<String,Object> getDataAsHashtable()
[ { "id":"test1", "password":123456, "accountNumber":9999999999, "amount":80000, "areaCode":[{ "areaCode" :"area3"}, { "areaCode" :"area4"}], "bank":{ "name" : "Bank1", "type" : "Current", "address" : { "street":"1234 dark St" } } } ] Here the key to the data in the hashtable will be "test1"
getDataAsHashtable
in interface SeLionDataProvider
Hashtable
public Object[][] getDataByKeys(String[] keys)
SeLionDataProvider
getDataByKeys
in interface SeLionDataProvider
keys
- The string keys to filter the data.Copyright © 2016 PayPal Open Source. All rights reserved.