You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐞: RestAssured - When sending a list for a formParam parameterValues, you will get "class java.util.LinkedList cannot be cast to class java.lang.String".
#1025
Open
1 task done
mariantocu opened this issue
Mar 28, 2024
· 1 comment
🐞: 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)
mariantocu
changed the title
🐞: When sending a list for a formParam parameterValues you will get class java.util.LinkedList cannot be cast to class java.lang.String.
🐞: RestAssured - When sending a list for a formParam parameterValues, you will get "class java.util.LinkedList cannot be cast to class java.lang.String".
Mar 28, 2024
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:
StackTrace:
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
It should be related to #1016
The text was updated successfully, but these errors were encountered: