Skip to content

Commit

Permalink
Test case with named @restform
Browse files Browse the repository at this point in the history
See issue quarkiverse#248
  • Loading branch information
jmini committed Sep 19, 2024
1 parent 0aa25f7 commit a10cd25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions integration-tests/src/main/java/rest/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;

import org.hibernate.validator.constraints.Length;
import org.jboss.resteasy.reactive.RestForm;
import org.jboss.resteasy.reactive.RestPath;
import org.jboss.resteasy.reactive.RestQuery;
Expand Down Expand Up @@ -103,6 +104,12 @@ public TemplateInstance validatedAction(@RestForm @NotBlank String required,
return Templates.validatedForm();
}

@POST
public String withLengthValidation(@RestForm("foo") @Length(min = 2, max = 4) String param) {
return "Got 'foo' param: " + param + ", has errors: " + validation.hasErrors() + ", 'foo' error: "
+ validation.getError("foo");
}

@Path("/absolute")
public String absolutePath() {
return "Absolute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ public void testValidationError() {
"Email: must be a well-formed email address\n\n\nManual: Required\n\n\nRequired: must not be blank\n\n\n"));
}

@Test
public void testValidationErrorOnNamedRestForm() {
given()
.when()
.formParam("foo", "123456")
.post("/Application/withLengthValidation")
.then()
.statusCode(200)
.body(is("Got 'foo' param: 123456, has errors: true, 'foo' error: length must be between 2 and 4"));
}

@Test
public void testValidationErrorFlash() {
RenardeCookieFilter cookieFilter = new RenardeCookieFilter();
Expand Down

0 comments on commit a10cd25

Please sign in to comment.