use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProviderTest method createJobWithTaskModelVariable.
private TaskFlowJob createJobWithTaskModelVariable(String value, String model) throws UserException {
TaskFlowJob job = new TaskFlowJob();
TaskVariable variable = new TaskVariable("VAR", value, model, false);
Task task = new ScriptTask();
task.setName("ModelTask");
task.setVariables(Collections.singletonMap(variable.getName(), variable));
job.addTask(task);
return job;
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelOKUpdateTaskVariable.
@Test
public void testSpelOKUpdateTaskVariable() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString'?(variables['var1'] = 'toto1') instanceof T(String) : false");
String value = "MyString";
ModelValidatorContext context = new ModelValidatorContext(createTask());
Assert.assertEquals(value, validator.validate(value, context));
Assert.assertEquals("toto1", context.getSpELVariables().getVariables().get("var1"));
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelOKUpdateJobVariableWhenEmptyOK.
@Test
public void testSpelOKUpdateJobVariableWhenEmptyOK() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString' ? (variables['var4'] == null ? (variables['var4'] = 'toto1') instanceof T(String) : true) : false");
String value = "MyString";
ModelValidatorContext context = new ModelValidatorContext(createJob());
Assert.assertEquals(value, validator.validate(value, context));
Assert.assertEquals("toto1", context.getSpELVariables().getVariables().get("var4"));
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelOKUpdateJobVariableWhenEmptyKO.
@Test
public void testSpelOKUpdateJobVariableWhenEmptyKO() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString' ? (variables['var2'] == null ? (variables['var2'] = 'toto1') instanceof T(String) : true) : false");
String value = "MyString";
ModelValidatorContext context = new ModelValidatorContext(createJob());
Assert.assertEquals(value, validator.validate(value, context));
Assert.assertEquals("value2", context.getSpELVariables().getVariables().get("var2"));
}
use of org.ow2.proactive.scheduler.common.exception.UserException in project scheduling by ow2-proactive.
the class TestDataspaceConcurrentTransfer method createJobWithFileTransfers.
public Job createJobWithFileTransfers() throws UserException, InvalidScriptException {
TaskFlowJob job = new TaskFlowJob();
job.setName(JOB_NAME);
job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
for (int i = 0; i < NB_TASKS; i++) {
ScriptTask st1 = new ScriptTask();
st1.setName(TASK_NAME_CREATE + i);
st1.setScript(new TaskScript(new SimpleScript("org.apache.commons.io.FileUtils.touch(new File(localspace, \"" + FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN + "\"));", "groovy")));
st1.addOutputFiles("**/*" + FILE_EXT_IN, OutputAccessMode.TransferToGlobalSpace);
job.addTask(st1);
ScriptTask st2 = new ScriptTask();
st2.setName(TASK_NAME_PROCESS + i);
st2.setScript(new TaskScript(new SimpleScript("org.apache.commons.io.FileUtils.copyFile(new File(localspace, \"" + FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN + "\"), new File(localspace, \"" + FOLDER_OUT_NAME + i + "/" + FILE_NAME + i + FILE_EXT_OUT + "\"));", "groovy")));
st2.addInputFiles(FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN, InputAccessMode.TransferFromGlobalSpace);
st2.addOutputFiles("**/*" + FILE_EXT_OUT, OutputAccessMode.TransferToGlobalSpace);
st2.addDependence(st1);
job.addTask(st2);
}
return job;
}
Aggregations