}
}
}
if (!isProduction) {
TestContextAdapter testContextAdapter = Aura.get(TestContextAdapter.class);
if (testContextAdapter != null) {
String testName = null;
// config takes precedence over param because the value is not expected to change during a test and it
// is less likely to have been modified unintentionally when from the config
if (configMap != null) {
testName = (String) configMap.get("test");
}
if (testName == null) {
testName = test.get(request);
}
if (testName != null) {
TestContext testContext = testContextAdapter.getTestContext(testName);
if (testContext != null) {
MasterDefRegistry registry = context.getDefRegistry();
Set<Definition> mocks = testContext.getLocalDefs();
if (mocks != null) {
boolean doReset = testReset.get(request);
for (Definition def : mocks) {
if (doReset && def instanceof Resettable) {
((Resettable) def).reset();
}
registry.addLocalDef(def);
}
}
}
} else {
testContextAdapter.clear();
}
}
}
return context;