// mock taskmanager to simply accept the call
TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
when(taskManager.submitTask(Matchers.any(TaskDeploymentDescriptor.class))).thenAnswer(new Answer<TaskOperationResult>() {
@Override
public TaskOperationResult answer(InvocationOnMock invocation) {
final TaskDeploymentDescriptor tdd = (TaskDeploymentDescriptor) invocation.getArguments()[0];
reference.set(tdd);
return new TaskOperationResult(tdd.getExecutionId(), true);
}
});
final Instance instance = getInstance(taskManager);
final AllocatedSlot slot = instance.allocateSlot(jobId);
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.deployToSlot(slot);
assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
TaskDeploymentDescriptor descr = reference.get();
assertNotNull(descr);
assertEquals(jobId, descr.getJobID());
assertEquals(jid2, descr.getVertexID());
assertEquals(3, descr.getIndexInSubtaskGroup());
assertEquals(10, descr.getCurrentNumberOfSubtasks());
assertEquals(RegularPactTask.class.getName(), descr.getInvokableClassName());
assertEquals("v2", descr.getTaskName());
assertEquals(2, descr.getOutputGates().size());
assertEquals(1, descr.getInputGates().size());
assertEquals(10, descr.getOutputGates().get(0).getChannels().size());
assertEquals(10, descr.getOutputGates().get(1).getChannels().size());
assertEquals(10, descr.getInputGates().get(0).getChannels().size());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}