use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class TestPropagatedVariables method createTaskFlowJob.
private TaskFlowJob createTaskFlowJob() throws UserException {
TaskFlowJob flowJob = new TaskFlowJob();
JavaTask taskA = new JavaTask();
taskA.setName("Task_A");
HashMap<String, String> setA = new HashMap<>();
setA.put("Task_A_Var", "Task_A_Val");
taskA.addArgument("set", setA);
taskA.setExecutableClassName(PropagateVariablesExec.class.getName());
flowJob.addTask(taskA);
JavaTask taskB = new JavaTask();
taskB.setName("Task_B");
HashMap<String, String> setB = new HashMap<>();
setB.put("Task_B_Var", "Task_B_Val");
taskB.addArgument("set", setB);
taskB.setExecutableClassName(PropagateVariablesExec.class.getName());
flowJob.addTask(taskB);
JavaTask taskC = new JavaTask();
taskC.setName("Task_C");
taskC.addDependence(taskA);
taskC.addDependence(taskB);
HashMap<String, String> checkC = new HashMap<>();
checkC.put("Task_A_Var", "Task_A_Val");
checkC.put("Task_B_Var", "Task_B_Val");
taskC.addArgument("check", checkC);
taskC.setExecutableClassName(PropagateVariablesExec.class.getName());
flowJob.addTask(taskC);
if (OperatingSystem.unix == OperatingSystem.getOperatingSystem()) {
NativeTask taskD = new NativeTask();
taskD.setName("TaskD");
taskD.setCommandLine("/bin/bash", "-c", "echo $variables_Task_A_Var; test \"$variables_Task_A_Var\" == \"Task_A_Val\"");
taskD.addDependence(taskC);
flowJob.addTask(taskD);
}
return flowJob;
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method checkIfOnTaskErrorIsInJobAndTaskInXML.
private void checkIfOnTaskErrorIsInJobAndTaskInXML(OnTaskError jobOnTaskErrorSetting, OnTaskError taskOnTaskErrorSetting) throws UserException, TransformerException, ParserConfigurationException, IOException {
String taskName = "taskName";
TaskFlowJob jobWithCancelJobOnErrorTrue = new TaskFlowJob();
jobWithCancelJobOnErrorTrue.setOnTaskError(jobOnTaskErrorSetting);
JavaTask task = new JavaTask();
task.setName(taskName);
task.setExecutableClassName("oo.Bar");
task.setOnTaskError(taskOnTaskErrorSetting);
jobWithCancelJobOnErrorTrue.addTask(task);
// Check that onTaskError is inside the <job [here] > xml tag
assertThat("XML must contain onTaskError=\\\"" + jobOnTaskErrorSetting.toString() + "\\\"", new Job2XMLTransformer().jobToxmlString(jobWithCancelJobOnErrorTrue), org.hamcrest.Matchers.matchesPattern(matchEvery + matchJobTagOpening + notMatchSmallerSign + matchOnTaskErrorEquals(jobOnTaskErrorSetting) + matchEvery + matchSmallerSign + matchEvery));
// Check that onTaskError is inside the <task [here] > xml tag
assertThat("XML must contain onTaskError=\\\"" + taskOnTaskErrorSetting.toString() + "\\\"", new Job2XMLTransformer().jobToxmlString(jobWithCancelJobOnErrorTrue), org.hamcrest.Matchers.matchesPattern(matchEvery + matchTaskTagOpening + notMatchSmallerSign + matchOnTaskErrorEquals(taskOnTaskErrorSetting) + matchEvery + matchSmallerSign + matchEvery));
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProviderTest method createJobWithJobModelVariable.
private TaskFlowJob createJobWithJobModelVariable(String value, String model) throws UserException {
TaskFlowJob job = new TaskFlowJob();
JobVariable jobVariable = new JobVariable("VAR", value, model);
job.setVariables(Collections.singletonMap(jobVariable.getName(), jobVariable));
return job;
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProviderTest method createJobWithSpelJobModelVariablesKO.
private TaskFlowJob createJobWithSpelJobModelVariablesKO() throws UserException {
TaskFlowJob job = new TaskFlowJob();
job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", SPEL_LEFT + "#value == 'value1' ? (variables['var2'] == '' ? (variables['var2'] = 'toto1') instanceof T(String) : true) : false" + SPEL_RIGHT), "var2", new JobVariable("var2", "", SPEL_LEFT + "#value == 'toto2'" + SPEL_RIGHT)));
return job;
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProviderTest method createJobWithSpelJobModelVariablesOK.
private TaskFlowJob createJobWithSpelJobModelVariablesOK() throws UserException {
TaskFlowJob job = new TaskFlowJob();
job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", SPEL_LEFT + "#value == 'value1' ? (variables['var2'] == '' ? (variables['var2'] = 'toto1') instanceof T(String) : true) : false" + SPEL_RIGHT), "var2", new JobVariable("var2", "", SPEL_LEFT + "#value == 'toto1'" + SPEL_RIGHT)));
return job;
}
Aggregations