diff --git a/java-checks-test-sources/default/pom.xml b/java-checks-test-sources/default/pom.xml index a5d059133fd..0b48cbb6ea7 100644 --- a/java-checks-test-sources/default/pom.xml +++ b/java-checks-test-sources/default/pom.xml @@ -609,7 +609,7 @@ provided - com.google.truth.extensions + com.google.truth.extensions truth-java8-extension 0.39 provided @@ -638,6 +638,12 @@ 3.0.2 provided + + io.rest-assured + spring-mock-mvc + 4.4.0 + test + com.fasterxml.jackson.core jackson-annotations @@ -921,13 +927,13 @@ aspectjweaver 1.9.9.1 provided - - - io.micronaut - micronaut-http - 3.7.2 - provided - + + + io.micronaut + micronaut-http + 3.7.2 + provided + com.fasterxml.woodstox woodstox-core @@ -935,11 +941,11 @@ provided - org.bouncycastle - bcprov-jdk15on - 1.70 - provided - + org.bouncycastle + bcprov-jdk15on + 1.70 + provided + org.hibernate.javax.persistence hibernate-jpa-2.0-api diff --git a/java-checks-test-sources/default/src/test/java/checks/tests/AssertionsInTestsCheck/RestAssured.java b/java-checks-test-sources/default/src/test/java/checks/tests/AssertionsInTestsCheck/RestAssured.java index 61c84bae899..96e1dc7bbad 100644 --- a/java-checks-test-sources/default/src/test/java/checks/tests/AssertionsInTestsCheck/RestAssured.java +++ b/java-checks-test-sources/default/src/test/java/checks/tests/AssertionsInTestsCheck/RestAssured.java @@ -1,6 +1,7 @@ package checks.tests.AssertionsInTestsCheck; import io.restassured.RestAssured; +import io.restassured.module.mockmvc.RestAssuredMockMvc; import io.restassured.builder.ResponseSpecBuilder; import io.restassured.response.ValidatableResponse; import io.restassured.specification.ResponseSpecification; @@ -10,6 +11,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan; +import static org.springframework.http.HttpStatus.FORBIDDEN; class RestAssuredTest { @@ -130,4 +132,14 @@ public void test_time() { // Compliant .then() .time(lessThan(2L), SECONDS); } + + @Test + public void test_status() { + + RestAssuredMockMvc.given() + .when() + .get("/api/expedientes") + .then() + .status(FORBIDDEN); + } } diff --git a/java-checks/src/main/java/org/sonar/java/checks/helpers/UnitTestUtils.java b/java-checks/src/main/java/org/sonar/java/checks/helpers/UnitTestUtils.java index a20650b3f9e..474a908b8ee 100644 --- a/java-checks/src/main/java/org/sonar/java/checks/helpers/UnitTestUtils.java +++ b/java-checks/src/main/java/org/sonar/java/checks/helpers/UnitTestUtils.java @@ -47,9 +47,10 @@ public final class UnitTestUtils { MethodMatchers.create().ofSubTypes("org.fest.assertions.GenericAssert", "org.fest.assertions.api.AbstractAssert").anyName().withAnyParameters().build(), // rest assured 2.x, 3.x, 4.x MethodMatchers.create().ofTypes( - "com.jayway.restassured.response.ValidatableResponseOptions", // restassured 2.x - "io.restassured.response.ValidatableResponseOptions" // restassured 3.x and 4.x - ) + "com.jayway.restassured.response.ValidatableResponseOptions", // restassured 2.x + "io.restassured.response.ValidatableResponseOptions", // restassured 3.x and 4.x + "io.restassured.module.mockmvc.response.ValidatableMockMvcResponse" // spring mock mvc extending the io.restassured library + ) .name(name -> "body".equals(name) || "time".equals(name) || name.startsWith("time") ||