Search in sources :

Example 11 with JobImpl

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;
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) JobImpl(org.opencastproject.job.api.JobImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) Job(org.opencastproject.job.api.Job) LinkedList(java.util.LinkedList)

Example 12 with JobImpl

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");
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) JobImpl(org.opencastproject.job.api.JobImpl) SecurityService(org.opencastproject.security.api.SecurityService) MessageSender(org.opencastproject.message.broker.api.MessageSender) ArrayList(java.util.ArrayList) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) OrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService) Before(org.junit.Before)

Example 13 with JobImpl

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);
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) Test(org.junit.Test)

Example 14 with JobImpl

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());
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) Job(org.opencastproject.job.api.Job) File(java.io.File) URI(java.net.URI) Capture(org.easymock.Capture) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Example 15 with JobImpl

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;
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) Job(org.opencastproject.job.api.Job) Date(java.util.Date)

Aggregations

JobImpl (org.opencastproject.job.api.JobImpl)21 Job (org.opencastproject.job.api.Job)17 Before (org.junit.Before)9 Test (org.junit.Test)9 File (java.io.File)7 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)7 Workspace (org.opencastproject.workspace.api.Workspace)7 ArrayList (java.util.ArrayList)6 MediaPackage (org.opencastproject.mediapackage.MediaPackage)6 URI (java.net.URI)5 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)5 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)5 InputStream (java.io.InputStream)4 List (java.util.List)4 SecurityService (org.opencastproject.security.api.SecurityService)4 WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)4 Date (java.util.Date)3 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)3 JaxbRole (org.opencastproject.security.api.JaxbRole)3 JaxbUser (org.opencastproject.security.api.JaxbUser)3