use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method testThatJobVariablesAreUsedIfTaskHasNoParents.
@Test
public void testThatJobVariablesAreUsedIfTaskHasNoParents() throws UnknownTaskException {
TaskResultCreator taskResultCreator = new TaskResultCreator();
SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(new DatabaseManagerException());
InternalJob mockedInternalJob = this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTaskWithoutParent());
Map<String, JobVariable> fakeVariableMap = new HashMap<>();
fakeVariableMap.put("TestVar", new JobVariable("TestVar", "h234"));
when(mockedInternalJob.getVariables()).thenReturn(fakeVariableMap);
Map<String, String> fakeReplacementVariableMap = new HashMap<>();
fakeReplacementVariableMap.put("TestVar", "h234");
when(mockedInternalJob.getVariablesAsReplacementMap()).thenReturn(fakeReplacementVariableMap);
TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, mockedInternalJob, this.getMockedInternalTask());
verify(mockedInternalJob, atLeastOnce()).getVariablesAsReplacementMap();
assertThat(new String(taskResult.getPropagatedVariables().get("TestVar")), is("h234"));
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method testThatTaskVariablesAreUsedIfTaskisInDB.
@Test
public void testThatTaskVariablesAreUsedIfTaskisInDB() throws UnknownTaskException {
TaskResultCreator taskResultCreator = new TaskResultCreator();
TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
Map<String, byte[]> fakeVariableMap = new HashMap<>();
fakeVariableMap.put("TestVar", new String("h234").getBytes());
when(mockedTaskResultImpl.getPropagatedVariables()).thenReturn(fakeVariableMap);
SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
when(mockedschedulerDbManager.loadLastTaskResult(any(TaskId.class))).thenReturn(mockedTaskResultImpl);
InternalJob mockedInternalJob = this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTaskWithoutParent());
TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, mockedInternalJob, this.getMockedInternalTask());
verify(mockedTaskResultImpl, atLeastOnce()).getPropagatedVariables();
assertThat(new String(taskResult.getPropagatedVariables().get("TestVar")), is("h234"));
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TerminateReplicateTaskHandlerTest method generateInternalTask.
private InternalTask generateInternalTask(long id) {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
InternalTask internalTask = new InternalScriptTask(job);
internalTask.setId(TaskIdImpl.createTaskId(new JobIdImpl(666L, "JobName"), "readableName", id));
internalTask.setStatus(TaskStatus.PENDING);
return internalTask;
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TerminateReplicateTaskHandlerTest method init.
@Before
public void init() {
action = new FlowAction(FlowActionType.REPLICATE);
action.setDupNumber(0);
MockitoAnnotations.initMocks(this);
when(internalJob.getJobInfo()).thenReturn(jobInfoImpl);
when(internalJob.getJobDescriptor()).thenReturn(jobDescriptorImpl);
terminateReplicateTaskHandler = new TerminateReplicateTaskHandler(internalJob);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class ExtendedSchedulerPolicyTest method createTask.
private InternalScriptTask createTask(String taskStartAt) {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
InternalScriptTask task1 = new InternalScriptTask(job);
if (taskStartAt != null) {
task1.addGenericInformation("START_AT", taskStartAt);
}
return task1;
}
Aggregations