๐: RestAssured - When sending a list for a formParam parameterValues, you will get "class java.util.LinkedList cannot be cast to class java.lang.String".
mariantocu opened this issue ยท 1 comments
mariantocu commented
What happened?
๐: When sending a list for a formParam parameterValues you will get class java.util.LinkedList cannot be cast to class java.lang.String. Allure it's trying to add to the curl the form parameters but it expected that the parameter value to be String. Instead it is an ArrayList.
Ex:
import io.qameta.allure.restassured.AllureRestAssured;
import io.restassured.RestAssured;
import java.util.List;
import static io.restassured.RestAssured.given;
import static io.restassured.http.Method.POST;
public class Test {
@org.junit.jupiter.api.Test
public void test() {
List<Person> persons = List.of(new Person("Brandon", 30), new Person("Lisa", 25));
RestAssured.replaceFiltersWith(new AllureRestAssured());
given()
.formParam("data", persons)
.baseUri("http://127.0.0.1")
.when().request(POST, "person")
.then().extract().response();
}
}
class Person {
public String name;
public int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
}
StackTrace:
java.lang.ClassCastException: class java.util.LinkedList cannot be cast to class java.lang.String (java.util.LinkedList and java.lang.String are in module java.base of loader 'bootstrap')
at java.base/java.util.HashMap.forEach(HashMap.java:1429)
at io.qameta.allure.attachment.http.HttpRequestAttachment$Builder.getCurl(HttpRequestAttachment.java:253)
at io.qameta.allure.attachment.http.HttpRequestAttachment$Builder.build(HttpRequestAttachment.java:242)
at io.qameta.allure.restassured.AllureRestAssured.filter(AllureRestAssured.java:105)
at io.restassured.filter.Filter$filter$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
at io.restassured.filter.FilterContext$next.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at io.restassured.internal.filter.CsrfFilter.filter(CsrfFilter.groovy:70)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:157)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
at io.restassured.filter.FilterContext$next.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1704)
at io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1334)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1089)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1008)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:791)
at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)
at io.restassured.internal.RequestSpecificationImpl.request(RequestSpecificationImpl.groovy:296)
at io.restassured.internal.RequestSpecificationImpl.request(RequestSpecificationImpl.groovy)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1334)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1089)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1008)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:791)
at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)
at io.restassured.internal.RequestSpecificationImpl.request(RequestSpecificationImpl.groovy:292)
at io.restassured.internal.RequestSpecificationImpl.request(RequestSpecificationImpl.groovy)
What Allure Integration are you using?
allure-rest-assured
What version of Allure Integration you are using?
2.26.0
What version of Allure Report you are using?
2.26.0
Code of Conduct
- I agree to follow this project's Code of Conduct
It should be related to #1016