@Test
  public void testCompositeOperationThatEmitsNotifications() throws Exception {
    ListBackedNotificationHandler handler = new ListBackedNotificationHandler();
    getController()
        .getNotificationRegistry()
        .registerNotificationHandler(ANY_ADDRESS, handler, ALL);

    ModelNode operation = new ModelNode();
    operation.get(OP).set("composite");
    operation.get(OP_ADDR).setEmptyList();
    ModelNode op1 = createOperation(MY_OPERATION);
    op1.get("param").set("param1");
    ModelNode op2 = createOperation(MY_OPERATION);
    op2.get("param").set("param2");
    operation.get(ModelDescriptionConstants.STEPS).add(op1);
    operation.get(ModelDescriptionConstants.STEPS).add(op2);
    ModelNode result = executeForResult(operation);
    System.out.println("operation = " + operation);
    System.out.println("result = " + result);

    // the notifications are received in the order they were emitted
    assertEquals("the notification were not emitted", 2, handler.getNotifications().size());
    assertEquals("param1", handler.getNotifications().get(0).getMessage());
    assertEquals("param2", handler.getNotifications().get(1).getMessage());

    getController()
        .getNotificationRegistry()
        .unregisterNotificationHandler(ANY_ADDRESS, handler, ALL);
  }
  @Test
  public void testCompositeOperationWithSecondOperationFailing() throws Exception {
    ListBackedNotificationHandler handler = new ListBackedNotificationHandler();
    getController()
        .getNotificationRegistry()
        .registerNotificationHandler(ANY_ADDRESS, handler, ALL);

    ModelNode operation = new ModelNode();
    operation.get(OP).set("composite");
    operation.get(OP_ADDR).setEmptyList();
    ModelNode op1 = createOperation(MY_OPERATION);
    op1.get("param").set("param1");
    ModelNode op2 = createOperation(MY_OPERATION);
    op2.get("param").set("param2");
    op2.get(FAIL_OPERATION.getName()).set(true);
    operation.get(ModelDescriptionConstants.STEPS).add(op1);
    operation.get(ModelDescriptionConstants.STEPS).add(op2);

    executeForFailure(operation);

    assertTrue("the notification were emitted", handler.getNotifications().isEmpty());

    getController()
        .getNotificationRegistry()
        .unregisterNotificationHandler(ANY_ADDRESS, handler, ALL);
  }