public void testPath() { InstanceStack iStack = new InstanceStack(); iStack.setConfigAdapter(mci); assertEquals("InstanceStack constructor should set path to base", "/*[0]", iStack.getPath()); Instance<?> ti = new TestInstance(); iStack.pushInstance(ti, ti.getDescriptor()); // Set and clear attributes iStack.setAttributeName("attr1"); assertEquals( "Setting attribute name should append name to path", "/*[0]/attr1", iStack.getPath()); iStack.clearAttributeName("attr1"); assertEquals("Clearing attribute name should remove name from path", "/*[0]", iStack.getPath()); iStack.setAttributeName("body"); assertEquals( "Setting attribute name as body should append '*' to path", "/*[0]/*", iStack.getPath()); iStack.clearAttributeName("body"); assertEquals("/*[0]", iStack.getPath()); iStack.setAttributeName("realbody"); assertEquals( "Setting attribute name as realbody should append '+' to path", "/*[0]/+", iStack.getPath()); iStack.clearAttributeName("realbody"); assertEquals("/*[0]", iStack.getPath()); // Set and clear indexes iStack.setAttributeName("attr2"); iStack.setAttributeIndex(42); assertEquals("/*[0]/attr2[42]", iStack.getPath()); iStack.clearAttributeIndex(42); assertEquals("/*[0]/attr2", iStack.getPath()); }
public void testErrorClearIndexWithoutSettingIndex() { InstanceStack iStack = new InstanceStack(); iStack.setConfigAdapter(mci); TestInstance ti = new TestInstance(); iStack.pushInstance(ti, ti.getDescriptor()); iStack.setAttributeName("attribute"); try { iStack.clearAttributeIndex(1); fail("Expected error when clearing attribute index before setting an index"); } catch (Exception expected) { assertExceptionMessage( expected, AuraRuntimeException.class, "mismatched clearAttributeIndex"); } }