private List<AlertCurrentEntity> getMockAlerts(String testType) {
    AlertCurrentEntity hostAlert = EasyMock.createStrictMock(AlertCurrentEntity.class);
    AlertCurrentEntity serviceAlert = EasyMock.createStrictMock(AlertCurrentEntity.class);
    AlertCurrentEntity componentAlert = EasyMock.createStrictMock(AlertCurrentEntity.class);

    AlertHistoryEntity hostHistory = EasyMock.createStrictMock(AlertHistoryEntity.class);
    AlertHistoryEntity serviceHistory = EasyMock.createStrictMock(AlertHistoryEntity.class);
    AlertHistoryEntity componentHistory = EasyMock.createStrictMock(AlertHistoryEntity.class);

    AlertDefinitionEntity alertDefinition = EasyMock.createStrictMock(AlertDefinitionEntity.class);

    EasyMock.expect(hostAlert.getAlertHistory()).andReturn(hostHistory).atLeastOnce();
    EasyMock.expect(serviceAlert.getAlertHistory()).andReturn(serviceHistory).atLeastOnce();
    EasyMock.expect(componentAlert.getAlertHistory()).andReturn(componentHistory).atLeastOnce();

    EasyMock.expect(hostHistory.getHostName()).andReturn(HOSTNAME).atLeastOnce();
    EasyMock.expect(hostHistory.getServiceName()).andReturn(null).atLeastOnce();
    EasyMock.expect(hostHistory.getComponentName()).andReturn(null).atLeastOnce();
    EasyMock.expect(hostHistory.getAlertDefinition()).andReturn(alertDefinition).atLeastOnce();
    EasyMock.expect(hostHistory.getAlertState()).andReturn(AlertState.OK).atLeastOnce();
    EasyMock.expect(hostHistory.getClusterId()).andReturn(CLUSTER_ID).atLeastOnce();

    EasyMock.expect(serviceHistory.getHostName()).andReturn(null).atLeastOnce();
    EasyMock.expect(serviceHistory.getServiceName()).andReturn(SERVICE).atLeastOnce();
    EasyMock.expect(serviceHistory.getComponentName()).andReturn(null).atLeastOnce();
    EasyMock.expect(serviceHistory.getAlertDefinition()).andReturn(alertDefinition).atLeastOnce();
    EasyMock.expect(serviceHistory.getAlertState()).andReturn(AlertState.OK).atLeastOnce();
    EasyMock.expect(serviceHistory.getClusterId()).andReturn(CLUSTER_ID).atLeastOnce();

    EasyMock.expect(alertDefinition.getDefinitionId()).andReturn(1L).atLeastOnce();
    EasyMock.expect(alertDefinition.getDefinitionName()).andReturn(DEFINITION_NAME).atLeastOnce();

    if (testType.equals("SCH")) {
      EasyMock.expect(componentHistory.getHostName()).andReturn(HOSTNAME).atLeastOnce();
      EasyMock.expect(componentHistory.getServiceName()).andReturn(SERVICE).atLeastOnce();
      EasyMock.expect(componentHistory.getComponentName()).andReturn(COMPONENT).atLeastOnce();
    } else {
      EasyMock.expect(componentHistory.getHostName()).andReturn(null).atLeastOnce();
      EasyMock.expect(componentHistory.getServiceName()).andReturn(null).atLeastOnce();
      EasyMock.expect(componentHistory.getComponentName()).andReturn(COMPONENT).atLeastOnce();
    }
    EasyMock.expect(componentHistory.getAlertDefinition()).andReturn(alertDefinition).atLeastOnce();
    EasyMock.expect(componentHistory.getAlertState()).andReturn(AlertState.OK).atLeastOnce();
    EasyMock.expect(componentHistory.getClusterId()).andReturn(CLUSTER_ID).atLeastOnce();

    List<AlertCurrentEntity> currentAlerts = new ArrayList<>();
    currentAlerts.add(hostAlert);
    currentAlerts.add(serviceAlert);
    currentAlerts.add(componentAlert);

    EasyMock.expect(m_alertsDAO.findCurrent()).andReturn(currentAlerts).atLeastOnce();

    EasyMock.replay(hostHistory, serviceHistory, componentHistory, alertDefinition);
    return currentAlerts;
  }
Tests that only the service alert has its maintenance mode changed.
ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/AlertMaintenanceModeListenerTest.java