104 lines
3.7 KiB
Java
104 lines
3.7 KiB
Java
package em;
|
|
|
|
import org.junit.AfterClass;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import static org.junit.Assert.*;
|
|
import java.util.Map;
|
|
import java.util.List;
|
|
import static org.evomaster.client.java.controller.api.EMTestUtils.*;
|
|
import org.evomaster.client.java.controller.SutHandler;
|
|
import io.restassured.RestAssured;
|
|
import static io.restassured.RestAssured.given;
|
|
import io.restassured.response.ValidatableResponse;
|
|
import static org.hamcrest.Matchers.*;
|
|
import io.restassured.config.JsonConfig;
|
|
import io.restassured.path.json.config.JsonPathConfig;
|
|
import static io.restassured.config.RedirectConfig.redirectConfig;
|
|
import static org.evomaster.client.java.controller.contentMatchers.NumberMatcher.*;
|
|
import static org.evomaster.client.java.controller.contentMatchers.StringMatcher.*;
|
|
import static org.evomaster.client.java.controller.contentMatchers.SubStringMatcher.*;
|
|
import static org.evomaster.client.java.controller.expect.ExpectationHandler.expectationHandler;
|
|
import org.evomaster.client.java.controller.expect.ExpectationHandler;
|
|
import io.restassured.path.json.JsonPath;
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
/**
|
|
* This file was automatically generated by EvoMaster on 2023-05-28T14:22:53.294248+02:00[Europe/Rome]
|
|
* <br>
|
|
* The generated test suite contains 1 tests
|
|
* <br>
|
|
* Covered targets: 5
|
|
* <br>
|
|
* Used time: 0h 5m 0s
|
|
* <br>
|
|
* Needed budget for current results: 100%
|
|
* <br>
|
|
* This file contains test cases that are likely to indicate faults.
|
|
*/
|
|
public class EvoMaster_faults_Test {
|
|
|
|
|
|
private static String baseUrlOfSut = "http://localhost:8080";
|
|
/** [ems] - expectations master switch - is the variable that activates/deactivates expectations individual test cases
|
|
* by default, expectations are turned off. The variable needs to be set to [true] to enable expectations
|
|
*/
|
|
private static boolean ems = false;
|
|
/**
|
|
* sco - supported code oracle - checking that the response status code is among those supported according to the schema
|
|
*/
|
|
private static boolean sco = false;
|
|
|
|
|
|
@BeforeClass
|
|
public static void initClass() {
|
|
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
|
|
RestAssured.useRelaxedHTTPSValidation();
|
|
RestAssured.urlEncodingEnabled = false;
|
|
RestAssured.config = RestAssured.config()
|
|
.jsonConfig(JsonConfig.jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.DOUBLE))
|
|
.redirect(redirectConfig().followRedirects(false));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(timeout = 60000)
|
|
public void test_0_with500() throws Exception {
|
|
ExpectationHandler expectationHandler = expectationHandler();
|
|
|
|
given().accept("*/*")
|
|
.delete(baseUrlOfSut + "/api/comments/Xfecwx7ykcU8h")
|
|
.then()
|
|
.statusCode(404)
|
|
.assertThat()
|
|
.contentType("text/plain")
|
|
.body(containsString("The comment with idXfecwx7ykcU8h was not found"));
|
|
|
|
|
|
ValidatableResponse res_1 = given().accept("application/json")
|
|
.get(baseUrlOfSut + "/api/comments?limit=0")
|
|
.then()
|
|
.statusCode(500)
|
|
.assertThat()
|
|
.contentType("application/json")
|
|
.body("'status'", numberMatches(500.0))
|
|
.body("'error'", containsString("Internal Server Error"))
|
|
.body("'message'", containsString(""))
|
|
.body("'path'", containsString("/api/comments"));
|
|
|
|
expectationHandler.expect(ems)
|
|
.that(sco, Arrays.asList(200, 400).contains(res_1.extract().statusCode()));
|
|
}
|
|
|
|
|
|
}
|