Skip to content

Commit

Permalink
Updated RuntimeParamConverterTest with the new empty parameter behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaz Mrak committed Aug 22, 2024
1 parent 2108e39 commit 494116b
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void sendEmptyParameter() {
.when().get("/param-converter")
.then()
.statusCode(200)
.body(Matchers.is("Hello! You provided an empty number."));
.body(Matchers.is("Hello, world! No number was provided."));
}

@ApplicationScoped
Expand All @@ -70,12 +70,8 @@ public static class ParamConverterEndpoint {

@GET
public Response greet(@QueryParam("number") Optional<Integer> numberOpt) {
if (numberOpt != null) {
if (numberOpt.isPresent()) {
return Response.ok(String.format("Hello, %s!", numberOpt.get())).build();
} else {
return Response.ok("Hello! You provided an empty number.").build();
}
if (numberOpt.isPresent()) {
return Response.ok(String.format("Hello, %s!", numberOpt.get())).build();
} else {
return Response.ok("Hello, world! No number was provided.").build();
}
Expand Down Expand Up @@ -108,10 +104,6 @@ public static class OptionalIntegerParamConverter implements ParamConverter<Opti
@Override
public Optional<Integer> fromString(String value) {
if (value == null) {
return null;
}

if (value.trim().isEmpty()) {
return Optional.empty();
}

Expand Down

0 comments on commit 494116b

Please sign in to comment.