Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
public class PageControllerTest {
@Autowired
PageRepository pageRepository;
@Value("${local.server.port}")
int port;
@Before
public void setUp() {
RestAssured.port = port;
}
@Test
public void links() {
when().get("/").then()
.statusCode(HttpStatus.SC_OK)
.contentType(JSON)
.body("_links.pages.href", Matchers.is("http://localhost:" + port + "/pages"))
.body("_links.portals.href", Matchers.is("http://localhost:" + port + "/portals"));
}
@Test
public void findPage( ) {
when().get("/pages/1").then().statusCode(HttpStatus.SC_OK).body("name", Matchers.is("login"));
}
@Test
public void deleteExistingPage() {
when().delete("/pages/2").then().statusCode(HttpStatus.SC_NO_CONTENT);
}
@Test
public void deleteNonExistingPage() {
when().delete("/pages/6").then().statusCode(HttpStatus.SC_NOT_FOUND);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.