use of org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelOK.
@Test
public void testSpelOK() throws ValidationException {
SpelValidator validator = new SpelValidator("#value == 'MyString'");
String value = "MyString";
Assert.assertEquals(value, validator.validate(value, new ModelValidatorContext(new StandardEvaluationContext())));
}
use of org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelOKUpdateJobVariable.
@Test
public void testSpelOKUpdateJobVariable() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString'?(variables['var1'] = 'toto1') instanceof T(String):false");
String value = "MyString";
ModelValidatorContext context = new ModelValidatorContext(createJob());
Assert.assertEquals(value, validator.validate(value, context));
Assert.assertEquals("toto1", context.getSpELVariables().getVariables().get("var1"));
}
use of org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelKOUpdateTaskVariable.
@Test
public void testSpelKOUpdateTaskVariable() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString'?(variables['var1'] = 'toto1') instanceof T(String) : false");
String value = "MyString123";
ModelValidatorContext context = new ModelValidatorContext(createTask());
try {
validator.validate(value, context);
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof ValidationException);
}
Assert.assertEquals("value1", context.getSpELVariables().getVariables().get("var1"));
}
use of org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException in project scheduling by ow2-proactive.
the class SpelValidatorTest method testSpelKOUpdateJobVariable.
@Test
public void testSpelKOUpdateJobVariable() throws ValidationException, UserException {
SpelValidator validator = new SpelValidator("#value == 'MyString'?(variables['var1'] = 'toto1') instanceof T(String):false");
String value = "MyString123";
ModelValidatorContext context = new ModelValidatorContext(createJob());
try {
validator.validate(value, context);
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof ValidationException);
}
Assert.assertEquals("value1", context.getSpELVariables().getVariables().get("var1"));
}
Aggregations