@Test
public void testCutOffHosts() throws AmbariException {

  MaintenanceStateHelper.HostPredicate predicate = createMock(MaintenanceStateHelper.HostPredicate.class);
  expect(predicate.shouldHostBeRemoved(eq("host1"))).andReturn(true);
  expect(predicate.shouldHostBeRemoved(eq("host2"))).andReturn(false);
  expect(predicate.shouldHostBeRemoved(eq("host3"))).andReturn(true);
  expect(predicate.shouldHostBeRemoved(eq("host4"))).andReturn(false);
  Set<String> candidates = new HashSet<String>();
  candidates.add("host1");
  candidates.add("host2");
  candidates.add("host3");
  candidates.add("host4");
  Injector injector = createStrictMock(Injector.class);
  MaintenanceStateHelper maintenanceStateHelper =
          createMockBuilder(MaintenanceStateHelper.class)
                  .withConstructor(injector)
                  .createNiceMock();
  replay(predicate, maintenanceStateHelper);
  Set<String> ignored = maintenanceStateHelper.filterHostsInMaintenanceState(candidates, predicate);
  verify(predicate, maintenanceStateHelper);
  Assert.assertEquals(candidates.size(), 2);
  Assert.assertTrue(candidates.contains("host2"));
  Assert.assertTrue(candidates.contains("host4"));
  Assert.assertEquals(ignored.size(), 2);
  Assert.assertTrue(ignored.contains("host1"));
  Assert.assertTrue(ignored.contains("host3"));
}