title: Unit test fails with this.id is null when using lombok @Getter and @Setter, but works when using @Data on the Entity class
body: <p>I am using lombok <code>@Getter</code> and <code>@Setter</code> annotations on my Entity class.</p>
  <pre class="lang-java prettyprint-override"><code>import lombok.Getter;
  import lombok.Setter;
  
  @Entity
  @Table(name = &quot;Achievements&quot;)
  @Getter
  @Setter
  @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = &quot;id&quot;)
  public class Achievement extends DomainObject {
  
    private static final long serialVersionUID = 1L;
  
    @Column(name = &quot;Name&quot;)
    private String name;
  
    @Column(name = &quot;Details&quot;)
    private String details;
  
    @ManyToOne
    @JoinColumn(name = &quot;AchievementTypeId&quot;, nullable = false)
    private AchievementType achievementType;
    
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = &quot;QuestId&quot;)
    private Quest quest;
  }
  </code></pre>
  <p>When I run the following unit test. it fails:</p>
  <pre class="lang-java prettyprint-override"><code>@Test
    public void saveAchievementTest() {
      Achievement achievement = new Achievement();
      achievement.setId(UUID.fromString(achievementId));
      AchievementRequestDTO achievementRequestDTO = new AchievementRequestDTO();
      achievementRequestDTO.setAchievementTypeId(UUID.fromString(achievementTypeId));
      achievement.setAchievementType(achievementType);
      when(achievementTypeRepository.getOne(achievementRequestDTO.getAchievementTypeId()))
          .thenReturn(achievementType);
      when(achievementRepository.save(achievement)).thenReturn(achievement);
      Achievement dbAchievement = achievementService.saveAchievement(achievementRequestDTO);
      assertEquals(dbAchievement.getId(), UUID.fromString(achievementId));
    }
  </code></pre>
  <p>The above run fails with a <code>NullPointerException</code> stating that <code>dbAchievement is null</code>. However, the same test case works when(in either of the two cases):</p>
  <ol>
  <li>I use <code>@Data</code> annotation instead of <code>@Getter</code> and <code>@Setter</code> in the entity class.</li>
  <li>I change the when statement in the test to <code>when(achievementRepository.save(any())).thenReturn(achievement);</code></li>
  </ol>
  <p>I suppose the issue here is the comparison of hashcodes to compare the object passed. I want to stick to using <code>@Getter and @Setter</code> in my entity. What should I do differently to achieve this?</p>