use of org.alfresco.rest.api.tests.client.PublicApiException in project alfresco-remote-api by Alfresco.
the class ProcessDefinitionWorkflowApiTest method testGetProcessDefinitionsWhereClause.
@Test
public void testGetProcessDefinitionsWhereClause() throws Exception {
RequestContext requestContext = initApiClientWithTestUser();
String adhocKey = createProcessDefinitionKey("activitiAdhoc", requestContext);
org.activiti.engine.repository.ProcessDefinition activitiDefinition = activitiProcessEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(adhocKey).singleResult();
assertNotNull(activitiDefinition);
ProcessDefinitionsClient processDefinitionsClient = publicApiClient.processDefinitionsClient();
// Filter on category equals
Map<String, ProcessDefinition> processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category = 'http://alfresco.org')");
assertTrue(processDefinitionMap.containsKey("activitiReviewPooled"));
assertTrue(processDefinitionMap.containsKey("activitiReview"));
assertTrue(processDefinitionMap.containsKey("activitiParallelGroupReview"));
assertTrue(processDefinitionMap.containsKey("activitiParallelReview"));
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(5, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category = 'unexisting')");
assertEquals(0, processDefinitionMap.size());
// Filter on name equals
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(name = 'Adhoc Activiti Process')");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(name = 'unexisting')");
assertEquals(0, processDefinitionMap.size());
// Filter on key equals
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(key='activitiAdhoc')");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(key='unexisting')");
assertEquals(0, processDefinitionMap.size());
// Filter on version equals
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(version='1')");
assertEquals(5, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(version='2')");
assertEquals(0, processDefinitionMap.size());
// Filter on deploymentId equals
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(deploymentId='" + activitiDefinition.getDeploymentId() + "')");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(deploymentId='unexisting')");
assertEquals(0, processDefinitionMap.size());
// Filter on category matches
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category matches('%alfresco.o%'))");
assertTrue(processDefinitionMap.containsKey("activitiReviewPooled"));
assertTrue(processDefinitionMap.containsKey("activitiReview"));
assertTrue(processDefinitionMap.containsKey("activitiParallelGroupReview"));
assertTrue(processDefinitionMap.containsKey("activitiParallelReview"));
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(5, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category matches('unexisting'))");
assertEquals(0, processDefinitionMap.size());
// Filter on name matches
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(name matches('Adhoc Activiti %'))");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(name matches('unexisting'))");
assertEquals(0, processDefinitionMap.size());
// Filter on key matches
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(key matches('activitiAd%'))");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
// Use AND operator
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category = 'http://alfresco.org' AND name = 'Adhoc Activiti Process')");
assertTrue(processDefinitionMap.containsKey("activitiAdhoc"));
assertEquals(1, processDefinitionMap.size());
// Use OR operator
try {
processDefinitionMap = getProcessDefinitions(processDefinitionsClient, "(category = 'http://alfresco.org' OR name = 'Adhoc Activiti Process')");
fail("Expected exception");
} catch (PublicApiException e) {
assertEquals(400, e.getHttpResponse().getStatusCode());
}
}
Aggregations