Skip to content

Commit

Permalink
Rest data with panache: add the parameter names in resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario authored and pedroh-pereira committed Nov 14, 2022
1 parent bb2d0ac commit 52538d5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
resourceMetadata.getEntityType());
methodCreator.setParameterNames(new String[] { "entity" });

// Add method annotations
addPathAnnotation(methodCreator, resourceProperties.getPath(RESOURCE_METHOD_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
resourceMetadata.getIdType());
methodCreator.setParameterNames(new String[] { "id" });

// Add method annotations
addPathAnnotation(methodCreator, appendToPath(resourceProperties.getPath(RESOURCE_METHOD_NAME), "{id}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
resourceMetadata.getIdType());
methodCreator.setParameterNames(new String[] { "id" });

// Add method annotations
addPathAnnotation(methodCreator, appendToPath(resourceProperties.getPath(RESOURCE_METHOD_NAME), "{id}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private void implementPaged(ClassCreator classCreator, ResourceMetadata resource
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
List.class, int.class, int.class, UriInfo.class);
methodCreator.setParameterNames(new String[] { "sort", "page", "size", "uriInfo" });

// Add method annotations
addGetAnnotation(methodCreator);
Expand Down Expand Up @@ -205,6 +206,7 @@ private void implementNotPaged(ClassCreator classCreator, ResourceMetadata resou
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
List.class);
methodCreator.setParameterNames(new String[] { "sort" });

// Add method annotations
addGetAnnotation(methodCreator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
resourceMetadata.getIdType(), resourceMetadata.getEntityType());
methodCreator.setParameterNames(new String[] { "id", "entity" });

// Add method annotations
addPathAnnotation(methodCreator, appendToPath(resourceProperties.getPath(RESOURCE_UPDATE_METHOD_NAME), "{id}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ private void implementPaged(ClassCreator classCreator, ResourceMetadata resource
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
List.class, int.class, int.class, UriInfo.class);
methodCreator.setParameterNames(new String[] { "sort", "page", "size", "uriInfo" });

// Add method annotations
addPathAnnotation(methodCreator, resourceProperties.getPath(RESOURCE_METHOD_NAME));
Expand Down Expand Up @@ -205,6 +206,7 @@ private void implementNotPaged(ClassCreator classCreator, ResourceMetadata resou
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, resourceMetadata.getEntityType()),
List.class);
methodCreator.setParameterNames(new String[] { "sort" });

// Add method annotations
addPathAnnotation(methodCreator, resourceProperties.getPath(RESOURCE_METHOD_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void shouldNotCreateBookWithBlankTitle() {
.and().body(book.toString())
.when().post("/books")
.then().statusCode(400)
.and().body("parameterViolations[0].path", equalTo("add.arg0.title"))
.and().body("parameterViolations[0].path", equalTo("add.entity.title"))
.and().body("parameterViolations[0].message", equalTo("must not be blank"));
}

Expand Down Expand Up @@ -307,7 +307,7 @@ void shouldNotUpdateBookWithBlankTitle() {
.and().body(book.toString())
.when().put("/books/" + CRIME_AND_PUNISHMENT_ID)
.then().statusCode(400)
.and().body("parameterViolations[0].path", equalTo("update.arg1.title"))
.and().body("parameterViolations[0].path", equalTo("update.entity.title"))
.and().body("parameterViolations[0].message", equalTo("must not be blank"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void shouldNotCreateBookWithBlankTitle() {
.and().body(book.toString())
.when().post("/books")
.then().statusCode(400)
.and().body("parameterViolations[0].path", equalTo("add.arg0.title"))
.and().body("parameterViolations[0].path", equalTo("add.entity.title"))
.and().body("parameterViolations[0].message", equalTo("must not be blank"));
}

Expand Down Expand Up @@ -242,7 +242,7 @@ void shouldNotUpdateBookWithBlankTitle() {
.and().body(book.toString())
.when().put("/books/" + CRIME_AND_PUNISHMENT_ID)
.then().statusCode(400)
.and().body("parameterViolations[0].path", equalTo("update.arg1.title"))
.and().body("parameterViolations[0].path", equalTo("update.entity.title"))
.and().body("parameterViolations[0].message", equalTo("must not be blank"));
}
}

0 comments on commit 52538d5

Please sign in to comment.