Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悶: 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 · 0 comments
Labels
triage type:bug Something isn't working

Comments

@mariantocu
Copy link

mariantocu commented 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:


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

@mariantocu mariantocu added triage type:bug Something isn't working labels Mar 28, 2024
@mariantocu 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant