Search in sources :

Example 11 with WorkflowSet

use of org.opencastproject.workflow.api.WorkflowSet in project opencast by opencast.

the class WorkflowServiceImplTest method testNegativeWorkflowQuery.

@Test
public void testNegativeWorkflowQuery() 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);
    startAndWait(workingDefinition, mediapackage2, WorkflowState.SUCCEEDED);
    startAndWait(failingDefinitionWithoutErrorHandler, mediapackage1, WorkflowState.FAILED);
    WorkflowSet succeededWorkflows = service.getWorkflowInstances(new WorkflowQuery().withState(WorkflowState.SUCCEEDED));
    Assert.assertEquals(2, succeededWorkflows.getItems().length);
    WorkflowSet failedWorkflows = service.getWorkflowInstances(new WorkflowQuery().withState(WorkflowState.FAILED));
    Assert.assertEquals(1, failedWorkflows.getItems().length);
    // Ensure that the "without" queries works
    WorkflowSet notFailedWorkflows = service.getWorkflowInstances(new WorkflowQuery().withoutState(WorkflowState.FAILED));
    Assert.assertEquals(2, notFailedWorkflows.getItems().length);
}
Also used : WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) WorkflowQuery(org.opencastproject.workflow.api.WorkflowQuery) Test(org.junit.Test)

Example 12 with WorkflowSet

use of org.opencastproject.workflow.api.WorkflowSet in project opencast by opencast.

the class WorkflowServiceImplTest method testGetWorkflowByWildcardMatching.

@Test
public void testGetWorkflowByWildcardMatching() throws Exception {
    String searchTerm = "another";
    String searchTermWithoutQuotes = "yet another";
    String searchTermInQuotes = "\"" + searchTermWithoutQuotes + "\"";
    String title = "just" + searchTerm + " " + searchTermInQuotes + " rev129";
    // Ensure that the database doesn't have any workflow instances
    Assert.assertEquals(0, service.countWorkflowInstances());
    mediapackage1.setTitle(title);
    startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
    WorkflowSet workflowsWithTitle = service.getWorkflowInstances(new WorkflowQuery().withTitle(searchTerm));
    Assert.assertEquals(1, workflowsWithTitle.getTotalCount());
    WorkflowSet workflowsWithQuotedTitle = service.getWorkflowInstances(new WorkflowQuery().withTitle(searchTermInQuotes));
    Assert.assertEquals(1, workflowsWithQuotedTitle.getTotalCount());
    WorkflowSet workflowsWithUnQuotedTitle = service.getWorkflowInstances(new WorkflowQuery().withTitle(searchTermWithoutQuotes));
    Assert.assertEquals(1, workflowsWithUnQuotedTitle.getTotalCount());
}
Also used : WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) WorkflowQuery(org.opencastproject.workflow.api.WorkflowQuery) Test(org.junit.Test)

Example 13 with WorkflowSet

use of org.opencastproject.workflow.api.WorkflowSet in project opencast by opencast.

the class WorkflowServiceImplTest method testGetWorkflowSort.

@Test
public void testGetWorkflowSort() throws Exception {
    String contributor1 = "foo";
    String contributor2 = "bar";
    String contributor3 = "baz";
    // Ensure that the database doesn't have any workflow instances
    Assert.assertEquals(0, service.countWorkflowInstances());
    // set contributors (a multivalued field)
    mediapackage1.addContributor(contributor1);
    mediapackage1.addContributor(contributor2);
    mediapackage2.addContributor(contributor2);
    mediapackage2.addContributor(contributor3);
    // run the workflows
    startAndWait(workingDefinition, mediapackage1, WorkflowState.SUCCEEDED);
    startAndWait(workingDefinition, mediapackage2, WorkflowState.SUCCEEDED);
    WorkflowSet workflowsWithContributor1 = service.getWorkflowInstances(new WorkflowQuery().withContributor(contributor1));
    WorkflowSet workflowsWithContributor2 = service.getWorkflowInstances(new WorkflowQuery().withContributor(contributor2));
    WorkflowSet workflowsWithContributor3 = service.getWorkflowInstances(new WorkflowQuery().withContributor(contributor3));
    Assert.assertEquals(1, workflowsWithContributor1.getTotalCount());
    Assert.assertEquals(2, workflowsWithContributor2.getTotalCount());
    Assert.assertEquals(1, workflowsWithContributor3.getTotalCount());
}
Also used : WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) WorkflowQuery(org.opencastproject.workflow.api.WorkflowQuery) Test(org.junit.Test)

Example 14 with WorkflowSet

use of org.opencastproject.workflow.api.WorkflowSet 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);
}
Also used : WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) WorkflowQuery(org.opencastproject.workflow.api.WorkflowQuery) Test(org.junit.Test)

Example 15 with WorkflowSet

use of org.opencastproject.workflow.api.WorkflowSet 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());
}
Also used : WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) WorkflowQuery(org.opencastproject.workflow.api.WorkflowQuery) Test(org.junit.Test)

Aggregations

WorkflowSet (org.opencastproject.workflow.api.WorkflowSet)19 WorkflowQuery (org.opencastproject.workflow.api.WorkflowQuery)18 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)12 Test (org.junit.Test)9 WorkflowDatabaseException (org.opencastproject.workflow.api.WorkflowDatabaseException)7 NotFoundException (org.opencastproject.util.NotFoundException)6 ArrayList (java.util.ArrayList)5 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 Organization (org.opencastproject.security.api.Organization)3 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)3 WorkflowException (org.opencastproject.workflow.api.WorkflowException)3 WorkflowParsingException (org.opencastproject.workflow.api.WorkflowParsingException)3 IOException (java.io.IOException)2 Lock (java.util.concurrent.locks.Lock)2 AssetManagerException (org.opencastproject.assetmanager.api.AssetManagerException)2 IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)2 MediaPackage (org.opencastproject.mediapackage.MediaPackage)2 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)2 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)2