This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 5cc6f09ce80b8efc96986f4317acaf621fa0588e Author: juanpablo <[email protected]> AuthorDate: Thu Apr 23 21:52:19 2020 +0200 move o.a.w.workflow.Workflow#TIME_NOT_SET to o.a.w.workflow.Step#TIME_NOT_SET --- .../org/apache/wiki/workflow/AbstractStep.java | 4 ++-- .../main/java/org/apache/wiki/workflow/Step.java | 7 ++++-- .../java/org/apache/wiki/workflow/Workflow.java | 11 ++++----- .../org/apache/wiki/workflow/WorkflowBuilder.java | 3 +-- .../apache/wiki/workflow/SimpleDecisionTest.java | 8 +++---- .../java/org/apache/wiki/workflow/TaskTest.java | 28 +++++++++++----------- .../org/apache/wiki/workflow/WorkflowTest.java | 18 +++++++------- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/AbstractStep.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/AbstractStep.java index 7045438..e545990 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/AbstractStep.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/AbstractStep.java @@ -70,9 +70,9 @@ public abstract class AbstractStep implements Step { */ protected AbstractStep( final String messageKey ) { m_started = false; - m_start = Workflow.TIME_NOT_SET; + m_start = Step.TIME_NOT_SET; m_completed = false; - m_end = Workflow.TIME_NOT_SET; + m_end = Step.TIME_NOT_SET; m_errors = new ArrayList<>(); m_outcome = Outcome.STEP_CONTINUE; m_key = messageKey; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Step.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Step.java index 7ed8561..50e3327 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Step.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Step.java @@ -53,6 +53,9 @@ import java.util.List; */ public interface Step extends Serializable { + /** Time value: the start or end time has not been set. */ + public static final Date TIME_NOT_SET = new Date( 0 ); + /** * Adds a successor Step to this one, which will be triggered by a supplied Outcome. Implementations should respect the order in which * Outcomes are added; {@link #getAvailableOutcomes()} should return them in the same order they were added. @@ -105,7 +108,7 @@ public interface Step extends Serializable { Principal getActor(); /** - * The end time for this Step. This value should be set when the step completes. Returns {@link Workflow#TIME_NOT_SET} if not completed + * The end time for this Step. This value should be set when the step completes. Returns {@link #TIME_NOT_SET} if not completed * yet. * * @return the end time @@ -136,7 +139,7 @@ public interface Step extends Serializable { Outcome getOutcome(); /** - * The start time for this Step. Returns {@link Workflow#TIME_NOT_SET} if not started yet. + * The start time for this Step. Returns {@link #TIME_NOT_SET} if not started yet. * * @return the start time */ diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java index 63d2ca2..7657b27 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java @@ -164,9 +164,6 @@ public class Workflow implements Serializable { private static final long serialVersionUID = 5228149040690660032L; - /** Time value: the start or end time has not been set. */ - public static final Date TIME_NOT_SET = new Date( 0 ); - /** ID value: the workflow ID has not been set. */ public static final int ID_NOT_SET = 0; @@ -317,7 +314,7 @@ public class Workflow implements Serializable { /** * The end time for this Workflow, expressed as a system time number. This value is equal to the end-time value returned by the final - * Step's {@link Step#getEndTime()} method, if the workflow has completed. Otherwise, this method returns {@link #TIME_NOT_SET}. + * Step's {@link Step#getEndTime()} method, if the workflow has completed. Otherwise, this method returns {@link Step#TIME_NOT_SET}. * * @return the end time */ @@ -328,7 +325,7 @@ public class Workflow implements Serializable { return last.getEndTime(); } } - return TIME_NOT_SET; + return Step.TIME_NOT_SET; } /** @@ -391,13 +388,13 @@ public class Workflow implements Serializable { /** * The start time for this Workflow, expressed as a system time number. This value is equal to the start-time value returned by the * first Step's {@link Step#getStartTime()} method, if the workflow has started already. Otherwise, this method returns - * {@link #TIME_NOT_SET}. + * {@link Step#TIME_NOT_SET}. * * @return the start time */ public final Date getStartTime() { - return isStarted() ? m_firstStep.getStartTime() : TIME_NOT_SET; + return isStarted() ? m_firstStep.getStartTime() : Step.TIME_NOT_SET; } /** diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java index 95afafb..9a8e7f2 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java @@ -115,8 +115,7 @@ public final class WorkflowBuilder { // If Decision required, create a simple approval workflow if ( decisionRequired ) { - // Look up the name of the approver (user or group) listed in jspwiki.properties; - // approvals go to the approver's decision cue + // Look up the name of the approver (user or group) listed in jspwiki.properties; approvals go to the approver's decision queue final Principal approverPrincipal = mgr.getApprover( workflowApproverKey ); final Decision decision = new SimpleDecision( workflow, decisionKey, approverPrincipal ); diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/SimpleDecisionTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/SimpleDecisionTest.java index 409e40d..5bf3539 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/SimpleDecisionTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/SimpleDecisionTest.java @@ -119,10 +119,10 @@ public class SimpleDecisionTest { @Test public void testGetEndTime() throws WikiException { - Assertions.assertEquals( Workflow.TIME_NOT_SET, m_decision.getEndTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, m_decision.getEndTime() ); m_decision.start(); m_decision.decide( Outcome.DECISION_APPROVE ); - Assertions.assertTrue( ( Workflow.TIME_NOT_SET != m_decision.getEndTime() ) ); + Assertions.assertTrue( ( Step.TIME_NOT_SET != m_decision.getEndTime() ) ); } @Test @@ -140,10 +140,10 @@ public class SimpleDecisionTest { @Test public void testGetStartTime() throws WikiException { - Assertions.assertEquals( Workflow.TIME_NOT_SET, m_decision.getStartTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, m_decision.getStartTime() ); m_decision.start(); m_decision.decide( Outcome.DECISION_APPROVE ); - Assertions.assertTrue( ( Workflow.TIME_NOT_SET != m_decision.getStartTime() ) ); + Assertions.assertTrue( ( Step.TIME_NOT_SET != m_decision.getStartTime() ) ); } @Test diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/TaskTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/TaskTest.java index 0eebdb1..6e330c0 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/TaskTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/TaskTest.java @@ -18,15 +18,15 @@ */ package org.apache.wiki.workflow; -import java.util.Collection; -import java.util.List; - import org.apache.wiki.api.exceptions.WikiException; import org.apache.wiki.auth.WikiPrincipal; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.Collection; +import java.util.List; + public class TaskTest { @@ -38,7 +38,7 @@ public class TaskTest { private static final long serialVersionUID = 1L; - public NormalTask(Workflow workflow) + public NormalTask( final Workflow workflow) { super(workflow, "task.normal"); } @@ -54,7 +54,7 @@ public class TaskTest { private static final long serialVersionUID = 1L; - public ErrorTask(Workflow workflow) + public ErrorTask( final Workflow workflow) { super(workflow, "task.error"); } @@ -86,11 +86,11 @@ public class TaskTest public void testSuccessors() { // If task finishes normally, branch to a decision (d1) - Step d1 = new SimpleDecision(m_workflow, "decision1.key", new WikiPrincipal("Actor1")); + final Step d1 = new SimpleDecision(m_workflow, "decision1.key", new WikiPrincipal("Actor1")); m_task.addSuccessor(Outcome.STEP_COMPLETE, d1); // If the task aborts, branch to an alternate decision (d2) - Step d2 = new SimpleDecision(m_workflow, "decision2.key", new WikiPrincipal("Actor2")); + final Step d2 = new SimpleDecision(m_workflow, "decision2.key", new WikiPrincipal("Actor2")); m_task.addSuccessor(Outcome.STEP_ABORT, d2); Assertions.assertEquals(d1, m_task.getSuccessor(Outcome.STEP_COMPLETE)); @@ -110,7 +110,7 @@ public class TaskTest m_task.addError("Error deciding something."); m_task.addError("Error deciding something else."); - List< String > errors = m_task.getErrors(); + final List< String > errors = m_task.getErrors(); Assertions.assertEquals(2, errors.size()); Assertions.assertEquals("Error deciding something.", errors.get(0)); Assertions.assertEquals("Error deciding something else.", errors.get(1)); @@ -119,7 +119,7 @@ public class TaskTest @Test public void testAvailableOutcomes() { - Collection< Outcome > outcomes = m_task.getAvailableOutcomes(); + final Collection< Outcome > outcomes = m_task.getAvailableOutcomes(); Assertions.assertFalse(outcomes.contains(Outcome.DECISION_APPROVE)); Assertions.assertFalse(outcomes.contains(Outcome.DECISION_DENY)); Assertions.assertFalse(outcomes.contains(Outcome.DECISION_HOLD)); @@ -131,10 +131,10 @@ public class TaskTest @Test public void testGetEndTime() throws WikiException { - Assertions.assertEquals(Workflow.TIME_NOT_SET, m_task.getEndTime()); + Assertions.assertEquals(Step.TIME_NOT_SET, m_task.getEndTime()); m_task.start(); m_task.setOutcome(m_task.execute()); - Assertions.assertTrue((Workflow.TIME_NOT_SET != m_task.getEndTime())); + Assertions.assertTrue((Step.TIME_NOT_SET != m_task.getEndTime())); } @Test @@ -162,10 +162,10 @@ public class TaskTest @Test public void testGetStartTime() throws WikiException { - Assertions.assertEquals(Workflow.TIME_NOT_SET, m_task.getStartTime()); + Assertions.assertEquals(Step.TIME_NOT_SET, m_task.getStartTime()); m_task.start(); m_task.execute(); - Assertions.assertTrue((Workflow.TIME_NOT_SET != m_task.getStartTime())); + Assertions.assertTrue((Step.TIME_NOT_SET != m_task.getStartTime())); } @Test @@ -199,7 +199,7 @@ public class TaskTest { m_task.start(); } - catch (IllegalStateException e) + catch ( final IllegalStateException e) { // Swallow return; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java index d600e0b..84b7444 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java @@ -77,8 +77,8 @@ public class WorkflowTest { Assertions.assertEquals( Workflow.ID_NOT_SET, w.getId() ); Assertions.assertEquals( new WikiPrincipal( "Owner1" ), w.getOwner() ); Assertions.assertEquals( Workflow.CREATED, w.getCurrentState() ); - Assertions.assertEquals( Workflow.TIME_NOT_SET, w.getStartTime() ); - Assertions.assertEquals( Workflow.TIME_NOT_SET, w.getEndTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, w.getStartTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, w.getEndTime() ); } @Test @@ -118,7 +118,7 @@ public class WorkflowTest { public void testGetMessageArgObjects() { // Try passing some valid object types: Date, Number w.addMessageArgument( new Date() ); - w.addMessageArgument( Integer.valueOf( 1 ) ); + w.addMessageArgument( 1 ); w.addMessageArgument( 2d ); w.addMessageArgument( new BigDecimal( "3.14" ) ); @@ -303,23 +303,23 @@ public class WorkflowTest { @Test public void testGetStartTime() throws WikiException { // Start time should be not be set until we start the workflow - Assertions.assertEquals( Workflow.TIME_NOT_SET, w.getStartTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, w.getStartTime() ); w.start(); - Assertions.assertNotSame( Workflow.TIME_NOT_SET, w.getStartTime() ); + Assertions.assertNotSame( Step.TIME_NOT_SET, w.getStartTime() ); final Decision d = ( Decision )w.getCurrentStep(); d.decide( Outcome.DECISION_APPROVE ); - Assertions.assertNotSame( Workflow.TIME_NOT_SET, w.getStartTime() ); + Assertions.assertNotSame( Step.TIME_NOT_SET, w.getStartTime() ); } @Test public void testGetEndTime() throws WikiException { // End time should be not set until we finish all 3 steps - Assertions.assertEquals( Workflow.TIME_NOT_SET, w.getEndTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, w.getEndTime() ); w.start(); - Assertions.assertEquals( Workflow.TIME_NOT_SET, w.getEndTime() ); + Assertions.assertEquals( Step.TIME_NOT_SET, w.getEndTime() ); final Decision d = ( Decision )w.getCurrentStep(); d.decide( Outcome.DECISION_APPROVE ); - Assertions.assertNotSame( Workflow.TIME_NOT_SET, w.getEndTime() ); + Assertions.assertNotSame( Step.TIME_NOT_SET, w.getEndTime() ); } @Test
