Search in sources :

Example 36 with MediaPackageBuilder

use of org.opencastproject.mediapackage.MediaPackageBuilder in project opencast by opencast.

the class DefaultsWorkflowOperationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    mp = builder.createNew();
    // set up service
    operationHandler = new DefaultsWorkflowOperationHandler();
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) Before(org.junit.Before)

Example 37 with MediaPackageBuilder

use of org.opencastproject.mediapackage.MediaPackageBuilder in project opencast by opencast.

the class TagByDublinCoreTermWOHTest method setUp.

@Before
public void setUp() throws Exception {
    MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    mp = builder.loadFromXml(this.getClass().getResourceAsStream("/archive_mediapackage.xml"));
    mp.getCatalog("catalog-1").setURI(this.getClass().getResource("/dublincore.xml").toURI());
    // set up the handler
    operationHandler = new TagByDublinCoreTermWOH();
    // Initialize the workflow
    instance = new WorkflowInstanceImpl();
    operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(mp);
    workspace = EasyMock.createNiceMock(Workspace.class);
    EasyMock.expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml"));
    EasyMock.replay(workspace);
    operationHandler.setWorkspace(workspace);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 38 with MediaPackageBuilder

use of org.opencastproject.mediapackage.MediaPackageBuilder in project opencast by opencast.

the class ZipWorkflowOperationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    mp = builder.loadFromXml(this.getClass().getResourceAsStream("/archive_mediapackage.xml"));
    // set up the handler
    operationHandler = new ZipWorkflowOperationHandler();
    // set up mock workspace
    workspace = EasyMock.createNiceMock(Workspace.class);
    URI newURI = new URI("http://www.url.org");
    EasyMock.expect(workspace.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())).andReturn(newURI).anyTimes();
    EasyMock.expect(workspace.getURI((String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(newURI).anyTimes();
    EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(new File(getClass().getResource("/dublincore.xml").toURI())).anyTimes();
    EasyMock.replay(workspace);
    operationHandler.setWorkspace(workspace);
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) InputStream(java.io.InputStream) URI(java.net.URI) File(java.io.File) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 39 with MediaPackageBuilder

use of org.opencastproject.mediapackage.MediaPackageBuilder in project opencast by opencast.

the class CloneWorkflowOperationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    // test resources
    URI uriMP = getClass().getResource("/clone_mediapackage.xml").toURI();
    mp = builder.loadFromXml(uriMP.toURL().openStream());
    // set up mock workspace
    workspace = EasyMock.createNiceMock(Workspace.class);
    // set up service
    operationHandler = new CloneWorkflowOperationHandler();
    // Prepare file to returne from workflow
    File videoFile = new File(getClass().getResource("/av.mov").toURI());
    EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(videoFile).anyTimes();
    EasyMock.replay(workspace);
    operationHandler.setWorkspace(workspace);
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) URI(java.net.URI) File(java.io.File) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 40 with MediaPackageBuilder

use of org.opencastproject.mediapackage.MediaPackageBuilder in project opencast by opencast.

the class CleanupWorkflowOperationHandlerTest method testCreanupWOHwithoutPreservedFlavor.

@Test
public void testCreanupWOHwithoutPreservedFlavor() throws WorkflowOperationException, MediaPackageException {
    Map<String, String> wfInstConfig = new Hashtable<>();
    wfInstConfig.put(CleanupWorkflowOperationHandler.DELETE_EXTERNAL, "true");
    MediaPackageBuilder mpBuilder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    MediaPackage mp = mpBuilder.createNew();
    MediaPackageElement track1 = addElementToMediaPackage(mp, MediaPackageElement.Type.Track, "presenter", "source", null);
    track1.setURI(UrlSupport.uri(HOSTNAME_NODE1, WFR_URL_PREFIX, WorkingFileRepository.COLLECTION_PATH_PREFIX, "asset", mp.getIdentifier().compact(), track1.getIdentifier(), "track.mp4"));
    cleanupWOH.start(createWorkflowInstance(wfInstConfig, mp), null);
    Assert.assertEquals("Media package shouldn't contain any elements", 0, mp.getElements().length);
    Assert.assertEquals("One file wasn't deleted on remote repository", 1, deletedFilesURIs.size());
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) Hashtable(java.util.Hashtable) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Test(org.junit.Test)

Aggregations

MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)46 Before (org.junit.Before)35 Workspace (org.opencastproject.workspace.api.Workspace)27 URI (java.net.URI)20 File (java.io.File)18 MediaPackage (org.opencastproject.mediapackage.MediaPackage)18 ArrayList (java.util.ArrayList)15 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)13 Job (org.opencastproject.job.api.Job)11 SecurityService (org.opencastproject.security.api.SecurityService)11 InputStream (java.io.InputStream)10 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)10 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)10 UserDirectoryService (org.opencastproject.security.api.UserDirectoryService)10 IncidentService (org.opencastproject.serviceregistry.api.IncidentService)10 ServiceRegistryInMemoryImpl (org.opencastproject.serviceregistry.api.ServiceRegistryInMemoryImpl)10 Date (java.util.Date)9 DefaultMediaPackageSerializerImpl (org.opencastproject.mediapackage.DefaultMediaPackageSerializerImpl)9 Organization (org.opencastproject.security.api.Organization)9 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)9