java-tutorials/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java

39 lines
1.1 KiB
Java
Raw Normal View History

2019-12-01 18:29:04 +02:00
package controllers;
2019-12-08 14:40:42 +02:00
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
2019-12-01 18:29:04 +02:00
2019-12-08 14:40:42 +02:00
import javax.inject.Inject;
2019-12-01 18:29:04 +02:00
import org.doctester.testbrowser.Request;
import org.doctester.testbrowser.Response;
2019-12-08 14:40:42 +02:00
import org.junit.Test;
import org.mockito.Mock;
import ninja.NinjaDocTester;
import services.UserService;
2019-12-01 18:29:04 +02:00
public class ApiControllerDocTesterTest extends NinjaDocTester {
String URL_INDEX = "/";
2019-12-08 14:40:42 +02:00
String URL_HELLO = "/hello";
String URL_USER_JSON = "/userJson";
String URL_USERS = "/users";
@Mock
UserService userService;
2019-12-01 18:29:04 +02:00
@Test
public void testGetIndex() {
2019-12-08 14:40:42 +02:00
Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_INDEX)));
assertThat(response.payload, containsString("Bonjour, bienvenue dans Ninja Framework!"));
2019-12-01 18:29:04 +02:00
}
@Test
2019-12-08 14:40:42 +02:00
public void testGetHello() {
Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_HELLO)));
assertThat(response.payload, containsString("Hello, welcome to Ninja Framework!"));
2019-12-01 18:29:04 +02:00
}
2019-12-08 14:40:42 +02:00
2019-12-01 18:29:04 +02:00
}