private <T extends Definition> void checkAddRemove(DefDescriptor<?> tld, String suid,
AddableDef<T> toAdd) throws QuickFixException {
DefDescriptor<T> dd;
String uid, ouid;
Set<DefDescriptor<?>> deps;
AuraTestingUtil util = getAuraTestingUtil();
MasterDefRegistry mdr;
dd = DefDescriptorImpl.getInstance(toAdd.getFQN(tld.getNamespace(), tld.getName()),
toAdd.getDefClass());
util.addSourceAutoCleanup(dd, toAdd.getContent());
mdr = resetDefRegistry();
uid = mdr.getUid(null, tld);
assertFalse("UID should change on add for " + dd.getDefType() + "@" + dd, suid.equals(uid));
deps = mdr.getDependencies(uid);
assertTrue("dependencies should contain the newly created " + dd.getDefType() + "@" + dd,
deps.contains(dd));
ouid = uid;
util.removeSource(dd);
mdr = resetDefRegistry();
uid = mdr.getUid(null, tld);
assertNotSame("UID should change on removal for " + dd.getDefType() + "@" + dd, ouid, uid);
deps = mdr.getDependencies(uid);
assertFalse("dependencies should not contain the deleted " + dd, deps.contains(dd));