DependencyValidator { void append(@Nullable DependencyValidator childDependencyValidator) { if (childDependencyValidator == null) { return; } if (!childDependencyValidator.mKey.equals(mKey)) { throw new RuntimeException( String.format( "DependencyValidator append mismatch, tried to append %s to %s", childDependencyValidator.mKey, mKey)); } for (DependencyValidator otherChildValidator : childDependencyValidator.mChildren) { otherChildValidator.addParent(this); } } DependencyValidator(DependencyKey key);   }
@Test public void testWorkingAppend() { createValidatorToAppendTo().append(createBaseValidator()); }
@Test(expected = CircularDependencyError.class) public void testFailedAppend() { createBadValidatorToAppendTo().append(createBaseValidator()); }