@Test
public void testPersistReferenceObservations() {

    final Stack<EntityTransaction> transactionStack = new Stack<>();
    final EntityTransaction transaction = mock(EntityTransaction.class);
    final PersistenceManager persistenceManager = mock(PersistenceManager.class);
    final List<ReferenceObservation> observations = new ArrayList<>();
    observations.add(new ReferenceObservation());
    observations.add(new ReferenceObservation());
    when(persistenceManager.transaction()).thenReturn(transaction);
    MatchupGenerator.persistReferenceObservations(observations, persistenceManager, transactionStack);
    verify(persistenceManager, times(1)).transaction();
    verify(persistenceManager, times(2)).persist(any(ReferenceObservation.class));
    verify(persistenceManager, times(1)).commit();
    verifyNoMoreInteractions(persistenceManager);
    assertEquals(1, transactionStack.size());
    assertSame(transaction, transactionStack.pop());
}