コード例 #1
0
  @Test
  public void savesRegistration() {

    OrchestraRegistration registration = new OrchestraRegistration();
    beanUnderTest.createRegistration(registration);

    verify(mockedEntityManager).merge(registration);
    verifyNoMoreInteractions(mockedEntityManager);
  }
コード例 #2
0
  @Test
  public void returnsAllRegistrations() {
    final OrchestraRegistration expected = new OrchestraRegistration();

    TypedQuery<OrchestraRegistration> mockQuery =
        getQueryThatReturnsList(Collections.singletonList(expected));
    when(mockedEntityManager.createQuery(anyString(), eq(OrchestraRegistration.class)))
        .thenReturn(mockQuery);

    List<OrchestraRegistration> actualRegistrations = beanUnderTest.getRegistrations();

    assertNotNull(
        actualRegistrations, "OrchestraRegistrationHandlerBean.getRegistrations returned null.");
    assertEquals(actualRegistrations.size(), 1, "Wrong number of registrations");

    OrchestraRegistration actual = actualRegistrations.get(0);
    assertEquals(actual, expected, "Wrong registration returned");
  }
コード例 #3
0
 @BeforeMethod
 public void setUp() throws Exception {
   beanUnderTest = new OrchestraRegistrationHandlerBean();
   mockedEntityManager = mock(EntityManager.class);
   beanUnderTest.setEntityManager(mockedEntityManager);
 }