@Test
public void testComponentCommandOrder() throws Exception {

  CommandOrder co1 = new CommandOrder();
  co1.setCommand("A-START");
  co1.setRequires("B-STARTED");
  CommandOrder co2 = new CommandOrder();
  co2.setCommand("A-START");
  co2.setRequires("C-STARTED");
  CommandOrder co3 = new CommandOrder();
  co3.setCommand("B-START");
  co3.setRequires("C-STARTED,D-STARTED,E-INSTALLED");
  ComponentCommandOrder cco = new ComponentCommandOrder(
      Arrays.asList(co1, co2, co3), resources);
  ComponentInstanceState cisB = new ComponentInstanceState("B",
      containerId, "aid");
  ComponentInstanceState cisC = new ComponentInstanceState("C", containerId, "aid");
  ComponentInstanceState cisD = new ComponentInstanceState("D", containerId, "aid");
  ComponentInstanceState cisE = new ComponentInstanceState("E", containerId, "aid");
  ComponentInstanceState cisE2 = new ComponentInstanceState("E", containerId, "aid");
  cisB.setState(State.STARTED);
  cisC.setState(State.INSTALLED);
  Assert.assertTrue(cco.canExecute("A", Command.START, Arrays.asList(cisB)));
  Assert.assertFalse(cco.canExecute("A", Command.START, Arrays.asList(cisB, cisC)));
  cisC.setState(State.STARTING);
  Assert.assertFalse(cco.canExecute("A", Command.START, Arrays.asList(cisB, cisC)));
  cisC.setState(State.INSTALL_FAILED);
  Assert.assertFalse(cco.canExecute("A", Command.START, Arrays.asList(cisB, cisC)));
  cisD.setState(State.INSTALL_FAILED);
  cisE.setState(State.STARTED);
  Assert.assertTrue(cco.canExecute("E", Command.START, Arrays.asList(cisB, cisC, cisD, cisE)));
  Assert.assertTrue(cco.canExecute("B", Command.INSTALL, Arrays.asList(cisB, cisC, cisD, cisE)));
  Assert.assertFalse(cco.canExecute("B", Command.START, Arrays.asList(cisB, cisC, cisD, cisE)));
  cisD.setState(State.INSTALLING);
  Assert.assertFalse(cco.canExecute("B", Command.START, Arrays.asList(cisB, cisC, cisD, cisE)));
  cisC.setState(State.STARTED);
  cisD.setState(State.STARTED);
  Assert.assertTrue(cco.canExecute("B", Command.START, Arrays.asList(cisB, cisC, cisD, cisE)));
  cisE2.setState(State.INSTALLING);
  Assert.assertFalse(cco.canExecute("B", Command.START, Arrays.asList(cisE, cisE2)));
  cisE2.setState(State.INSTALLED);
  Assert.assertTrue(cco.canExecute("B", Command.START, Arrays.asList(cisE, cisE2)));
  cisE2.setState(State.STARTED);
  Assert.assertTrue(cco.canExecute("B", Command.START, Arrays.asList(cisE, cisE2)));
  cisE2.setState(State.STARTING);
  Assert.assertTrue(cco.canExecute("B", Command.START, Arrays.asList(cisE, cisE2)));
}