@Test
  public void testConcurrentGroupModification() throws Exception {
    createDefinitions();

    AlertGroupEntity group = m_helper.createAlertGroup(m_cluster.getClusterId(), null);
    final Set<AlertTargetEntity> targets = createTargets(100);

    group.setAlertTargets(targets);
    group = m_dao.merge(group);

    final class AlertGroupWriterThread extends Thread {
      private AlertGroupEntity group;

      /**
       * {@inheritDoc}
       */
      @Override
      public void run() {
        for (int i = 0; i < 1000; i++) {
          group.setAlertTargets(new HashSet<>(targets));
        }
      }
    }

    List<Thread> threads = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
      AlertGroupWriterThread thread = new AlertGroupWriterThread();
      threads.add(thread);

      thread.group = group;
      thread.start();
    }

    for (Thread thread : threads) {
      thread.join();
    }
  }
Tests that updating JPA associations concurrently doesn't lead to Concu

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java