@Test
  public void testIncludesWithOverriddenSubsystems() throws Exception {
    try {
      // Here we test changing the includes attribute value
      // Testing what happens when adding subsystems at runtime becomes a bit too hard to mock up
      // so we test that in ServerManagementTestCase
      PathAddress addr = getProfileAddress("profile-four");
      ModelNode list = new ModelNode().add("profile-three");
      ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list);
      MockOperationContext operationContext =
          getOperationContextForSubsystemIncludes(
              addr,
              new RootResourceInitializer() {
                @Override
                public void addAdditionalResources(Resource root) {
                  Resource subsystemA = Resource.Factory.create();
                  root.getChild(PathElement.pathElement(PROFILE, "profile-three"))
                      .registerChild(PathElement.pathElement(SUBSYSTEM, "a"), subsystemA);

                  Resource subsystemB = Resource.Factory.create();
                  Resource profile4 =
                      root.getChild(PathElement.pathElement(PROFILE, "profile-four"));
                  profile4.registerChild(PathElement.pathElement(SUBSYSTEM, "a"), subsystemB);
                }
              });
      ProfileResourceDefinition.createIncludesValidationHandler().execute(operationContext, op);
      operationContext.executeNextStep();
      Assert.fail("Expected error");
    } catch (OperationFailedException expected) {
      Assert.assertTrue(expected.getMessage().contains("164"));
      Assert.assertTrue(expected.getMessage().contains("'profile-four'"));
      Assert.assertTrue(expected.getMessage().contains("'a'"));
      Assert.assertTrue(expected.getMessage().contains("'profile-three'"));
    }
  }
 /** Resolve expressions in the given model (if there are any) */
 private ModelNode resolveExpressions(final ModelNode unresolved) {
   if (unresolved == null) {
     return null;
   }
   try {
     return expressionResolver.resolveExpressions(unresolved.clone());
   } catch (OperationFailedException e) {
     // Fail
     throw new IllegalStateException(e.getMessage(), e);
   }
 }
 public OperationFailedRuntimeException(OperationFailedException e) {
   super(e.getMessage());
 }