public void addVariable(String variable) throws YarnException {
    if (immutableVariables.contains(variable)) {
      throw new YarnException("Variable '" + variable + "' is immutable " +
          "cannot add to the modified variable list.");
    }
    knownVariables.add(variable);
  }
@Test
  public void testDynamicQueueValidation() {
    //Setting up queue manager and emulated queue hierarchy
    CapacitySchedulerQueueManager qm =
        mock(CapacitySchedulerQueueManager.class);

    MockQueueHierarchyBuilder.create()
        .withQueueManager(qm)
        .withQueue("root.unmanaged")
        .withDynamicParentQueue("root.managed")
        .withQueue("root.unmanagedwithchild.child")
        .withQueue("root.leaf")
        .build();
    when(qm.getQueue(isNull())).thenReturn(null);

    MappingRuleValidationContextImpl ctx =
        new MappingRuleValidationContextImpl(qm);
    try {
      ctx.addVariable("%dynamic");
      ctx.addVariable("%user");
    } catch (YarnException e) {
      fail("We don't expect the add variable to fail: " + e.getMessage());
    }

    assertValidPath(ctx, "%dynamic");
    assertValidPath(ctx, "root.%dynamic");
    assertValidPath(ctx, "%user.%dynamic");
    assertValidPath(ctx, "root.managed.%dynamic");
    assertValidPath(ctx, "managed.%dynamic");
    assertValidPath(ctx, "managed.static");
    assertValidPath(ctx, "managed.static.%dynamic");
    assertValidPath(ctx, "managed.static.%dynamic.%dynamic");

    assertInvalidPath(ctx, "root.invalid.%dynamic");
    assertInvalidPath(ctx, "root.unmanaged.%dynamic");

    assertValidPath(ctx, "root.unmanagedwithchild.%user");
    assertValidPath(ctx, "unmanagedwithchild.%user");
  }