Exemple #1
0
 public void testMarkParentMultipleTimes() {
   InstanceStack iStack = new InstanceStack();
   iStack.setConfigAdapter(mci);
   assertEquals("InstanceStack constructor should set path to base", "/*[0]", iStack.getPath());
   TestInstance parent = new TestInstance("parent");
   iStack.markParent(parent);
   assertEquals("Marking parent should set path to the parent's path", "parent", iStack.getPath());
   iStack.markParent(parent);
   assertEquals("Marking additional parent should not update path", "parent", iStack.getPath());
   iStack.clearParent(parent);
   assertEquals("parent", iStack.getPath());
   iStack.clearParent(parent);
   assertEquals(
       "Clearing both parents should reset path to original base path", "/*[0]", iStack.getPath());
 }
Exemple #2
0
 public void testMarkParentNoCurrentInstance() {
   InstanceStack iStack = new InstanceStack();
   iStack.setConfigAdapter(mci);
   assertEquals("InstanceStack constructor should set path to base", "/*[0]", iStack.getPath());
   TestInstance parent = new TestInstance("parentBase");
   iStack.markParent(parent);
   assertEquals(
       "Marking parent should set path to the parent's path", "parentBase", iStack.getPath());
   iStack.clearParent(parent);
   assertEquals(
       "Clearing parent should reset path to original base path", "/*[0]", iStack.getPath());
 }
Exemple #3
0
  public void testErrorWrongParent() {
    // Mark a new parent without clearing the first
    InstanceStack iStack = new InstanceStack();
    iStack.setConfigAdapter(mci);
    iStack.markParent(new TestInstance("parent"));
    try {
      iStack.markParent(new TestInstance("different parent"));
      fail("Expected error when marking parent that's different than the current instance");
    } catch (Exception expected) {
      assertExceptionMessage(
          expected, AuraRuntimeException.class, "Don't know how to handle setAttribute here");
    }

    // Clear an instance that hasn't been marked as a parent
    iStack = new InstanceStack();
    iStack.setConfigAdapter(mci);
    iStack.markParent(new TestInstance("parent"));
    try {
      iStack.clearParent(new TestInstance("different parent"));
      fail("Expected error when clearing parent that's different than the current instance");
    } catch (Exception expected) {
      assertExceptionMessage(expected, AuraRuntimeException.class, "mismatched clear parent");
    }
  }