java - How to return parametrised List<T> in Interface RequestSpecification? -


when get request interface requestspecification , want return parametrized list<t>, must in method .as()??? highlight bold! maybe must specify 1 of implementations of list? need specific parametrized list!

list<> response = given().parameter(x,x)                    .expect()                    .statuscode(200)                    .when()                    .get("some kind of get")                    **.as(list<>.class)** 

welcome type erasure. lists same @ runtime. unless have type information of parameter type class object, can is:

@suppresswarnings("unchecked") list<desiredtype> response = (list<desiredtype>)given().parameter(x,x)                .expect()                .statuscode(200)                .when()                .get("some kind of get")                .as(list.class); 

be aware though if puts in objects not of type desiredtype, encounter problems when accessing list later on.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -