@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'"));
    }
  }
 @Test
 public void testGoodProfileIncludesWrite() throws Exception {
   PathAddress addr = getProfileAddress("profile-one");
   ModelNode list = new ModelNode().add("profile-two");
   ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list);
   MockOperationContext operationContext = getOperationContext(addr);
   ProfileResourceDefinition.createIncludesValidationHandler().execute(operationContext, op);
   operationContext.executeNextStep();
 }
 @Test
 public void testBadProfileIncludesAdd() throws Exception {
   PathAddress addr = getProfileAddress("test");
   ModelNode op = Util.createAddOperation(addr);
   op.get(INCLUDES).add("profile-one").add("NOT_THERE");
   MockOperationContext operationContext = getOperationContext(addr);
   ProfileAddHandler.INSTANCE.execute(operationContext, op);
   operationContext.executeNextStep();
 }
 @Test(expected = OperationFailedException.class)
 public void testCyclicProfileIncludesWrite() throws Exception {
   PathAddress addr = getProfileAddress("profile-three");
   ModelNode list = new ModelNode().add("profile-four");
   ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list);
   MockOperationContext operationContext = getOperationContextWithIncludes(addr);
   ProfileResourceDefinition.createIncludesValidationHandler().execute(operationContext, op);
   operationContext.executeNextStep();
 }