Search in sources :

Example 46 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class SpelValidatorTest method createJob.

private TaskFlowJob createJob() throws UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", "model1", "", "group1", false, false), "var2", new JobVariable("var2", "value2", "model2", "", "group1", false, true), "var3", new JobVariable("var3", "", "", "", "group2", false, false), "var4", new JobVariable("var4", null, null, "", "group2", false, false)));
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 47 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class GetJobContentGeneratorTest method testReplaceVars.

@Test
public void testReplaceVars() throws IOException {
    URL url = Resources.getResource("org/ow2/proactive/scheduler/common/job/factories/job_with_vars_and_info.xml");
    String jobContent = Resources.toString(url, Charsets.UTF_8);
    Map<String, JobVariable> vars = new HashMap<>();
    vars.put("var", new JobVariable("var", "myvalue"));
    final String newJobContent = generator.replaceVarsAndGenericInfo(jobContent, vars, Collections.emptyMap());
    assertTrue(newJobContent.contains("<variables>"));
    assertTrue(newJobContent.contains("myvalue"));
    assertFalse(newJobContent.contains("<genericInformation>"));
    assertNotEquals(jobContent, newJobContent);
}
Also used : HashMap(java.util.HashMap) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) URL(java.net.URL) Test(org.junit.Test)

Example 48 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionVariableXmlElement.

@Test
public void testJobCreationAttributeOrderDefinitionVariableXmlElement() throws URISyntaxException, JobCreationException {
    GlobalVariablesParser.setConfigurationPath(GlobalVariablesParserTest.class.getResource("/org/ow2/proactive/scheduler/common/job/factories/globalvariables/global_variables_default.xml").toExternalForm());
    GlobalVariablesParser.getInstance().reloadFilters();
    Job job = factory.createJob(jobDescriptorAttrDefVariableXmlElement);
    Map<String, JobVariable> jobVariables = job.getVariables();
    assertEquals(2, jobVariables.size());
    JobVariable jobVariable = jobVariables.get("name1");
    assertNotNull(jobVariable);
    assertEquals("name1", jobVariable.getName());
    assertEquals("value1", jobVariable.getValue());
    assertEquals("model1", jobVariable.getModel());
    jobVariable = jobVariables.get("name2");
    assertNotNull(jobVariable);
    assertEquals("name2", jobVariable.getName());
    assertEquals("value2", jobVariable.getValue());
    assertEquals("model2", jobVariable.getModel());
}
Also used : Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) GlobalVariablesParserTest(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesParserTest) Test(org.junit.Test)

Example 49 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable 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;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 50 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable 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;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Aggregations

JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)51 Test (org.junit.Test)19 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)17 HashMap (java.util.HashMap)15 LinkedHashMap (java.util.LinkedHashMap)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 JobId (org.ow2.proactive.scheduler.common.job.JobId)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)7 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)6 Task (org.ow2.proactive.scheduler.common.task.Task)6 TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)6 IOException (java.io.IOException)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)5 SimpleScript (org.ow2.proactive.scripting.SimpleScript)5 TaskScript (org.ow2.proactive.scripting.TaskScript)5 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)4 SimpleJob (functionaltests.jobs.SimpleJob)4 FileNotFoundException (java.io.FileNotFoundException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4