casting - Convert Queue<Deque<String>> into Object[][] in Java -
i'm building dynamic test @dataprovider
annotation testng. in java, how convert data structure defined queue<deque<string>> queueofdeques = arraydeque<deque<string>>();
object[][]
? based on this explanation, tried this:
@dataprovider( name = "providedqueue" ) public static object[][] datafortest(){ return new object[][]{{someclass.getqueueofdeques}}; }
where method getqueueofdeques
returns queueofdeques
data structure defined above. don't know i'm doing wrong, not converting variable should be, deriving testng ignores parameterized test.
java.lang.classcastexception: net.easysol.detectid.migrationtester.arraydeque cannot cast java.lang.string
simply iteration:
static object[][] convert(collection<? extends collection<?>> cc) { object[][] res = new object[cc.size()][]; int = 0; (collection<?> c : cc) res[i++] = c.toarray(); return res; }
such general method converting collection of collections (they may queue
, deque
, list
, many others) of type (as <?>
refers) object[][]
array.
Comments
Post a Comment