-1
I have tried using Port and baseUri and does not run the rest, always fails.
Complete error:
java.lang.NullPointerException: Cannot 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")); }
*/
}
Does this Answer your Question? What is Nullpointerexception and what are its main causes?
– Darlei Fernando Zillmer