Author: jbarrez
Date: 2009-09-11 10:33:58 -0400 (Fri, 11 Sep 2009)
New Revision: 5628
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
Log:
Fix for JBPM-2502
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-09-10 13:45:51
UTC (rev 5627)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-09-11 14:33:58
UTC (rev 5628)
@@ -37,7 +37,7 @@
public interface JobQuery {
/** duedate property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
- public static final String PROPERTY_DUEDATE = "dueDate";
+ public static final String PROPERTY_DUEDATE = "duedate";
/** state property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
public static final String PROPERTY_STATE = "state";
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java
===================================================================
---
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -55,7 +55,10 @@
* (this usually used in combination with {@link #processDefinitionId(String)}) */
HistoryDetailQuery comments();
- /** order selected process definitions descending for certain {@link #PROPERTY_USERID
properties} */
+ /** order selected process definitions ascending */
+ HistoryDetailQuery orderAsc(String property);
+
+ /** order selected process definitions descending */
HistoryDetailQuery orderDesc(String property);
/** select a specific page in the result set */
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
===================================================================
---
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -34,7 +34,7 @@
/** id property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
String PROPERTY_ID = "dbid";
/** starttime property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
- String PROPERTY_STARTTIME = "startTime";
+ String PROPERTY_CREATETIME = "createTime";
/** endtime property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
String PROPERTY_ENDTIME = "endTime";
/** executionId property to be used as property in {@link #orderAsc(String)} and {@link
#orderDesc(String)} */
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -56,6 +56,8 @@
}
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -80,6 +80,8 @@
if (activityName!=null) {
appendWhereClause(" hai.activityName =
'"+activityName+"'", hql);
}
+
+ appendOrderByClause(hql);
return hql.toString();
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -72,6 +72,8 @@
appendWhereClause(" hd.time > :timeAfter ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -58,6 +58,8 @@
appendWhereClause(" hpi.state = '"+state+"' ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
@@ -83,7 +85,7 @@
}
public HistoryProcessInstanceQuery orderDesc(String property) {
- addOrderByClause("hpi."+property+" asc");
+ addOrderByClause("hpi."+property+" desc");
return this;
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -88,6 +88,8 @@
appendWhereClause(" ht.startTime > :startedAfter ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -67,6 +67,8 @@
appendWhereClause("j.exception is null ", hql);
}
}
+
+ appendOrderByClause(hql);
return hql.toString();
}
Deleted:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,132 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.test.deploy;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.jbpm.api.Deployment;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DeploymentQueryTest extends JbpmTestCase {
-
- public void testSuspendDeployment() {
- String deploymentClaimId = repositoryService
- .createDeployment()
- .setName("Claim")
- .addResourceFromString("process.jpdl.xml",
- "<process name='claim'>" +
- " <start>" +
- " <transition to='c' />" +
- " </start>" +
- " <state name='c' />" +
- "</process>"
- )
- .deploy();
-
- String deploymentHireId = repositoryService
- .createDeployment()
- .setName("Hire")
- .addResourceFromString("process.jpdl.xml",
- "<process name='hire'>" +
- " <start>" +
- " <transition to='h' />" +
- " </start>" +
- " <state name='h' />" +
- "</process>"
- )
- .deploy();
-
- String deploymentFireId = repositoryService
- .createDeployment()
- .setName("Fire")
- .addResourceFromString("process.jpdl.xml",
- "<process name='fire'>" +
- " <start>" +
- " <transition to='f' />" +
- " </start>" +
- " <state name='f' />" +
- "</process>"
- )
- .deploy();
-
- repositoryService.suspendDeployment(deploymentHireId);
-
-
- // find all deployments
-
- List<Deployment> deployments = repositoryService
- .createDeploymentQuery()
- .list();
-
- Set<String> expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Claim");
- expectedDeploymentNames.add("Hire");
- expectedDeploymentNames.add("Fire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- // find suspended deployments
-
- deployments = repositoryService
- .createDeploymentQuery()
- .suspended()
- .list();
-
- expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Hire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- // find active deployments
-
- deployments = repositoryService
- .createDeploymentQuery()
- .notSuspended()
- .list();
-
- expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Claim");
- expectedDeploymentNames.add("Fire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- repositoryService.deleteDeploymentCascade(deploymentClaimId);
- repositoryService.deleteDeploymentCascade(deploymentHireId);
- repositoryService.deleteDeploymentCascade(deploymentFireId);
- }
-
- Set<String> getDeploymentNames(List<Deployment> deployments) {
- Set<String> deploymentNames = new HashSet<String>();
- for (Deployment deployment: deployments) {
- deploymentNames.add(deployment.getName());
- }
- return deploymentNames;
- }
-}
Deleted:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.test.history;
-
-import java.util.List;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.history.HistoryActivityInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryActivityInstanceQeuryTest extends JbpmTestCase {
-
- public void testSimpleQuery() {
- deployJpdlXmlString(
- "<process name='abc'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to ='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <transition to ='c' />" +
- " </state>" +
- " <state name='c'>" +
- " <transition to ='end' />" +
- " </state>" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance =
executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
-
- processInstance = executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
-
- processInstance = executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
-
- executionService.startProcessInstanceByKey("abc");
-
- List<HistoryActivityInstance> histActInsts =
historyService.createHistoryActivityInstanceQuery()
- .activityName("a")
- .list();
-
- assertEquals(4, histActInsts.size());
-
- histActInsts = historyService.createHistoryActivityInstanceQuery()
- .activityName("b")
- .list();
-
- assertEquals(3, histActInsts.size());
-
- histActInsts = historyService.createHistoryActivityInstanceQuery()
- .activityName("c")
- .list();
-
- assertEquals(2, histActInsts.size());
- }
-}
Deleted:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.test.history;
-
-import java.util.List;
-
-import org.jbpm.api.history.HistoryComment;
-import org.jbpm.api.history.HistoryDetail;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryDetailQueryTest extends JbpmTestCase {
-
- public void testTaskCommentDetail() {
- deployJpdlXmlString(
- "<process name='TaskCommentDetail'>" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <task name='t' assignee='johndoe'/>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TaskCommentDetail");
-
- String taskId = taskService.createTaskQuery().uniqueResult().getId();
-
- taskService.addTaskComment(taskId, "hello");
-
- List<HistoryDetail> historyDetails =
historyService.createHistoryDetailQuery().list();
- assertEquals(historyDetails.toString(), 1, historyDetails.size());
-
- historyDetails = historyService
- .createHistoryDetailQuery()
- .comments()
- .list();
-
- assertEquals(historyDetails.toString(), 1, historyDetails.size());
-
- HistoryComment historyComment = (HistoryComment) historyDetails.get(0);
- assertEquals("hello", historyComment.getMessage());
- }
-
- public void testTaskCommentRepliesDetail() {
- deployJpdlXmlString(
- "<process name='TaskCommentRepliesDetail'>" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <task name='t' assignee='johndoe'/>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TaskCommentRepliesDetail");
-
- String taskId = taskService.createTaskQuery().uniqueResult().getId();
-
- processEngine.setAuthenticatedUserId("johndoe");
- String helloCommentId = taskService.addTaskComment(taskId, "hi, how are you
guys?").getId();
-
- processEngine.setAuthenticatedUserId("joesmoe");
- taskService.addReplyComment(helloCommentId, "i'm doing fine, thanks");
-
- processEngine.setAuthenticatedUserId("jackblack");
- taskService.addReplyComment(helloCommentId, "i got a hangover");
-
- List<HistoryDetail> historyDetails =
historyService.createHistoryDetailQuery().list();
- assertEquals(historyDetails.toString(), 3, historyDetails.size());
-
- historyDetails = historyService
- .createHistoryDetailQuery()
- .comments()
- .list();
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,111 +0,0 @@
-package org.jbpm.test.mgmt;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.jbpm.api.job.Job;
-import org.jbpm.test.JbpmTestCase;
-
-
-public class JobQueryTest extends JbpmTestCase {
-
- public void testQueryOutstandingTimers() {
- deployJpdlXmlString(
- "<process name='TimerQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <state name='t'>" +
- " <transition name='timeout' to='t'>" +
- " <timer duedate='20 seconds' />" +
- " </transition>" +
- " </state>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
-
- List<Job> timers = managementService.createJobQuery()
- .timers()
- .list();
-
- assertEquals(4, timers.size());
- }
-
- public void testQueryBacklogMessages() {
- deployJpdlXmlString(
- "<process name='MessagesQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <state name='t' continue='async' />" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
-
- List<Job> timers = managementService.createJobQuery()
- .messages()
- .list();
-
- assertEquals(4, timers.size());
- }
-
-
- public static class Dog implements Serializable {
- private static final long serialVersionUID = 1L;
- public void bark() {
- throw new RuntimeException("wooof");
- }
- }
- public void testErrorMessages() {
- deployJpdlXmlString(
- "<process name='ErrorMsgQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <java name='t' " +
- " continue='async' " +
- " class='"+Dog.class.getName()+"'" +
- " method='bark'>" +
- " </java>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
-
-
- List<Job> messages = managementService.createJobQuery()
- .messages()
- .list();
-
- assertEquals(3, messages.size());
-
- managementService.executeJob(messages.get(0).getId());
- managementService.executeJob(messages.get(0).getId());
- managementService.executeJob(messages.get(0).getId());
-
- List<Job> errorJobs = managementService.createJobQuery()
- .exception(true)
- .list();
-
- assertEquals(1, errorJobs.size());
-
- assertTextPresent("wooof", errorJobs.get(0).getException());
-
- messages = managementService.createJobQuery()
- .messages()
- .exception(false)
- .list();
-
- assertEquals(2, messages.size());
- }
-}
Deleted:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.test.process;
-
-import java.util.List;
-
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessDefinitionQueryTest extends JbpmTestCase {
-
- public void testQueryProcessDefinitionsEmpty() {
- List<ProcessDefinition> processDefinitions = repositoryService
- .createProcessDefinitionQuery()
- .list();
-
- assertEquals(0, processDefinitions.size());
- }
-
- public void testQueryProcessDefinitionsNameLike() {
- deployJpdlXmlString(
- "<process name='make print'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='use phone'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='clean whiteboard'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='fix coffeemaker'>" +
- " <start />" +
- "</process>"
- );
-
- List<ProcessDefinition> processDefinitions =
repositoryService.createProcessDefinitionQuery()
- .processDefinitionNameLike("%make%")
- .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
- .list();
-
- assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
- assertEquals("make friends", processDefinitions.get(1).getName());
- assertEquals("make print", processDefinitions.get(2).getName());
- }
-
- public void testQueryProcessDefinitionsKeyLike() {
- deployJpdlXmlString(
- "<process name='make print'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='use phone'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='clean whiteboard'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='fix coffeemaker'>" +
- " <start />" +
- "</process>"
- );
-
- List<ProcessDefinition> processDefinitions =
repositoryService.createProcessDefinitionQuery()
- .processDefinitionNameLike("make%")
- .orderAsc(ProcessDefinitionQuery.PROPERTY_ID)
- .list();
-
- assertEquals("make_friends-1", processDefinitions.get(0).getId());
- assertEquals("make_friends-2", processDefinitions.get(1).getId());
- assertEquals("make_friends-3", processDefinitions.get(2).getId());
- assertEquals("make_print-1", processDefinitions.get(3).getId());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-10
13:45:51 UTC (rev 5627)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-11
14:33:58 UTC (rev 5628)
@@ -1,260 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.test.task;
-
-import java.lang.reflect.Method;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.api.TaskQuery;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskQueryTest extends JbpmTestCase {
-
- public void testPropertyNames() {
- Task task = taskService.newTask();
- task.setName("write task query test");
- task.setAssignee("koen");
- task.setPriority(Integer.MAX_VALUE);
- task.setDescription("make sure the test fails if property names are
incorrect");
- task.setDuedate(new Date());
- String taskId = taskService.saveTask(task);
-
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_ASSIGNEE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_CREATEDATE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_DUEDATE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_NAME);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PRIORITY);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PROGRESS);
-
- taskService.deleteTaskCascade(taskId);
- }
-
- private void checkProperty(TaskQuery taskQuery, Task task, String propertyName) {
- List<Task> taskList = taskQuery.orderAsc(propertyName).list();
- assertNotNull(taskList);
- assertContainsTask(taskList, task.getName());
- assertEquals(1, taskList.size());
- }
-
- public void testSimplestTaskQuery() {
- List<Task> tasks = createTestTasks();
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .list();
- assertNotNull(taskList);
-
- assertContainsTask(taskList, "do laundry");
- assertContainsTask(taskList, "change dyper");
- assertContainsTask(taskList, "start new business");
- assertContainsTask(taskList, "find venture capital");
-
- assertEquals(4, taskList.size());
-
- deleteTasks(tasks);
- }
-
- public void testOrderByName() {
- testOrderBy(TaskQuery.PROPERTY_NAME,
- new String[] {"change dyper", "do laundry", "find
venture capital", "start new business"});
- }
-
- public void testOrderByAssignee() {
- testOrderBy(TaskQuery.PROPERTY_ASSIGNEE, new String[] {null, "Joram",
"Koen", "Tom"});
- }
-
- public void testOrderByCreateTime() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_CREATEDATE, 4);
- }
-
- public void testOrderByDueDate() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_DUEDATE, 4);
- }
-
- public void testOrderByPriority() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_PRIORITY, 4);
- }
-
- public void testOrderByProgress() {
- testOrderBy(TaskQuery.PROPERTY_PROGRESS, new Integer[] {2, 15, 75, 99});
- }
-
-
- /* -------------------------------------------------------------------
- * HELPER METHODS
- * ------------------------------------------------------------------- */
-
- private List<Task> createTestTasks() {
- List<Task> result = new ArrayList<Task>();
-
- Task task1 = taskService.newTask();
- task1.setName("do laundry");
- task1.setAssignee("Tom");
- task1.setPriority(3);
- task1.setDuedate(stringToDate("10/10/1985"));
- task1.setProgress(15);
-
- Task task2 = taskService.newTask();
- task2.setName("change dyper");
- task2.setAssignee("Koen");
- task2.setPriority(1);
- task2.setDuedate(stringToDate("28/06/1989"));
- task2.setProgress(2);
-
- Task task3 = taskService.newTask();
- task3.setName("start new business");
- task3.setAssignee("Joram");
- task3.setPriority(4);
- task3.setProgress(75);
-
- Task task4 = taskService.newTask();
- task4.setName("find venture capital");
- task4.setPriority(7);
- task4.setDuedate(stringToDate("09/09/2009"));
- task4.setProgress(99);
-
- for (Task t : new Task[] {task1, task2, task3, task4}) {
- taskService.saveTask(t);
- result.add(t);
- }
-
- return result;
- }
-
- /**
- * Convience method:
- * - Creates a task query with order asc/desc on the given <i>property</i>
param.
- * - Loops over both result lists and checks if the elements
- * are in the order as given by the <i>expectedValues</i> param.
- */
- private void testOrderBy(String property, Object[] expectedValues) {
- List<Task> tasks = createTestTasks();
-
- List<Task> taskListAsc =
taskService.createTaskQuery().orderAsc(property).list();
- List<Task> taskListDesc =
taskService.createTaskQuery().orderDesc(property).list();
-
- assertNotNull(taskListAsc);
- assertEquals(expectedValues.length, taskListAsc.size());
-
- assertNotNull(taskListDesc);
- assertEquals(expectedValues.length, taskListDesc.size());
-
- for (int i = 0; i < expectedValues.length; i++) {
-
- Object realValueAsc = null;
- Object realValueDesc = null;
-
- try {
-
- realValueAsc = invokeGetterOnTask(property, taskListAsc.get(i));
- realValueDesc = invokeGetterOnTask(property,
taskListDesc.get((taskListDesc.size() -1) - i));
-
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- assertEquals("Incorrect order by ASC for property " + property,
expectedValues[i], realValueAsc);
- assertEquals("Incorrect order by ASC for property " + property,
expectedValues[i], realValueAsc);
-
- }
-
- deleteTasks(tasks);
- }
-
- /**
- * Creates a taskquery for tasks, orderd on the given property.
- * The resulting list is checked asc/desc for natural order.
- *
- * Note property must implement Comparable!
- */
- @SuppressWarnings("unchecked")
- private void testOrderByResultsInNaturalOrdening(String property, int
expectedNrOfResults) {
- List<Task> tasks = createTestTasks();
- List<Task> taskListAsc =
taskService.createTaskQuery().orderAsc(property).list();
- List<Task> taskListDesc =
taskService.createTaskQuery().orderDesc(property).list();
-
- assertEquals(expectedNrOfResults, taskListAsc.size());
- assertEquals(expectedNrOfResults, taskListDesc.size());
-
- if (expectedNrOfResults > 1) {
-
- for (int i = 1; i < taskListAsc.size(); i++) {
-
- // ascending check
- Comparable c1 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i -
1));
- Comparable c2 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i));
- if (c1 != null && c2 != null) {
- assertTrue(c1.compareTo(c2) <= 0); // c1 <= c2 when ascending
- }
-
- // ascending check
- Comparable c3 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i -
1));
- Comparable c4 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i));
- if (c3 != null && c4 != null) {
- assertTrue(c3.compareTo(c4) >= 0); // c3 >= c4 when ascending
- }
-
- }
- }
-
- deleteTasks(tasks);
- }
-
- private Object invokeGetterOnTask(String property, Task task) {
- Method getter = ReflectUtil.getMethod(TaskImpl.class,
- "get" + property.substring(0, 1).toUpperCase() +
property.substring(1), null);
- try {
- return getter.invoke(task);
- } catch (Exception e) {
- throw new RuntimeException("Couldn't invoke getter for property " +
property);
- }
- }
-
- private void deleteTasks(List<Task> tasks) {
- for (Task t : tasks) {
- taskService.deleteTaskCascade(t.getId());
- }
- }
-
- private Date stringToDate(String dateString) {
- DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
- try {
- return dateFormat.parse(dateString);
- } catch (ParseException e) {
- throw new RuntimeException("Couldn't convert " + dateString);
- }
- }
-
-}