@Test
  public void testAlertDefinitionEquality() {
    AlertDefinition ad1 = getAlertDefinition(SourceType.PORT);
    AlertDefinition ad2 = getAlertDefinition(SourceType.PORT);

    assertTrue(ad1.equals(ad2));
    assertTrue(ad1.deeplyEquals(ad2));

    // change 1 property and check that name equality still works
    ad2.setInterval(2);
    assertTrue(ad1.equals(ad2));
    assertFalse(ad1.deeplyEquals(ad2));

    // change the name and verify name equality is broken
    ad2.setName(getName() + " foo");
    assertFalse(ad1.equals(ad2));
    assertFalse(ad1.deeplyEquals(ad2));

    ad2 = getAlertDefinition(SourceType.AGGREGATE);
    assertFalse(ad1.deeplyEquals(ad2));

    ad2 = getAlertDefinition(SourceType.PORT);
    assertTrue(ad1.deeplyEquals(ad2));

    ad2.getSource().getReporting().getOk().setText("foo");
    assertFalse(ad1.deeplyEquals(ad2));
  }
Tests equality of {@link AlertDefinition} for hashing and merging purposes.
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionEqualityTest.java