Error: java.lang.NullPointerException: Can not invoke method trim ()

0

I've tried using Port and the baseUri and does not run the rest, it always fails.

Full error:

  

java.lang.NullPointerException: Can not invoke method trim () on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod (NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite. call (PogoMetaClassSite.java:47) at org.codehaus.groovy.runtime.callsite.CallSiteArray

Project code:

package br.com.academia.poo;

import static com.jayway.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.jayway.restassured.RestAssured;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AcademiapooApplicationTests {

    public AcademiapooApplicationTests() {
        RestAssured.baseURI = "localhost:8080/" ;
    }

    @Test
    /* Chama o serviço pelo metodo POST */
    public void testCriaUsuario() {
        String myJson = "{\"id\":\"1\",\"name\": \"vanessa\"}";

        given()
            .contentType("application/json")
            .body(myJson)
        .when()
            .post("/clientes")
        .then()
            .statusCode(200)
            .body("message",containsString("usuário criado com sucesso"));
    }

    /*
     * @Test public void testPegarCliente() {
     * 
     * given() .when() .get("/clientes/1") .then() .statusCode(200) .body("id",
     * is(1)) .body("username", equalTo("vanessa")) .assertThat()
     * .body(matchesJsonSchemaInClasspath("clienteTest.json")); }
     */
}
    
asked by anonymous 29.09.2018 / 20:38

1 answer

0

The error you are having says that you are calling the TRIM method in through a string that was not initialized with no valid value, probably a NULL, look for its error there by the PogoMetaClassSite file in the call method near line 47.

    
29.09.2018 / 21:00