*
* Since this test looks in a namespace that can be changed over time, the specific names of dependencies may need
* to be changed as the source code changes.
*/
public void testAppendDependencies() throws Exception {
DependencyDef testDependencyDef;
Set<DefDescriptor<?>> deps = new HashSet<>();
// Check for a couple dependencies present in a namespace
testDependencyDef = vendor.makeDependencyDef(vendor.makeComponentDefDescriptor("hi"), "aura", "INTERFACE",
vendor.makeLocation("f1", 5, 5, 0));
testDependencyDef.appendDependencies(deps);
assertTrue("Dependency not found", containsDependency(deps, "markup://aura:rootComponent"));
// Check dependency that exists but is wrong type
// TODO(W-1497192): can't find providers or helpers as dependencies
// testDependencyDef =
// vendor.makeDependencyDef(vendor.makeComponentDefDescriptor("hi"),
// "aura", "PROVIDER", vendor.makeLocation("f1", 5, 5, 0));
// deps.clear();
// testDependencyDef.appendDependencies(deps);
// Get dependency of specific component
testDependencyDef = vendor.makeDependencyDef(vendor.makeComponentDefDescriptor("hi"),
"markup://aura:application", "APPLICATION", vendor.makeLocation("f1", 5, 5, 0));
deps.clear();
testDependencyDef.appendDependencies(deps);
assertTrue("Failed to find dependency when searching using format <type>://<namespace>:<name>",
containsDependency(deps, "markup://aura:application"));
// Try to get dependency that doesn't exist, verify exception thrown
testDependencyDef = vendor.makeDependencyDef(vendor.makeComponentDefDescriptor("hi"),
"markup://aura:iDontExist", "APPLICATION", vendor.makeLocation("f1", 5, 5, 0));
deps.clear();
testDependencyDef.appendDependencies(deps);
try {
testDependencyDef.validateReferences();
fail("Exception not thrown when looking for dependency that does not exist");
} catch (Exception e) {
checkExceptionFull(e, InvalidDefinitionException.class,
"Invalid dependency markup://aura:iDontExist[APPLICATION]", "f1");
}
// Valid resource name but wrong type
testDependencyDef = vendor.makeDependencyDef(vendor.makeComponentDefDescriptor("hi"),
"markup://aura:application", "COMPONENT", vendor.makeLocation("f1", 5, 5, 0));
deps.clear();
testDependencyDef.appendDependencies(deps);
try {
testDependencyDef.validateReferences();
fail("Exception not thrown when dependency resource is valid but is of wrong type");
} catch (Exception e) {
checkExceptionFull(e, InvalidDefinitionException.class,
"Invalid dependency markup://aura:application[COMPONENT]", "f1");
}