use of com.centurylink.mdw.dataaccess.file.AssetFile in project mdw-designer by CenturyLinkCloud.
the class GroovyTestCaseRun method getAsset.
TestCaseAsset getAsset(String path) throws TestException {
try {
int lastSlash = path.lastIndexOf('/');
String name = path;
String pkg = null;
if (lastSlash >= 0) {
pkg = path.substring(0, lastSlash);
name = name.substring(lastSlash + 1);
}
if (pkg == null && testcase.isLegacy())
throw new TestException("Asset path must be fully-qualified for legacy tests");
if (testcase.isLegacy() || !testCaseAsset.isVcs()) {
int lastDot = name.lastIndexOf('.');
if (lastDot < 0)
throw new TestException("Asset format must be inferable from extension: " + name);
String language = RuleSetVO.getLanguage(name.substring(lastDot));
RuleSetVO ruleSet = dao.getRuleSet(name, language, 0);
if (ruleSet == null) {
// placeholder
ruleSet = new RuleSetVO();
ruleSet.setName(name);
}
ruleSet.setPackageName(pkg == null ? testCaseAsset.getPackageName() : pkg);
return new TestCaseAsset(ruleSet);
} else {
// VCS
PackageDir pkgDir = testCaseAsset.getPackageDir();
if (pkg != null && !pkg.equals(pkgDir.getPackageName()))
pkgDir = new PackageDir(dao.getVcsBase(), new File(dao.getVcsBase() + "/" + pkg.replace('.', '/')), dao.getVersionControl());
if (!pkgDir.exists())
return null;
AssetFile assetFile = pkgDir.getAssetFile(new File(pkgDir + "/" + name));
return new TestCaseAsset(pkgDir, assetFile);
}
} catch (Exception ex) {
throw new TestException("Cannot load " + path, ex);
}
}
Aggregations