0

I am executing below Rest Assured Program:

        io.restassured.RestAssured.baseURI ="http://a.b.c.d:9200/e/f";
        Response responseNew=null;
        request = RestAssured.given();

        JSONObject requestparams = new JSONObject();
        //Setting params
        requestparams.put("field", "1");
        request.body(requestparams.toJSONString());
        
        //Submitting Request
        responseNew= request.when().contentType(ContentType.JSON).accept(ContentType.JSON)
                .body(inputObject).when().post("/path");
        
        //Status Code Check
        responseNew.then().assertThat().statusCode(200);

I am getting below Error at the line where Status code is verified,

Exception in thread "main" java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(Unknown Source)
    at java.lang.ClassLoader.preDefineClass(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    
        
  • This might help you https://stackoverflow.com/a/43003862/7574461 – lucas-nguyen-17 Oct 19 '21 at 09:03
  • Hi , After doing this, Exception is thrown for line "responseNew.then().assertThat().statusCode(200);" java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.List at io.restassured.path.json.JsonPath.getList(JsonPath.java:375) at com.AllFunctions.Counts_RestAssured.RegistrationSuccessful(Counts_RestAssured.java:145) – Abhishek Rao Oct 19 '21 at 09:31
  • This error means you're try to extract data from response body with wrong path. `responseNew.then().assertThat().statusCode(200)` doesn't extract anything from response body. Please add more info to your question. full stack trace, response body and full code. – lucas-nguyen-17 Oct 19 '21 at 12:21
  • Hi , Below is the code, io.restassured.RestAssured.baseURI ="http://a.b.c.d:9200/e/f"; Response responseNew=null; request = RestAssured.given(); JSONObject requestparams = new JSONObject(); requestparams.put("parameter", "1"); request.body(requestparams.toJSONString()); responseNew= request.when().contentType(ContentType.JSON).accept(ContentType.JSON) .body(inputObject).when().post("/_search"); responseNew.then().assertThat().statusCode(200); JsonPath extractor = responseNew.jsonPath(); List valid_rec_1= extractor.getList("field_name"); – Abhishek Rao Oct 19 '21 at 13:39
  • Please update your question, I cannot read code in comment. Thanks – lucas-nguyen-17 Oct 19 '21 at 13:51
  • Hi , Can you pl give me your email address?I will send the code.Not able to fit in . – Abhishek Rao Oct 19 '21 at 14:34
  • It's better if we can solve the problem here, in Stackoverflow. I think the problem is `List valid_rec_1= extractor.getList("field_name");` You just need to edit your question, add sample response and actual `field_name`, then I can figure it out. – lucas-nguyen-17 Oct 19 '21 at 15:17
  • https://stackoverflow.com/a/17565202/3190953 – Wilfred Clement Oct 19 '21 at 15:18
  • field Name:unique_id , Datatype:String , Response : io.restassured.internal.RestAssuredResponseImpl@8692d67 – Abhishek Rao Oct 19 '21 at 16:12
  • Now getting Null Pointer Exception at Line : List valid_rec_1= extractor.getList("field_name"); – Abhishek Rao Oct 19 '21 at 16:12
  • @AbhishekRao If the issue with `Hamcrest verion` is solved, then close this question and open new question for new issue. *PLEASE*, add enough detail to your question. – lucas-nguyen-17 Oct 20 '21 at 02:55

0 Answers0