title: AssertionError when testing LocalDate with MockMvc and JUnit 5
body: <p>I am trying to use JUnit 5 with Hibernate 5.4 and MockMvc in a Spring Boot 2.3 project.</p>
  <p>This is how the members of my <code>employee</code> entity class looks like:</p>
  <pre><code>import java.time.LocalDate;
  ... (Rest of the imports)
  
  @Entity
  public class Employee {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long employeeId;
  
      @Column(nullable = false, updatable = true)
      private String firstName;
  
      @Column(nullable = true, updatable = true)
      private String lastName;
  
      @Column(nullable = false, updatable = true)
      private String email;
  
      @Column(nullable = false, updatable = true)
      private LocalDate birthDate;
  </code></pre>
  <p>I am trying to test the LocalDate field birthDate with Mockito and MockMvc using JUnit 5. This is how the test case for that looks like:</p>
  <pre><code>    @Test
      public void testFindEmployeeById() throws Exception {
          Employee mockedEmployee = makeEmployee(9L, &quot;Mock First&quot;, &quot;Mock Last&quot;, &quot;mock@email.com&quot;,
                  LocalDate.of(1996, 9, 8), 9L, &quot;Mock Project&quot;, &quot;Mock Department&quot;);
  
          Mockito.when(employeeRepositoryMock.findById(mockedEmployee.getEmployeeId()))
                  .thenReturn(Optional.of(mockedEmployee));
  
          mockMvc.perform(MockMvcRequestBuilders.get(&quot;/v1/employees/id/9&quot;).accept(MediaType.APPLICATION_JSON))
                  .andDo(MockMvcRestDocumentation.document(&quot;employeeById&quot;,
                          Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
                          PayloadDocumentation.responseFields(
                                  PayloadDocumentation.fieldWithPath(&quot;employeeId&quot;).description(&quot;Employee ID&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;firstName&quot;).description(&quot;First Name&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;lastName&quot;).description(&quot;Last Name&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;email&quot;).description(&quot;Email Address&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;birthDate&quot;).description(&quot;Date of Birth&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;project.projectId&quot;).description(&quot;Project ID&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;project.name&quot;).description(&quot;Project name&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;project.department.departmentId&quot;)
                                          .description(&quot;Department ID&quot;),
                                  PayloadDocumentation.fieldWithPath(&quot;project.department.name&quot;)
                                          .description(&quot;Department Name&quot;))))
                  .andDo(print()).andExpect(MockMvcResultMatchers.status().isOk())
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.employeeId&quot;).value(mockedEmployee.getEmployeeId()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.firstName&quot;).value(mockedEmployee.getFirstName()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.lastName&quot;).value(mockedEmployee.getLastName()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.email&quot;).value(mockedEmployee.getEmail()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.birthDate&quot;).value(mockedEmployee.getBirthDate()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.project.projectId&quot;)
                          .value(mockedEmployee.getProject().getProjectId()))
                  .andExpect(
                          MockMvcResultMatchers.jsonPath(&quot;$.project.name&quot;).value(mockedEmployee.getProject().getName()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.project.department.departmentId&quot;)
                          .value(mockedEmployee.getProject().getDepartment().getDepartmentId()))
                  .andExpect(MockMvcResultMatchers.jsonPath(&quot;$.project.department.name&quot;)
                          .value(mockedEmployee.getProject().getDepartment().getName()));
      }
  </code></pre>
  <p>Upon running the test case, I get an AssertionError:</p>
  <pre><code>java.lang.AssertionError: JSON path &quot;$.birthDate&quot; expected:&lt;1996-09-08&gt; but was:&lt;1996-09-08&gt;
  </code></pre>
  <p>As you can tell, both the string representations are the same. Yet JUnit 5 throws the error.</p>
  <p>So, what is the right way to go about comparing LocalDate with JUnit 5?</p>
  <p>A similar question can be found here: <a href="https://stackoverflow.com/questions/61184154/comparing-localdate-using-hamcrest-in-junit-test-case">Comparing LocalDate using Hamcrest in Junit Test Case</a>
  and here: <a href="https://stackoverflow.com/questions/45592405/junit-assertionerror-when-testing-simpledateformat">JUnit AssertionError when testing SimpledateFormat</a></p>
  <p>Thanks in advance. :)</p>