Skip to content

Commit

Permalink
Test a Bean Validation annotation on a parameter
Browse files Browse the repository at this point in the history
Add a test for a BeanValidation annotation added to a resource method
parameter.
  • Loading branch information
Azquelt committed Jun 20, 2022
1 parent 2ac736c commit 6556e4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -16,9 +16,11 @@
package org.eclipse.microprofile.openapi.apps.beanvalidation;

import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.core.MediaType;

@Path("/")
Expand All @@ -28,4 +30,9 @@ public class BeanValidationResource {
@Consumes(MediaType.APPLICATION_JSON)
public void test(@Valid BeanValidationData data) {
}

@POST
@Path("parameter/{test}")
public void test(@PathParam("test") @Size(max = 6) String size) {
}
}
Expand Up @@ -195,6 +195,15 @@ public void defaultAndOtherGroupsTest(String format) {
assertProperty(vr, "defaultAndOtherGroups", hasEntry("minLength", 1));
}

@Test(dataProvider = "formatProvider")
@RunAsClient
public void parameterTest(String format) {
ValidatableResponse vr = callEndpoint(format);
String schemaPath = dereference(vr, "paths.'/parameter/{test}'.post.parameters[0]", "schema");
vr.body(schemaPath, hasEntry("maxLength", 6));
vr.body(schemaPath, hasEntry("type", "string"));
}

/**
* Asserts that a property from the test schema matches the given matcher
*
Expand Down

0 comments on commit 6556e4d

Please sign in to comment.