use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class WorkflowServiceImplTest method setupWorkflowInstanceImpl.
private WorkflowInstanceImpl setupWorkflowInstanceImpl(long id, String operation, WorkflowState state, Date startDate) throws ConfigurationException, MediaPackageException, NotFoundException, ServiceRegistryException {
Job job = new JobImpl(id);
job = serviceRegistry.updateJob(job);
MediaPackage mediapackage = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mediapackage.setDate(startDate);
mediapackage.setDuration(7200L);
WorkflowOperationInstanceImpl workflowOperation = new WorkflowOperationInstanceImpl(operation, OperationState.PAUSED);
workflowOperation.setId(id);
List<WorkflowOperationInstance> workflowOperationInstanceList = new LinkedList<WorkflowOperationInstance>();
workflowOperationInstanceList.add(workflowOperation);
WorkflowInstanceImpl workflowInstanceImpl = new WorkflowInstanceImpl();
workflowInstanceImpl.setMediaPackage(mediapackage);
workflowInstanceImpl.setState(state);
workflowInstanceImpl.setId(id);
workflowInstanceImpl.setOperations(workflowOperationInstanceList);
return workflowInstanceImpl;
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class WorkflowServiceSolrIndexTest method setUp.
@Before
public void setUp() throws Exception {
// security service
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(SecurityServiceStub.DEFAULT_ORG_ADMIN).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
OrganizationDirectoryService orgDirectroy = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgDirectroy.getOrganization((String) EasyMock.anyObject())).andReturn(securityService.getOrganization()).anyTimes();
EasyMock.replay(orgDirectroy);
// Create a job with a workflow as its payload
List<Job> jobs = new ArrayList<>();
Job job = new JobImpl();
WorkflowInstanceImpl workflow = new WorkflowInstanceImpl();
workflow.setId(123);
workflow.setCreator(securityService.getUser());
workflow.setOrganization(securityService.getOrganization());
workflow.setState(WorkflowState.INSTANTIATED);
workflow.setMediaPackage(MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew());
String jobPayload = WorkflowParser.toXml(workflow);
job.setPayload(jobPayload);
job.setOrganization(securityService.getOrganization().getId());
jobs.add(job);
// Mock up the service registry to return the job
ServiceRegistry serviceRegistry = EasyMock.createMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.count(WorkflowService.JOB_TYPE, null)).andReturn(1L);
EasyMock.expect(serviceRegistry.getJobs(WorkflowService.JOB_TYPE, null)).andReturn(jobs);
EasyMock.expect(serviceRegistry.getJob(123)).andReturn(job);
EasyMock.expect(serviceRegistry.getJobPayloads("START_WORKFLOW")).andReturn(Collections.singletonList(jobPayload));
EasyMock.replay(serviceRegistry);
MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
EasyMock.replay(messageSender);
// Now create the dao
dao = new WorkflowServiceSolrIndex();
dao.solrRoot = PathSupport.concat("target", Long.toString(System.currentTimeMillis()));
dao.setServiceRegistry(serviceRegistry);
dao.setSecurityService(securityService);
dao.setOrgDirectory(orgDirectroy);
dao.activate("System Admin");
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class WaveformServiceImplTest method testGenerateWaveformImage.
/**
* Test of createWaveformImage method of class WaveformServiceImpl.
*/
@Test
public void testGenerateWaveformImage() throws Exception {
Job expectedJob = new JobImpl(1);
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.createJob(EasyMock.eq(WaveformServiceImpl.JOB_TYPE), EasyMock.eq(WaveformServiceImpl.Operation.Waveform.toString()), (List<String>) EasyMock.anyObject(), EasyMock.anyFloat())).andReturn(expectedJob);
EasyMock.replay(serviceRegistry);
WaveformServiceImpl instance = new WaveformServiceImpl();
instance.setServiceRegistry(serviceRegistry);
Job job = instance.createWaveformImage(dummyTrack);
assertEquals(expectedJob, job);
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class WaveformServiceImplTest method testProcess.
/**
* Test of process method of class WaveformServiceImpl.
*/
@Test
public void testProcess() throws Exception {
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(new File(audioTrack.getURI()));
Capture filenameCapture = new Capture();
EasyMock.expect(workspace.putInCollection(EasyMock.anyString(), (String) EasyMock.capture(filenameCapture), (InputStream) EasyMock.anyObject())).andReturn(new URI("waveform.png"));
EasyMock.replay(workspace);
WaveformServiceImpl instance = new WaveformServiceImpl();
instance.setWorkspace(workspace);
String audioTrackXml = MediaPackageElementParser.getAsXml(audioTrack);
Job job = new JobImpl(1);
job.setJobType(WaveformServiceImpl.JOB_TYPE);
job.setOperation(WaveformServiceImpl.Operation.Waveform.toString());
job.setArguments(Arrays.asList(audioTrackXml));
String result = instance.process(job);
assertNotNull(result);
MediaPackageElement waveformAttachment = MediaPackageElementParser.getFromXml(result);
assertEquals(new URI("waveform.png"), waveformAttachment.getURI());
assertTrue(filenameCapture.hasCaptured());
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class TestJobEndpoint method createJob.
private Job createJob(int id, Status status, String jobType, String operation, String created, String started, String creator, String hostname) throws Exception {
Date createdDate = new Date(DateTimeSupport.fromUTC(created));
Date startedDate = new Date(DateTimeSupport.fromUTC(started));
Job job = new JobImpl(id);
job.setStatus(status);
job.setJobType(jobType);
job.setOperation(operation);
job.setCreator(creator);
job.setProcessingHost(hostname);
job.setDateCreated(createdDate);
job.setDateStarted(startedDate);
return job;
}
Aggregations