@Test
  public void testHostOperationsAllowance() throws Exception {
    Injector injector = createStrictMock(Injector.class);
    MaintenanceStateHelper maintenanceStateHelper =
            createMockBuilder(MaintenanceStateHelper.class)
                    .withConstructor(injector)
                    .createNiceMock();

    Host host = createMock(Host.class);

    // only called for Cluster level
    expect(host.getMaintenanceState(anyInt())).andReturn(MaintenanceState.ON);
    expect(host.getMaintenanceState(anyInt())).andReturn(MaintenanceState.OFF);

    replay(maintenanceStateHelper, host);


    Assert.assertEquals(false, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Cluster));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Service));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Host));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.HostComponent));

    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Cluster));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Service));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.Host));
    Assert.assertEquals(true, maintenanceStateHelper.isOperationAllowed(host, 1, Resource.Type.HostComponent));

    verify(maintenanceStateHelper, host);
  }
Tests that the service MM state is calculated correctly for an alert.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java