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")); }
*/
}