For context, I have been trying to find the resolution outside, but cannot find any.

So, I have a controller with path /api/{enum}/something. This path variable is mapped to some enum. Now, I want to create a unit test using WebTestClient something like below.

@SpringJUnitConfig({SomethingController.class})
@WebFluxTest(controllers = SomethingController.class)
class SomethingControllerTest {

  @Autowired
  private WebTestClient client;

  @Nested
  class SubTest {

    @Test
    void test() throws Exception {
      // arrange
      final var request = new Request();

      // act
      client.post()
          .uri("/api/{enum}/something", "ENUMA") // if I put upper case here. it's working. if I put lower case "enuma", it's not working.
          .contentType(MediaType.APPLICATION_JSON)
          .bodyValue(request)
          .exchange()
          .expectStatus().isOk();
    }
  }
}

If I put upper case in the path variable. it's working. If I put lower case, it's not working. It's inconsistent with the real/actual running. When I run the app, it can accept the lower case enum.

Version: - Spring Boot 3.3.7

Comment From: bclozel

Your issue description is missing SomethingController so this is not actionable right now.

Comment From: wilkinsona

I can't reproduce the behaviour that you have described. An upper-case value is required both in @WebFluxTest and when running the application's main method. This is what I would expect as lenient, case-insensitive conversion of enums is provided by Spring Boot's ApplicationConversionService which is separate from the WebConversionService that's used by Spring WebFlux (and Spring MVC).

Perhaps I have misunderstood the problem or perhaps you have some custom configuration in your application that's customising the web conversion service that isn't in effect when you're using @WebFluxTest? Either way, if you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.