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

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

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