Author: tom.baeyens(a)jboss.com
Date: 2009-01-23 12:02:45 -0500 (Fri, 23 Jan 2009)
New Revision: 3718
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
Log:
improved query api on process, execution and task service
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-01-23 13:44:13
UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-01-23 17:02:45
UTC (rev 3718)
@@ -29,15 +29,18 @@
*/
public interface ExecutionQuery {
- ExecutionQuery onlyProcessInstances();
-
+ String PROPERTY_KEY = "key";
+
ExecutionQuery processDefinitionNameLike(String processDefinitionName);
ExecutionQuery processDefinitionKeyLike(String processDefinitionKey);
ExecutionQuery processDefinitionId(String processDefinitionId);
- ExecutionQuery orderByKeyAsc();
- ExecutionQuery orderByKeyDesc();
+ ExecutionQuery processInstanceId(String processInstanceId);
- List<Execution> list();
- List<Execution> list(int firstResult, int maxResults);
+ ExecutionQuery orderAsc(String property);
+ ExecutionQuery orderDesc(String property);
+
+ ExecutionQuery page(int firstResult, int maxResults);
+
+ List<Execution> execute();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-01-23
13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -117,6 +117,9 @@
/** search for executions with criteria */
ExecutionQuery createExecutionQuery();
+ /** search for process instances with criteria */
+ ExecutionQuery createProcessInstanceQuery();
+
/** creates or overwrites a variable value on the referenced execution */
Execution setVariable(String executionId, String name, Object value);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-01-23
13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -28,15 +28,17 @@
*/
public interface ProcessDefinitionQuery {
+ String PROPERTY_NAME = "name";
+ String PROPERTY_KEY = "key";
+ String PROPERTY_PACKAGENAME = "packageName";
+ String PROPERTY_VERSION = "version";
+ String PROPERTY_DEPLOYMENTTIME = "deploymentTime";
+
ProcessDefinitionQuery nameLike(String name);
ProcessDefinitionQuery keyLike(String key);
- ProcessDefinitionQuery orderByNameAsc();
- ProcessDefinitionQuery orderByNameDesc();
+ ProcessDefinitionQuery orderAsc(String property);
+ ProcessDefinitionQuery orderDesc(String property);
- ProcessDefinitionQuery orderByKeyAsc();
- ProcessDefinitionQuery orderByKeyDesc();
-
- List<ProcessDefinition> list();
- List<ProcessDefinition> list(int firstResult, int maxResults);
+ List<ProcessDefinition> execute();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-23 13:44:13 UTC
(rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-23 17:02:45 UTC
(rev 3718)
@@ -31,11 +31,12 @@
*/
public interface TaskQuery {
- public static final String NAME = "name";
- public static final String ASSIGNEE = "assignee";
- public static final String CREATEDATE = "create-date";
- public static final String DUEDATE = "due-date";
- public static final String PRIORITY = "priority";
+ public static final String PROPERTY_NAME = "name";
+ public static final String PROPERTY_ASSIGNEE = "assignee";
+ public static final String PROPERTY_CREATEDATE = "create";
+ public static final String PROPERTY_DUEDATE = "dueDate";
+ public static final String PROPERTY_PRIORITY = "priority";
+ public static final String PROPERTY_PROGRESS = "progress";
TaskQuery assignee(String assignee);
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -1,74 +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.pvm.internal.cmd;
-
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HqlQueryOldCmd implements Command<List<Object>> {
-
- private static final long serialVersionUID = 1L;
-
- private static Log log = Log.getLog(HqlQueryOldCmd.class.getName());
-
- String hql;
- Integer firstResult;
- Integer maxResults;
-
- public HqlQueryOldCmd(String hql, Integer firstResult, Integer maxResults) {
- this.hql = hql;
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- }
-
- public List<Object> execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- if (session==null) {
- throw new JbpmException("no hibernate-session defined in
configuration");
- }
-
- Query query = session.createQuery(hql);
- if (firstResult!=null) {
- query.setFirstResult(firstResult);
- }
- if (maxResults!=null) {
- query.setMaxResults(maxResults);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("executing hql: ");
- log.debug(hql);
- }
-
- return query.list();
- }
-}
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,98 @@
+/*
+ * 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.pvm.internal.query;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AbstractQuery implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected CommandService commandService;
+ protected String orderByClause = null;
+ protected Page page = null;
+ protected boolean isWhereAdded = false;
+
+ public AbstractQuery(CommandService commandService) {
+ this.commandService = commandService;
+ }
+
+ protected abstract void applyParameters(Query query);
+
+ public abstract String hql();
+
+ /* reuse by copy and paste:
+ * (return type can't be changed)
+ public ConcreteQuery page(int firstResult, int maxResults) {
+ this.page = new Page{firstResult, maxResults};
+ return this;
+ }
+ */
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ String hql = hql();
+ Query query = session.createQuery(hql);
+ applyParameters(query);
+ applyPage(query);
+ return query.list();
+ }
+
+ protected void appendWhereClause(String whereClause, StringBuffer hql) {
+ if (isWhereAdded) {
+ hql.append(" and ");
+ } else {
+ hql.append("where ");
+ }
+ hql.append(whereClause);
+ }
+
+ protected void appendOrderByClause(StringBuffer hql) {
+ if (orderByClause!=null) {
+ hql.append("order by ");
+ hql.append(orderByClause);
+ }
+ }
+
+ protected void applyPage(Query query) {
+ if (page!=null) {
+ query.setFirstResult(page.firstResult);
+ query.setMaxResults(page.maxResults);
+ }
+ }
+
+ protected void addOrderByClause(String clause) {
+ if (orderByClause==null) {
+ orderByClause = clause;
+ } else {
+ orderByClause += ", " + clause;
+ }
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
(from rev 3707,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,124 @@
+/*
+ * 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.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionQueryImpl extends AbstractQuery implements ExecutionQuery {
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean onlyProcessInstances;
+ protected String processDefinitionNameLike;
+ protected String processDefinitionKeyLike;
+ protected String processDefinitionId;
+ protected String processInstanceId;
+
+ public ExecutionQueryImpl(CommandService commandService, boolean onlyProcessInstances)
{
+ super(commandService);
+ this.onlyProcessInstances = onlyProcessInstances;
+ }
+
+ public List<Execution> execute() {
+ return (List<Execution>) commandService.execute(this);
+ }
+
+ public String hql() {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select execution ");
+ hql.append("from ");
+ hql.append(ExecutionImpl.class.getName());
+ hql.append(" as execution ");
+
+ if (onlyProcessInstances) {
+ appendWhereClause("execution.processInstance.dbid = execution.dbid ",
hql);
+ }
+
+ if (processInstanceId!=null) {
+ appendWhereClause("execution.processInstance.id =
'"+processInstanceId+"' ", hql);
+ }
+
+ if (processDefinitionId!=null) {
+ appendWhereClause("e.processDefinition.id =
'"+processDefinitionId+"' ", hql);
+ }
+
+ if (processDefinitionNameLike!=null) {
+ appendWhereClause("e.processDefinition.name like
'"+processDefinitionNameLike+"' ", hql);
+ }
+
+ if (processDefinitionKeyLike!=null) {
+ appendWhereClause("e.processDefinition.key like
'"+processDefinitionKeyLike+"' ", hql);
+ }
+
+ appendOrderByClause(hql);
+
+ return hql.toString();
+ }
+
+ protected void applyParameters(Query query) {
+ }
+
+ public ExecutionQuery orderAsc(String property) {
+ addOrderByClause("e."+property+" asc");
+ return this;
+ }
+
+ public ExecutionQuery orderDesc(String property) {
+ addOrderByClause("e."+property+" desc");
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionId(String processDefinitionId) {
+ this.processDefinitionId = processDefinitionId;
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
+ this.processDefinitionKeyLike = processDefinitionKey;
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
+ this.processDefinitionNameLike = processDefinitionName;
+ return this;
+ }
+
+ public ExecutionQuery page(int firstResult, int maxResults) {
+ this.page = new Page(firstResult, maxResults);
+ return this;
+ }
+
+ public ExecutionQuery processInstanceId(String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ return this;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
(rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,41 @@
+/*
+ * 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.pvm.internal.query;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Page implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public int firstResult;
+ public int maxResults;
+
+ public Page(int firstResult, int maxResults) {
+ this.firstResult = firstResult;
+ this.maxResults = maxResults;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
(from rev 3707,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,95 @@
+/*
+ * 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.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryImpl extends AbstractQuery implements
ProcessDefinitionQuery {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String NEWLINE = System.getProperty("line.separator");
+
+ protected String nameLike;
+ protected String keyLike;
+
+ public ProcessDefinitionQueryImpl(CommandService commandService) {
+ super(commandService);
+ }
+
+ public List<ProcessDefinition> execute() {
+ return (List) commandService.execute(this);
+ }
+
+ public String hql() {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select pd ");
+ hql.append("from ");
+ hql.append(ProcessDefinitionImpl.class.getName());
+ hql.append(" as pd ");
+
+ if (nameLike!=null) {
+ appendWhereClause("pd.name like '"+nameLike+"'", hql);
+ }
+
+ if (keyLike!=null) {
+ appendWhereClause("pd.key like '"+keyLike+"'", hql);
+ }
+
+ appendOrderByClause(hql);
+
+ return hql.toString();
+ }
+
+ protected void applyParameters(Query query) {
+ }
+
+ public ProcessDefinitionQuery nameLike(String name) {
+ this.nameLike = name;
+ return this;
+ }
+
+ public ProcessDefinitionQuery keyLike(String key) {
+ this.keyLike = key;
+ return this;
+ }
+
+ public ProcessDefinitionQuery orderAsc(String property) {
+ addOrderByClause("pd."+property+" asc");
+ return this;
+ }
+
+ public ProcessDefinitionQuery orderDesc(String property) {
+ addOrderByClause("pd."+property+" desc");
+ return this;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -1,142 +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.pvm.internal.svc;
-
-import java.util.List;
-
-import org.jbpm.Execution;
-import org.jbpm.ExecutionQuery;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExecutionQueryImpl implements ExecutionQuery {
-
- private static final String NEWLINE = System.getProperty("line.separator");
-
- protected boolean onlyProcessInstances;
- protected String processDefinitionNameLike;
- protected String processDefinitionKeyLike;
- protected String processDefinitionId;
- protected String order;
- protected Integer firstResult;
- protected Integer maxResults;
-
- protected CommandService commandService;
-
- public ExecutionQueryImpl(CommandService commandService) {
- this.commandService = commandService;
- }
-
- protected String buildHql() {
- StringBuffer hql = new StringBuffer();
- hql.append("select e ");
- hql.append(NEWLINE);
- hql.append("from "+ExecutionImpl.class.getName()+" as e ");
- hql.append(NEWLINE);
-
- boolean where = false;
-
- if (processDefinitionId!=null) {
- where = true;
- hql.append("where e.processDefinition.id =
'"+processDefinitionId+"'");
- hql.append(NEWLINE);
- }
-
- if (processDefinitionNameLike!=null) {
- where = true;
- addWhereOrAnd(hql, where);
- hql.append("e.processDefinition.name like
'"+processDefinitionNameLike+"'");
- hql.append(NEWLINE);
- }
-
- if (processDefinitionKeyLike!=null) {
- where = true;
- addWhereOrAnd(hql, where);
- hql.append("e.processDefinition.key like
'"+processDefinitionKeyLike+"'");
- hql.append(NEWLINE);
- }
-
- if (order!=null) {
- hql.append("order by "+order);
- }
-
- return hql.toString();
- }
-
- private void addWhereOrAnd(StringBuffer hql, boolean where) {
- if (where) {
- hql.append(" and ");
- } else {
- hql.append("where ");
- }
- }
-
- protected List<Execution> execute() {
- String hql = buildHql();
- return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult,
maxResults));
- }
-
- public ExecutionQuery onlyProcessInstances() {
- this.onlyProcessInstances = true;
- return this;
- }
-
- public ExecutionQuery orderByKeyAsc() {
- order = "e.key asc";
- return this;
- }
-
- public ExecutionQuery orderByKeyDesc() {
- order = "e.key desc";
- return this;
- }
-
- public ExecutionQuery processDefinitionId(String processDefinitionId) {
- this.processDefinitionId = processDefinitionId;
- return this;
- }
-
- public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
- this.processDefinitionKeyLike = processDefinitionKey;
- return this;
- }
-
- public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
- this.processDefinitionNameLike = processDefinitionName;
- return this;
- }
-
- public List<Execution> list() {
- return execute();
- }
-
- public List<Execution> list(int firstResult, int maxResults) {
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- return execute();
- }
-}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -39,6 +39,7 @@
import org.jbpm.pvm.internal.cmd.SignalCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
+import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
/**
@@ -132,9 +133,13 @@
}
public ExecutionQuery createExecutionQuery() {
- return new ExecutionQueryImpl(commandService);
+ return new ExecutionQueryImpl(commandService, false);
}
+ public ExecutionQuery createProcessInstanceQuery() {
+ return new ExecutionQueryImpl(commandService, true);
+ }
+
public void deleteProcessInstance(String processInstanceId) {
commandService.execute(new DeleteProcessInstance(processInstanceId));
}
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -1,127 +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.pvm.internal.svc;
-
-import java.util.List;
-
-import org.jbpm.ProcessDefinition;
-import org.jbpm.ProcessDefinitionQuery;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessDefinitionQueryImpl implements ProcessDefinitionQuery {
-
- private static final String NEWLINE = System.getProperty("line.separator");
-
- protected String nameLike;
- protected String keyLike;
- protected String order;
- protected Integer firstResult;
- protected Integer maxResults;
-
- protected CommandService commandService;
-
- public ProcessDefinitionQueryImpl(CommandService commandService) {
- this.commandService = commandService;
- }
-
- protected String buildHql() {
- StringBuffer hql = new StringBuffer();
- hql.append("select pd ");
- hql.append(NEWLINE);
- hql.append("from "+ProcessDefinitionImpl.class.getName()+" as pd
");
- hql.append(NEWLINE);
-
- if (nameLike!=null) {
- hql.append("where pd.name like '"+nameLike+"'");
- hql.append(NEWLINE);
- }
-
- if (keyLike!=null) {
- if (nameLike==null) {
- hql.append("where ");
- } else {
- hql.append(" and ");
- hql.append(NEWLINE);
- }
- hql.append("pd.key like '"+keyLike+"'");
- hql.append(NEWLINE);
- }
-
- if (order!=null) {
- hql.append("order by "+order);
- }
-
- return hql.toString();
- }
-
- protected List<ProcessDefinition> execute() {
- String hql = buildHql();
- return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult,
maxResults));
- }
-
-
- public ProcessDefinitionQuery nameLike(String name) {
- nameLike = name;
- return this;
- }
-
- public ProcessDefinitionQuery keyLike(String key) {
- keyLike = key;
- return this;
- }
-
- public ProcessDefinitionQuery orderByKeyAsc() {
- order = "pd.key asc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByKeyDesc() {
- order = "pd.key desc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByNameAsc() {
- order = "pd.name asc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByNameDesc() {
- order = "pd.name desc";
- return this;
- }
-
- public List<ProcessDefinition> list() {
- return execute();
- }
-
- public List<ProcessDefinition> list(int firstResult, int maxResults) {
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- return execute();
- }
-}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -35,6 +35,7 @@
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionByIdCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionKeysCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsByKeyCmd;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
/** {@link ProcessService} implementation that delegates execution of the
* methods to a {@link CommandService}.
Deleted:
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
===================================================================
---
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -1,40 +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.task.internal.cmd;
-
-import java.util.List;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.Task;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HqlQueryCmd implements Command<List<Task>> {
-
- public List<Task> execute(Environment environment) throws Exception {
- return null;
- }
-
-}
Modified:
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -24,109 +24,78 @@
import java.util.List;
import org.hibernate.Query;
-import org.hibernate.Session;
import org.jbpm.TaskQuery;
-import org.jbpm.cmd.Command;
import org.jbpm.cmd.CommandService;
-import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.query.AbstractQuery;
+import org.jbpm.pvm.internal.query.Page;
import org.jbpm.task.Task;
/**
* @author Tom Baeyens
*/
-public class TaskQueryImpl implements TaskQuery, Command<List<Task>> {
+public class TaskQueryImpl extends AbstractQuery implements TaskQuery {
private static final long serialVersionUID = 1L;
private static final String UNASSIGNED = "unassigned";
- protected CommandService commandService;
-
protected String assignee = null;
- protected int[] page = null;
- protected boolean hasWhereClause = false;
- protected String orderByClause = null;
public TaskQueryImpl(CommandService commandService) {
- this.commandService = commandService;
+ super(commandService);
}
-
+
public TaskQuery assignee(String assignee) {
this.assignee = assignee;
- this.hasWhereClause = true;
return this;
}
public TaskQuery unassigned() {
this.assignee = UNASSIGNED;
- this.hasWhereClause = true;
return this;
}
public TaskQuery orderAsc(String property) {
- addOrderByClause(property, "asc");
+ orderByClause = "task."+property+" asc ";
return this;
}
public TaskQuery orderDesc(String property) {
- addOrderByClause(property, "desc");
+ orderByClause = "task."+property+" desc ";
return this;
}
- protected void addOrderByClause(String property, String direction) {
- if (orderByClause==null) {
- orderByClause = "";
- } else {
- orderByClause += ", ";
- }
- orderByClause += "task."+property+" "+direction;
- }
-
public TaskQuery page(int firstResult, int maxResults) {
- page = new int[]{firstResult, maxResults};
+ page = new Page(firstResult, maxResults);
return this;
}
public List<Task> execute() {
- return commandService.execute(this);
+ return (List<Task>) commandService.execute(this);
}
- public List<Task> execute(Environment environment){
+ protected void applyParameters(Query query) {
+ if ( (assignee!=UNASSIGNED) && (assignee!=null) ) {
+ query.setString("assignee", assignee);
+ }
+ }
+
+ public String hql() {
StringBuffer hql = new StringBuffer();
hql.append("select task ");
hql.append("from ");
hql.append(TaskImpl.class.getName());
hql.append(" as task ");
- if (hasWhereClause) {
- hql.append("where ");
- }
-
if (assignee==UNASSIGNED) {
- hql.append("task.assignee is null ");
+ appendWhereClause("task.assignee is null ", hql);
} else if (assignee!=null) {
- hql.append("task.assignee = :assignee ");
+ appendWhereClause("task.assignee = :assignee ", hql);
}
- if (orderByClause!=null) {
- hql.append("order by ");
- hql.append(orderByClause);
- }
+ appendOrderByClause(hql);
- Session session = environment.get(Session.class);
- String hqlText = hql.toString();
- Query query = session.createQuery(hqlText);
-
- if ( (assignee!=UNASSIGNED) && (assignee!=null) ) {
- query.setString("assignee", assignee);
- }
-
- if (page!=null) {
- query.setFirstResult(page[0]);
- query.setMaxResults(page[1]);
- }
-
- return query.list();
+ return hql.toString();
}
}
Modified:
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -91,7 +91,7 @@
public List<Task> getPersonalTaskList(String assignee, int firstResult, int
maxResults) {
return createTaskQuery()
.assignee(assignee)
- .orderDesc(TaskQuery.PRIORITY)
+ .orderDesc(TaskQuery.PROPERTY_PRIORITY)
.page(firstResult, maxResults)
.execute();
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-01-23
13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -174,4 +174,42 @@
return null;
}
+
+ public static Task getTask(List<Task> taskList, String taskName) {
+ for (Task task : taskList) {
+ if (taskName.equals(task.getName())) {
+ return task;
+ }
+ }
+ return null;
+ }
+
+ public static void assertContainsTask(List<Task> taskList, String taskName) {
+ if (getTask(taskList, taskName)==null) {
+ fail("tasklist doesn't contain task '"+taskName+"':
"+taskList);
+ }
+ }
+
+ public static Task getTask(List<Task> taskList, String taskName, String assignee)
{
+ for (Task task : taskList) {
+ if (taskName.equals(task.getName())) {
+ if (assignee==null) {
+ if (task.getAssignee()==null) {
+ return task;
+ }
+ } else {
+ if (assignee.equals(task.getAssignee())) {
+ return task;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void assertContainsTask(List<Task> taskList, String taskName,
String assignee) {
+ if (getTask(taskList, taskName, assignee)==null) {
+ fail("tasklist doesn't contain task '"+taskName+"' for
assignee '"+assignee+"': "+taskList);
+ }
+ }
}
Added:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,50 @@
+/*
+ * 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.execution;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionTest extends DbTestCase {
+
+ public void testFindExecutionById() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p");
+
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
(from rev 3685,
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java)
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,254 @@
+/*
+ * 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.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalExecutionTest extends DbTestCase {
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL",
"82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL",
"82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL",
"82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL",
"82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL",
"82436");
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ execution = executionService.signalExecutionById("ICL/82436", variables);
+
+ assertNotNull(execution);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getActivityName());
+
+ Map<String,Object> expectedVariables = new HashMap<String,
Object>(variables);
+ Set<String> expectedVariableNames = new
HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new
HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p");
+ execution = executionService.signalExecutionById(execution.getId());
+ assertEquals("a", execution.getActivityName());
+ }
+
+ /*
+
+ public void testSetVariable()
+ {
+ Execution execution = startExecution();
+
+ String executionId = execution.getId();
+ // set variable a to value text
+ executionService.setVariable(executionId, "a", "text");
+ // check if we can read that value back
+ assertEquals("text", executionService.getVariable(executionId,
"a"));
+
+ // overwrite the value of variable a with another text
+ executionService.setVariable(executionId, "a", "another text");
+ // see if we can read another text back from the variable
+ assertEquals("another text", executionService.getVariable(executionId,
"a"));
+ }
+
+ public void testSetVariables()
+ {
+ Execution execution = startExecution();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // set variables in bulk by providing a map
+ executionService.setVariables(execution.getId(), variables);
+
+ Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add("a");
+ variableNames.add("b");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
+
+ // now set variables b and c with a map
+ variables = new HashMap<String, Object>();
+ variables.put("b", new Integer(99));
+ variables.put("c", "another text");
+
+ // this should leave a untouched, overwrite b and create c
+ executionService.setVariables(execution.getId(), variables);
+
+ // update the expected map
+ expected.put("b", new Integer(99));
+ expected.put("c", "another text");
+
+ // add c to the variable names that should be collected
+ variableNames.add("c");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the
processes 'ultimate seduction' and
+ * 'publish book'
+ void deployMultipleVersionsOfProcesses()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").activity("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish
book").key("PBO").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+ }
+
+ Execution startExecution()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").activity("initial").initial().behaviour(WaitState.class)
+ .done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ return executionService.startExecutionByName("nuclear fusion");
+ }
+
+ */
+}
Added:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,219 @@
+/*
+ * 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.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionTest extends DbTestCase {
+
+ public void testStartNewExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+ public void testStartNewExecutionInLatestProcessDefinition() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("b", execution.getActivityName());
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ // create variables that are fed into the process before it starts executing
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // feed the variables in
+ Execution execution = executionService.startExecutionByKey("ICL",
variables);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getActivityName());
+
+ // verify that the variables are actually set
+ assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
+ assertEquals("text", executionService.getVariable(executionId,
"b"));
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue(execution.getId().startsWith("ICL/"));
+ }
+
+ public void testStartNewProcessInstanceWithAKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL",
"one");
+
+ assertNotNull(execution);
+ assertEquals("ICL/one", execution.getId());
+ }
+
+ public void testStartNewProcessInstanceWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Execution execution = executionService.startExecutionByKey("ICL",
variables);
+
+ String executionId = execution.getId();
+
+ assertNotNull(execution);
+
+ Map<String,Object> expectedVariables = new HashMap<String,
Object>(variables);
+ Set<String> expectedVariableNames = new
HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new
HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+ public void testStartExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition =
processService.findProcessDefinitionsByKey("ICL").get(0);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startExecutionById("ICL:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("a", execution.getActivityName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertNull(execution.getKey());
+ // if there is no user defined name or key specified in the execution,
+ // the default id generator will create a unique id like this:
processDefinitionId/execution.dbid
+ assertTrue(execution.getId().startsWith("ICL/"));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(4));
+ }
+
+ public void testStartExecutionByIdWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startExecutionById("ICL:1",
variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
+ assertEquals("text", executionService.getVariable(executionId,
"b"));
+ }
+}
Property changes on:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java
(from rev 3641,
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java)
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,36 @@
+/*
+ * 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.mgmt;
+
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends DbTestCase {
+
+ public void testGetJobs() {
+ assertEquals(0, managementService.getTimers(0, 10).size());
+ assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+
+}
Added:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,139 @@
+/*
+ * 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.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryTest extends DbTestCase {
+
+ public void testQueryProcessDefinitionsEmpty() {
+ List<ProcessDefinition> processDefinitions = processService
+ .createProcessDefinitionQuery()
+ .execute();
+
+ 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 =
processService.createProcessDefinitionQuery()
+ .nameLike("%make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .execute();
+
+ 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 =
processService.createProcessDefinitionQuery()
+ .keyLike("make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+
+ assertEquals("make_friends:3", processDefinitions.get(0).getId());
+ assertEquals("make_friends:2", processDefinitions.get(1).getId());
+ assertEquals("make_friends:1", processDefinitions.get(2).getId());
+ assertEquals("make_print:1", processDefinitions.get(3).getId());
+ }
+}
Property changes on:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
(from rev 3682,
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java)
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,356 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceTest extends DbTestCase {
+
+ public void testProcessWithNameOnly() {
+ ProcessDefinition processDefinition = deployJpdlXmlString(
+ "<process name='Insurance claim'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("Insurance_claim", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Insurance_claim:1", processDefinition.getId());
+ }
+
+ public void testProcessWithNameAndKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition =
processService.findLatestProcessDefinitionByKey("ICL");
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("ICL", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("ICL:1", processDefinition.getId());
+ }
+
+ // interface methods ////////////////////////////////////////////////////////
+
+ public void testFindProcessDefinitionKeys() {
+ deployMultipleVersionsOfProcesses();
+
+ List<String> processKeys = processService.findProcessDefinitionKeys();
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("nuclear_fusion");
+ expected.add("publish_book");
+ expected.add("ultimate_seduction");
+
+ assertEquals(expected, processKeys);
+ }
+
+
+ public void testFindProcessByKey() {
+ deployJpdlXmlString(
+ "<process name='Name with spaces'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition =
processService.findLatestProcessDefinitionByKey("Name_with_spaces");
+ assertNotNull(processDefinition);
+ assertEquals("Name with spaces", processDefinition.getName());
+ assertEquals("Name_with_spaces", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Name_with_spaces:1", processDefinition.getId());
+ }
+
+ public void testFindProcessDefinitions() {
+ deployMultipleVersionsOfProcesses();
+
+ List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitionsByKey("nuclear_fusion");
+ assertNotNull(processDefinitions);
+
+ assertEquals("expected 3 but was " + processDefinitions.size() + ":
" + processDefinitions, 3, processDefinitions.size());
+ assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+ assertEquals(3, processDefinitions.get(0).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+ assertEquals(2, processDefinitions.get(1).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+ assertEquals(1, processDefinitions.get(2).getVersion());
+ }
+
+ public void testFindLatestProcessDefinition() {
+ deployMultipleVersionsOfProcesses();
+
+ ProcessDefinition retrieved =
processService.findLatestProcessDefinitionByKey("nuclear_fusion");
+ assertNotNull(retrieved);
+
+ assertEquals(3, retrieved.getVersion());
+ assertEquals("nuclear fusion", retrieved.getName());
+ assertEquals("nuclear_fusion", retrieved.getKey());
+ }
+
+ public void testFindProcessDefinitionById() {
+ deployJpdlXmlString(
+ "<process name='given' version='33'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ ProcessDefinition processDefinition =
processService.findProcessDefinitionById("given:33");
+ assertNotNull(processDefinition);
+ assertEquals("given", processDefinition.getName());
+ assertEquals(33, processDefinition.getVersion());
+ }
+
+ public void testDeleteProcessDefinition() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start />" +
+ "</process>")
+ .deploy();
+
+ // delete it
+ processService.deleteProcessDefinition("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionAndInstances() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>")
+ .deploy();
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ processService.deleteProcessDefinitionAndInstances("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+ assertEquals(0, executionService.createExecutionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionButNotInstances() {
+ deployJpdlXmlString(
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ try {
+ processService.deleteProcessDefinition("deleteme:33");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("still 4 process instances for process definition
deleteme:33", e.getMessage());
+ }
+ }
+
+ // various other aspects ////////////////////////////////////////////////////
+
+ public void testAutomaticVersioning() {
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look it up again
+ List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitionsByKey("versionme");
+ assertNotNull(processDefinitions);
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // and check that automatically assigned version starts with 1
+ assertEquals(1, processDefinition.getVersion());
+
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look them up again
+ processDefinitions =
processService.findProcessDefinitionsByKey("versionme");
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+ // and check that automatically assigned version starts with 1
+ assertEquals(2, processDefinitions.get(0).getVersion());
+ assertEquals(1, processDefinitions.get(1).getVersion());
+ }
+
+ public void testUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitionsByKey("takethis");
+ assertNotNull(processDefinitions);
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // verify that the user specified version was used
+ // (and not overwritten by an automatically assigned versioning)
+ assertEquals(234, processDefinition.getVersion());
+ }
+
+ public void testDuplicateUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ try {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("process 'takethis:234' already exists",
e.getMessage());
+ }
+ }
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the
processes 'ultimate seduction' and
+ * 'publish book'
+ */
+ void deployMultipleVersionsOfProcesses() {
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='publish book'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+ }
+
+ public void testMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start>" +
+ " <flow to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertEquals("end", execution.getActivityName());
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+
+ public void testMostMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+}
Copied:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
(from rev 3701,
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java)
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,78 @@
+/*
+ * 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.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskCreateUpdateDeleteTest extends DbTestCase {
+
+ public void testNewTask() {
+ // creation of a new non-persisted task
+ Task task = taskService.newTask();
+ task = taskService.getTask(task.getId());
+ assertNull(task);
+ }
+
+ public void testGenerateTaskId() {
+ Task task = taskService.newTask();
+ String taskId = task.getId();
+ assertNull("expected null, but was " + taskId, taskId);
+ // save task to generate identifier
+ saveTask(task);
+ assertNotNull(task.getId());
+ }
+
+ public void testSaveTask() {
+ Task task = taskService.newTask();
+ saveTask(task);
+ String taskId = task.getId();
+ // task was made persistent
+ task = taskService.getTask(taskId);
+ assertNotNull("expected non-null task", task);
+ // make some change
+ Date dueDate = new Date();
+ task.setDueDate(dueDate);
+ taskService.saveTask(task);
+ // verify change is applied
+ task = taskService.getTask(taskId);
+ assertEquals(dueDate, task.getDueDate());
+ }
+
+ public void testDeleteTask() {
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+ String taskId = task.getId();
+
+ // task was made persistent
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ // delete task and verify it does not exist
+ taskService.deleteTask(taskId);
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+}
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -23,7 +23,6 @@
import java.util.List;
-import org.jbpm.TaskQuery;
import org.jbpm.task.Task;
import org.jbpm.test.DbTestCase;
@@ -104,6 +103,7 @@
List<Task> taskList = taskService.getPersonalTaskList("joesmoe", 0,
10);
assertNotNull(taskList);
+ // default sort order is based on the priority
assertEquals("make profit", taskList.get(0).getName());
assertEquals("get good idea", taskList.get(1).getName());
assertEquals("find venture capital", taskList.get(2).getName());
@@ -112,88 +112,4 @@
assertEquals(5, taskList.size());
}
-
- public void testSimplestTaskQuery() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(4);
- saveTask(task);
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .execute();
- assertNotNull(taskList);
-
- assertContainsTask(taskList, "do laundry");
- assertContainsTask(taskList, "change dyper");
- assertContainsTask(taskList, "start new business");
- assertContainsTask(taskList, "find venture capital");
-
- assertEquals(4, taskList.size());
- }
-
- public void testSimplestTaskQuerySortBy() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(7);
- saveTask(task);
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .orderAsc(TaskQuery.NAME)
- .execute();
- assertNotNull(taskList);
-
- assertEquals("change dyper", taskList.get(0).getName());
- assertEquals("do laundry", taskList.get(1).getName());
- assertEquals("find venture capital", taskList.get(2).getName());
- assertEquals("start new business", taskList.get(3).getName());
-
- assertEquals(4, taskList.size());
- }
-
- public void assertContainsTask(List<Task> taskList, String taskName) {
- for (Task task : taskList) {
- if (taskName.equals(task.getName())) {
- return;
- }
- }
- fail("tasklist doesn't contain task '"+taskName+"':
"+taskList);
- }
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -0,0 +1,111 @@
+/*
+ * 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.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryTest extends DbTestCase {
+
+ public void testSimplestTaskQuery() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(4);
+ saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .execute();
+ assertNotNull(taskList);
+
+ assertContainsTask(taskList, "do laundry");
+ assertContainsTask(taskList, "change dyper");
+ assertContainsTask(taskList, "start new business");
+ assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(4, taskList.size());
+ }
+
+ public void testSimplestTaskQuerySortBy() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(7);
+ saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .orderAsc(TaskQuery.PROPERTY_NAME)
+ .execute();
+ assertNotNull(taskList);
+
+ assertEquals("change dyper", taskList.get(0).getName());
+ assertEquals("do laundry", taskList.get(1).getName());
+ assertEquals("find venture capital", taskList.get(2).getName());
+ assertEquals("start new business", taskList.get(3).getName());
+
+ assertEquals(4, taskList.size());
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java 2009-01-23
13:44:13 UTC (rev 3717)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java 2009-01-23
17:02:45 UTC (rev 3718)
@@ -1,78 +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.util.Date;
-
-import org.jbpm.task.Task;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceTest extends DbTestCase {
-
- public void testNewTask() {
- // creation of a new non-persisted task
- Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
- assertNull(task);
- }
-
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveTask(task);
- assertNotNull(task.getId());
- }
-
- public void testSaveTask() {
- Task task = taskService.newTask();
- saveTask(task);
- String taskId = task.getId();
- // task was made persistent
- task = taskService.getTask(taskId);
- assertNotNull("expected non-null task", task);
- // make some change
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- taskService.saveTask(task);
- // verify change is applied
- task = taskService.getTask(taskId);
- assertEquals(dueDate, task.getDueDate());
- }
-
- public void testDeleteTask() {
- Task task = taskService.newTask();
- taskService.saveTask(task);
- String taskId = task.getId();
-
- // task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- // delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-}
Modified: jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 13:44:13
UTC (rev 3717)
+++ jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 17:02:45
UTC (rev 3718)
@@ -22,7 +22,7 @@
org.hibernate.level=INFO
org.hibernate.cfg.HbmBinder.level=SEVERE
org.hibernate.cfg.SettingsFactory.level=SEVERE
-# org.hibernate.SQL.level=FINEST
-# org.hibernate.type.level=FINEST
+org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
# org.hibernate.transaction.level=FINEST