@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);
}