@Test
  public void testExistingAnnouncement() {

    Long jobAnnouncementId = 1L;
    JobAnnouncement jobAnnouncement = new JobAnnouncement();
    jobAnnouncement.setId(jobAnnouncementId);

    when((jobAnnouncementService.findOrNew((BusinessProcess) any()))).thenReturn(jobAnnouncement);

    // A first call will deliver an object from the database. The businessProcess will have
    // been consulted whether the object already exists. The entityManager will have delivered the
    // object

    jobAnnouncement = jobAnnouncementBean.getJobAnnouncement();

    verify(jobAnnouncementService).findOrNew((BusinessProcess) any());

    assertThat(jobAnnouncement).isNotNull();
    assertThat(jobAnnouncement.getId()).isEqualTo(jobAnnouncementId);

    // A second call will deliver the same object.

    JobAnnouncement jobAnnouncement2 = jobAnnouncementBean.getJobAnnouncement();
    assertThat(jobAnnouncement2).isEqualTo(jobAnnouncement);

    verifyNoMoreInteractions(businessProcess);
  }
  @Test
  public void testNewAnnouncement() {

    JobAnnouncement jobAnnouncement = new JobAnnouncement();

    when((jobAnnouncementService.findOrNew((BusinessProcess) any()))).thenReturn(jobAnnouncement);

    // A first call will deliver a fresh object. The businessProcess will have been consulted
    // whether the object already exists.

    jobAnnouncement = jobAnnouncementBean.getJobAnnouncement();

    verify(jobAnnouncementService).findOrNew((BusinessProcess) any());
    assertThat(jobAnnouncement).isNotNull();
    assertThat(jobAnnouncement.getId()).isNull();

    // A second call will deliver the same object.
    JobAnnouncement jobAnnouncement2 = jobAnnouncementBean.getJobAnnouncement();

    verifyNoMoreInteractions(businessProcess);

    assertThat(jobAnnouncement2).isEqualTo(jobAnnouncement);
  }