Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle upgrade of hibernate-validator from 6.1.7.Final to 7.0.1.Final #1286

Open
3 tasks
nya-elimu opened this issue May 24, 2021 · 3 comments
Open
3 tasks
Labels
bug Something isn't working dependencies Pull requests that update a dependency file help wanted Extra attention is needed

Comments

@nya-elimu
Copy link
Member

nya-elimu commented May 24, 2021

This version of the hibernate-validator will result in validation to stop working, so we need to handle this before bumping the version.

See https://hibernate.org/validator/documentation/migration-guide/


Relates to #1211

@nya-elimu nya-elimu added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed dependencies Pull requests that update a dependency file labels May 24, 2021
@macdude357
Copy link

@nya-elimuai I upgraded the version locally but don't see any test errors. Is there a test that should fail to demonstrate the issue with upgrading?

@nya-elimu
Copy link
Member Author

@nya-elimuai I upgraded the version locally but don't see any test errors. Is there a test that should fail to demonstrate the issue with upgrading?

@macdude357 Apologies for lack of details in this issue. So let me help you out with a little information 🙂

One way to test this error is to launch the webapp, go to http://localhost:8080/webapp/content/word/list, and then adding a new Word without including any of the compulsory fields (those marked with @NotEmpty or @NotNull).

Here is how to reproduce:

  1. Submit the "Create Word" form without willing any of the details:

    Screen Shot 2021-05-25 at 7 29 52 AM
  2. The Word will still be stored in the database, and will erroneously appear in the list of Words:

    Screen Shot 2021-05-25 at 7 30 10 AM

And your point about unit tests not failing is a good one. Actually, we should add a couple of unit tests to cover this specific issue. By for example trying to store a Word in the database without first populating the required properties, and then use something like @Test(expected=ConstraintViolationException.class).

CC @UmenR

@nya-elimu
Copy link
Member Author

nya-elimu commented Jul 22, 2022

As a related topic, also note that Hibernate validation is currently not working in our MockMvc unit tests: https://github.com/elimu-ai/webapp/blob/main/src/test/java/ai/elimu/web/content/word/WordCreateControllerTest.java#L53

@Test
    public void testHandleSubmit_emptyText() throws Exception {
        RequestBuilder requestBuilder = MockMvcRequestBuilders
                .post("/content/word/create")
                .param("timeStart", String.valueOf(System.currentTimeMillis()))
                .param("text", "")
                .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
//        MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn();
//        assertEquals(HttpStatus.BAD_REQUEST.value(), mvcResult.getResponse().getStatus());
//        assertEquals("content/word/create", mvcResult.getModelAndView().getViewName());
    }

More info here: https://stackoverflow.com/questions/24049480/spring-mockmvc-doesnt-consider-validation-in-my-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants