Are the Create new
Gatling tests that have another object as required supposed to fail ? Or did I broke something ? Is it a bug ?
For example, this Test on docField
fails (doctTemplate --many--> docFields
), I'm guessing that it fails because docField requires the docTemplate
object and the generated tests does not add that object. This is my test result:
================================================================================
2017-06-02 19:06:23 100s elapsed
---- Requests ------------------------------------------------------------------
> Global (OK=400 KO=95 )
> First unauthenticated request (OK=100 KO=0 )
> Authentication (OK=100 KO=0 )
> Authenticated request (OK=100 KO=0 )
> Get all docFields (OK=100 KO=0 )
> Create new docField (OK=0 KO=95 )
---- Errors --------------------------------------------------------------------
> status.find.is(201), but actually found 400 95 (100.0%)
This is the class
public class DocField implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
@NotNull
@Lob
@Column(name = "default_value", nullable = false)
private String defaultValue;
@ManyToOne(optional = false)
@NotNull
private DocTemplate docTemplate;
And this is the test scenario:
val scn = scenario("Test the DocField entity")
.exec(http("First unauthenticated request")
.get("/api/account")
.headers(headers_http)
.check(status.is(401))
.check(headerRegex("Set-Cookie", "XSRF-TOKEN=(.*);[\\s]").saveAs("xsrf_token"))).exitHereIfFailed
.pause(10)
.exec(http("Authentication")
.post("/api/authentication")
.headers(headers_http_authenticated)
.formParam("j_username", "admin")
.formParam("j_password", "admin")
.formParam("remember-me", "true")
.formParam("submit", "Login")
.check(headerRegex("Set-Cookie", "XSRF-TOKEN=(.*);[\\s]").saveAs("xsrf_token"))).exitHereIfFailed
.pause(1)
.exec(http("Authenticated request")
.get("/api/account")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(10)
.repeat(2) {
exec(http("Get all docFields")
.get("/api/doc-fields")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(10 seconds, 20 seconds)
.exec(http("Create new docField")
.post("/api/doc-fields")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "name":"SAMPLE_TEXT", "defaultValue":"SAMPLE_TEXT"}""")).asJSON
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_docField_url"))).exitHereIfFailed
.pause(10)
.repeat(5) {
exec(http("Get created docField")
.get("${new_docField_url}")
.headers(headers_http_authenticated))
.pause(10)
}
.exec(http("Delete created docField")
.delete("${new_docField_url}")
.headers(headers_http_authenticated))
.pause(10)
}
I don't see any creation of DocTemplate, so the test fails. Doesn't jhipster supposed to generate the test so it passes right after code generation ? or did I broke it somehow ?