use of org.opencastproject.workflow.api.WorkflowQuery in project opencast by opencast.
the class WorkflowServiceImplTest method testGetWorkflowByEpisodeId.
@Test
public void testGetWorkflowByEpisodeId() throws Exception {
String mediaPackageId = mediapackage1.getIdentifier().toString();
// Ensure that the database doesn't have a workflow instance with this episode
Assert.assertEquals(0, service.countWorkflowInstances());
Assert.assertEquals(0, service.getWorkflowInstances(new WorkflowQuery().withMediaPackage(mediaPackageId)).size());
startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
WorkflowSet workflowsInDb = service.getWorkflowInstances(new WorkflowQuery().withMediaPackage(mediaPackageId));
Assert.assertEquals(1, workflowsInDb.getItems().length);
}
use of org.opencastproject.workflow.api.WorkflowQuery in project opencast by opencast.
the class WorkflowServiceImplTest method testGetWorkflowByCreator.
@Test
public void testGetWorkflowByCreator() throws Exception {
// Set different creators in the mediapackages
String manfred = "Dr. Manfred Frisch";
mediapackage1.addCreator(manfred);
mediapackage2.addCreator("Somebody else");
// Ensure that the database doesn't have any workflow instances with media packages with this creator
Assert.assertEquals(0, service.countWorkflowInstances());
WorkflowInstance instance1 = startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
WorkflowInstance instance2 = startAndWait(workingDefinition, mediapackage2, WorkflowState.SUCCEEDED);
Assert.assertEquals(WorkflowState.SUCCEEDED, service.getWorkflowById(instance1.getId()).getState());
Assert.assertEquals(WorkflowState.SUCCEEDED, service.getWorkflowById(instance2.getId()).getState());
// Build the workflow query
WorkflowQuery queryForManfred = new WorkflowQuery().withCreator(manfred);
Assert.assertEquals(1, service.getWorkflowInstances(queryForManfred).getTotalCount());
Assert.assertEquals(instance1.getMediaPackage().getIdentifier().toString(), service.getWorkflowInstances(queryForManfred).getItems()[0].getMediaPackage().getIdentifier().toString());
}
use of org.opencastproject.workflow.api.WorkflowQuery in project opencast by opencast.
the class WorkflowServiceImplTest method testGetWorkflowByText.
@Test
public void testGetWorkflowByText() throws Exception {
// Ensure that the database doesn't have any workflow instances
Assert.assertEquals(0, service.countWorkflowInstances());
Assert.assertEquals(0, service.getWorkflowInstances(new WorkflowQuery().withText("Climate").withCount(100).withStartPage(0)).size());
startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
WorkflowSet workflowsInDb = service.getWorkflowInstances(new WorkflowQuery().withText("Climate").withCount(100).withStartPage(0));
Assert.assertEquals(1, workflowsInDb.getItems().length);
Assert.assertEquals(1, service.getWorkflowInstances(new WorkflowQuery().withText("limate")).size());
Assert.assertEquals(1, service.getWorkflowInstances(new WorkflowQuery().withText("mate")).size());
Assert.assertEquals(1, service.getWorkflowInstances(new WorkflowQuery().withText("lima")).size());
}
use of org.opencastproject.workflow.api.WorkflowQuery in project opencast by opencast.
the class WorkflowServiceImplTest method testGetWorkflowByCurrentOperation.
@Test
public void testGetWorkflowByCurrentOperation() throws Exception {
// Ensure that the database doesn't have a workflow instance in the "opPause" operation
Assert.assertEquals(0, service.countWorkflowInstances());
Assert.assertEquals(0, service.getWorkflowInstances(new WorkflowQuery().withCurrentOperation("opPause")).size());
startAndWait(pausingWorkflowDefinition, mediapackage1, WorkflowState.PAUSED);
WorkflowSet workflowsInDb = service.getWorkflowInstances(new WorkflowQuery().withCurrentOperation("opPause"));
Assert.assertEquals(1, workflowsInDb.getItems().length);
}
use of org.opencastproject.workflow.api.WorkflowQuery in project opencast by opencast.
the class WorkflowServiceImplTest method testCleanupWorkflowInstances.
/**
* Test for {@link WorkflowServiceImpl#cleanupWorkflowInstances(int, WorkflowState)}
*
* @throws Exception
* if anything fails
*/
@Test
public void testCleanupWorkflowInstances() throws Exception {
WorkflowInstance wi1 = startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
startAndWait(workingDefinition, mediapackage2, WorkflowState.SUCCEEDED);
// reload instances, because operations have no id before
wi1 = service.getWorkflowById(wi1.getId());
service.cleanupWorkflowInstances(0, WorkflowState.FAILED);
assertEquals(2, service.getWorkflowInstances(new WorkflowQuery()).size());
service.cleanupWorkflowInstances(0, WorkflowState.SUCCEEDED);
assertEquals(0, service.getWorkflowInstances(new WorkflowQuery()).size());
for (WorkflowOperationInstance op : wi1.getOperations()) {
assertEquals(0, serviceRegistry.getChildJobs(op.getId()).size());
}
}
Aggregations