use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.
the class UsersManager method modifyUsers.
public void modifyUsers(List<XmlUser> originalUsers, List<XmlUser> newUsers) throws JAXBException, IOException, ClearThException {
synchronized (usersListMonitor) {
loadUsersList();
for (int i = 0; i < newUsers.size(); i++) doModifyUser(originalUsers.get(i), newUsers.get(i));
try {
saveUsersList();
} catch (Exception e) {
String msg = "Error while saving users list after modifying it";
logger.error(msg, e);
throw new IOException(msg, e);
}
loadUsersList();
}
}
use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.
the class MvelExpressionValidator method validateExpression.
public void validateExpression(Serializable expression) throws ClearThException {
ASTNode node = null;
if (expression instanceof CompiledExpression) {
CompiledExpression castedExpression = (CompiledExpression) expression;
node = castedExpression.getFirstNode();
} else if (expression instanceof ExecutableAccessor) {
ExecutableAccessor castedExpression = (ExecutableAccessor) expression;
node = castedExpression.getNode();
}
if (node != null && node.nextASTNode != null) {
int operator = node.nextASTNode.getOperator();
if (operator == Operator.TERNARY) {
return;
}
throw new ClearThException("Invalid expression: '" + String.valueOf(node.getExpr()) + "'. Possibly it was" + " received from another reference.");
}
}
use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.
the class ConfigMakerTool method makeConfig.
public File makeConfig(File matrixFile, File destDir, String resultConfigName) throws IOException, ClearThException {
if (matrixFile == null || !matrixFile.exists())
throw new ClearThException("Matrix file does not exist!");
if (!checkMatrixFileExtension(matrixFile.getName()))
throw new ClearThException("Unsupported matrix file format");
String[] configHeader;
List<Scheduler> schedulers = ClearThCore.getInstance().getSchedulersManager().getCommonSchedulers();
StepFactory stepFactory;
if (schedulers != null && !schedulers.isEmpty()) {
Scheduler sch = schedulers.get(0);
configHeader = sch.getSchedulerData().getConfigHeader();
stepFactory = sch.getStepFactory();
} else {
configHeader = DefaultSchedulerData.CONFIG_HEADER;
stepFactory = null;
}
List<String> stepsNames = null;
stepsNames = readMatrixFile(matrixFile);
if (stepsNames == null || stepsNames.isEmpty())
throw new ClearThException("No steps references found in uploaded file " + resultConfigName + ". Please make sure that you upload a script file with right extension");
List<Step> steps = new ArrayList<Step>();
for (String stepName : stepsNames) {
steps.add(createStep(stepName, stepFactory));
}
File configFile = File.createTempFile(resultConfigName + "_config_", ".cfg", destDir);
SchedulerData.saveSteps(configFile, configHeader, steps);
return configFile;
}
use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.
the class TestingExecutor method loadMatrices.
public void loadMatrices(Scheduler scheduler, File matricesDir) throws ClearThException {
List<File> matrixFiles;
try {
matrixFiles = getMatricesFiles(matricesDir.toPath());
} catch (IOException e) {
throw new ClearThException("Error on matrix files getting", e);
}
matrixFiles.forEach(scheduler::addMatrix);
}
use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.
the class SchedulerTest method executeTest.
@Test
public void executeTest() throws ClearThException, AutomationException {
Scheduler scheduler = clearThManager.getScheduler(schedulerName, userName);
List<String> warnings = loadStepsForExecuteTest(scheduler);
if (!warnings.isEmpty())
throw new AutomationException("Steps loading errors:" + warnings);
loadMatricesForExecuteTest(scheduler);
scheduler.start(userName);
waitForSchedulerToStop(scheduler, 100, 10000);
List<XmlSchedulerLaunchInfo> launchesInfo = scheduler.getSchedulerData().getLaunches().getLaunchesInfo();
if (launchesInfo == null || launchesInfo.isEmpty())
throw new ClearThException("Launches data is not found");
XmlSchedulerLaunchInfo currentLaunch = launchesInfo.get(0);
allSuccessVerify(currentLaunch, scheduler.getExecutedMatricesPath());
verifyStepsStatuses(scheduler.getSteps());
checkReports(currentLaunch.getReportsPath());
}
Aggregations