Search in sources :

Example 6 with JobValidationData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData in project scheduling by ow2-proactive.

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenValidatingUsingANullWorkflowUrlThenValidationContainsException.

@Test
public void testWhenValidatingUsingANullWorkflowUrlThenValidationContainsException() throws Exception {
    String workflowUrl = null;
    JobValidationData response = schedulerRest.validateFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
    checkInvalidResponse(response);
}
Also used : JobValidationData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData) Test(org.junit.Test)

Example 7 with JobValidationData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData in project scheduling by ow2-proactive.

the class ValidationUtil method validateJob.

public JobValidationData validateJob(String jobFilePath, Map<String, String> jobVariables) {
    JobValidationData data = new JobValidationData();
    try {
        JobFactory factory = JobFactory.getFactory();
        Job job = factory.createJob(jobFilePath, jobVariables);
        if (job instanceof TaskFlowJob) {
            validateJob((TaskFlowJob) job, data);
            fillUpdatedVariables((TaskFlowJob) job, data);
        } else {
            data.setValid(true);
        }
    } catch (JobCreationException e) {
        data.setTaskName(e.getTaskName());
        data.setErrorMessage(e.getMessage());
        data.setStackTrace(getStackTrace(e));
    }
    return data;
}
Also used : JobFactory(org.ow2.proactive.scheduler.common.job.factories.JobFactory) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobValidationData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData) Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Example 8 with JobValidationData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData in project scheduling by ow2-proactive.

the class ValidationUtil method validateJob.

private void validateJob(TaskFlowJob job, JobValidationData data) {
    ArrayList<Task> tasks = job.getTasks();
    if (tasks.isEmpty()) {
        data.setErrorMessage(String.format("%s must contain at least one task.", job.getName()));
        return;
    }
    FlowError error = FlowChecker.validate(job);
    if (error != null) {
        data.setTaskName(error.getTask());
        data.setErrorMessage(error.getMessage());
        return;
    }
    data.setValid(true);
}
Also used : FlowError(org.ow2.proactive.scheduler.common.job.factories.FlowError) Task(org.ow2.proactive.scheduler.common.task.Task)

Example 9 with JobValidationData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData in project scheduling by ow2-proactive.

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenValidatingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed.

@Test
public void testWhenValidatingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed() throws Exception {
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobValidationData response = schedulerRest.validateFromUrl(sessionId, workflowUrl, getOneVariablePathSegment("var1", "value1"));
    Assert.assertEquals(1, response.getUpdatedVariables().size());
    Assert.assertEquals("value1", response.getUpdatedVariables().get("var1"));
}
Also used : JobValidationData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData) Test(org.junit.Test)

Example 10 with JobValidationData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData in project scheduling by ow2-proactive.

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenValidatingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed.

@Test
public void testWhenValidatingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed() throws Exception {
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobValidationData response = schedulerRest.validateFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
    Assert.assertEquals(1, response.getUpdatedVariables().size());
    Assert.assertEquals("defaultvalue", response.getUpdatedVariables().get("var1"));
}
Also used : JobValidationData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData) Test(org.junit.Test)

Aggregations

JobValidationData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData)8 Test (org.junit.Test)5 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Task (org.ow2.proactive.scheduler.common.task.Task)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 SequenceInputStream (java.io.SequenceInputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 InputPart (org.jboss.resteasy.plugins.providers.multipart.InputPart)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 Job (org.ow2.proactive.scheduler.common.job.Job)1 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)1 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)1 FlowError (org.ow2.proactive.scheduler.common.job.factories.FlowError)1