Repository: commons-scxml Updated Branches: refs/heads/master 9fb7a6368 -> 05e94b822
http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Param.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/Param.java b/src/main/java/org/apache/commons/scxml2/model/Param.java index 23eaab2..327b828 100644 --- a/src/main/java/org/apache/commons/scxml2/model/Param.java +++ b/src/main/java/org/apache/commons/scxml2/model/Param.java @@ -17,7 +17,6 @@ package org.apache.commons.scxml2.model; import java.io.Serializable; -import java.util.Map; /** * The class in this SCXML object model that corresponds to the http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/PayloadBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/PayloadBuilder.java b/src/main/java/org/apache/commons/scxml2/model/PayloadBuilder.java index dfd7c82..8ba5cf7 100644 --- a/src/main/java/org/apache/commons/scxml2/model/PayloadBuilder.java +++ b/src/main/java/org/apache/commons/scxml2/model/PayloadBuilder.java @@ -93,13 +93,12 @@ public class PayloadBuilder { * @param evaluator the evaluator to evaluate/lookup the data * @param paramsList the list of params * @param payload the payload data map to be updated - * @throws ModelException if this action has not an EnterableState as parent * @throws SCXMLExpressionException if a malformed or invalid expression is evaluated - * @see PayloadProvider#addToPayload(String, Object, java.util.Map) + * @see PayloadBuilder#addToPayload(String, Object, java.util.Map) */ public static void addParamsToPayload(final Context ctx, final Evaluator evaluator, final List<Param> paramsList, Map<String, Object> payload) - throws ModelException, SCXMLExpressionException { + throws SCXMLExpressionException { if (!paramsList.isEmpty()) { Object paramValue; for (Param p : paramsList) { @@ -128,14 +127,13 @@ public class PayloadBuilder { * @param errorReporter to report errors * @param namelist the namelist * @param payload the payload data map to be updated - * @throws ModelException if this action has not an EnterableState as parent * @throws SCXMLExpressionException if a malformed or invalid expression is evaluated - * @see PayloadProvider#addToPayload(String, Object, java.util.Map) + * @see PayloadBuilder#addToPayload(String, Object, java.util.Map) */ public static void addNamelistDataToPayload(final EnterableState parentState, final Context ctx, final Evaluator evaluator, final ErrorReporter errorReporter, final String namelist, Map<String, Object> payload) - throws ModelException, SCXMLExpressionException { + throws SCXMLExpressionException { if (namelist != null) { StringTokenizer tkn = new StringTokenizer(namelist); while (tkn.hasMoreTokens()) { http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/PayloadProvider.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/PayloadProvider.java b/src/main/java/org/apache/commons/scxml2/model/PayloadProvider.java deleted file mode 100644 index 84ae749..0000000 --- a/src/main/java/org/apache/commons/scxml2/model/PayloadProvider.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.scxml2.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * A <code>PayloadProvider</code> is an element in the SCXML document - * that can provide payload data for an event or an external process. - */ -public abstract class PayloadProvider extends Action { - - /** - * Payload data values wrapper list needed when multiple variable entries use the same names. - * The multiple values are then wrapped in a list. The PayloadBuilder uses this 'marker' list - * to distinguish between entry values which are a list themselves and the wrapper list. - */ - private static class DataValueList extends ArrayList { - } - - /** - * Adds an attribute and value to a payload data map. - * <p> - * As the SCXML specification allows for multiple payload attributes with the same name, this - * method takes care of merging multiple values for the same attribute in a list of values. - * </p> - * <p> - * Furthermore, as modifications of payload data on either the sender or receiver side should affect the - * the other side, attribute values (notably: {@link Node} value only for now) is cloned first before being added - * to the payload data map. This includes 'nested' values within a {@link NodeList}, {@link List} or {@link Map}. - * </p> - * @param attrName the name of the attribute to add - * @param attrValue the value of the attribute to add - * @param payload the payload data map to be updated - */ - @SuppressWarnings("unchecked") - protected void addToPayload(final String attrName, final Object attrValue, Map<String, Object> payload) { - DataValueList valueList = null; - Object value = payload.get(attrName); - if (value != null) { - if (value instanceof DataValueList) { - valueList = (DataValueList)value; - } - else { - valueList = new DataValueList(); - valueList.add(value); - payload.put(attrName, valueList); - } - } - value = attrValue; - if (value instanceof List) { - if (valueList == null) { - valueList = new DataValueList(); - payload.put(attrName, valueList); - } - valueList.addAll((List)value); - } - else if (valueList != null) { - valueList.add(value); - } - else { - payload.put(attrName, value); - } - } -} http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/SCXML.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/SCXML.java b/src/main/java/org/apache/commons/scxml2/model/SCXML.java index 062289c..8610d99 100644 --- a/src/main/java/org/apache/commons/scxml2/model/SCXML.java +++ b/src/main/java/org/apache/commons/scxml2/model/SCXML.java @@ -48,12 +48,6 @@ public class SCXML implements Serializable, Observable { private static final Integer SCXML_OBSERVABLE_ID = 0; /** - * The xmlns attribute on the root <smxml> element. - * This must match XMLNS above. - */ - private String xmlns; - - /** * The SCXML version of this document. */ private String version; @@ -113,13 +107,13 @@ public class SCXML implements Serializable, Observable { /** * The immediate child targets of this SCXML document root. */ - private List<EnterableState> children; + private final List<EnterableState> children; /** * A global map of all States and Parallels associated with this * state machine, keyed by their id. */ - private Map<String, TransitionTarget> targets; + private final Map<String, TransitionTarget> targets; /** * The XML namespaces defined on the SCXML document root node, @@ -137,8 +131,8 @@ public class SCXML implements Serializable, Observable { * Constructor. */ public SCXML() { - this.children = new ArrayList<EnterableState>(); - this.targets = new HashMap<String, TransitionTarget>(); + this.children = new ArrayList<>(); + this.targets = new HashMap<>(); } /** @@ -305,24 +299,6 @@ public class SCXML implements Serializable, Observable { } /** - * Get the xmlns of this SCXML document. - * - * @return Returns the xmlns. - */ - public final String getXmlns() { - return xmlns; - } - - /** - * Set the xmlns of this SCXML document. - * - * @param xmlns The xmlns to set. - */ - public final void setXmlns(final String xmlns) { - this.xmlns = xmlns; - } - - /** * Get the namespace definitions specified on the SCXML element. * May be <code>null</code>. * http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Send.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/Send.java b/src/main/java/org/apache/commons/scxml2/model/Send.java index 32d9d23..5bd7bcc 100644 --- a/src/main/java/org/apache/commons/scxml2/model/Send.java +++ b/src/main/java/org/apache/commons/scxml2/model/Send.java @@ -434,7 +434,7 @@ public class Send extends Action implements ContentContainer, ParamsContainer { } else if (content != null) { if (content.getExpr() != null) { - Object evalResult = null; + Object evalResult; try { evalResult = eval.eval(ctx, content.getExpr()); } catch (SCXMLExpressionException e) { http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java b/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java index 4334b7f..20b58d2 100644 --- a/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java +++ b/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java @@ -17,7 +17,6 @@ package org.apache.commons.scxml2.model; import java.util.HashSet; -import java.util.Map; import java.util.Set; /** @@ -67,7 +66,7 @@ public class SimpleTransition extends Executable implements Observable { * If multiple state(s) are specified, they must belong to the regions * of the same parallel. */ - private Set<TransitionTarget> targets; + private final Set<TransitionTarget> targets; /** * The transition target ID @@ -79,7 +78,7 @@ public class SimpleTransition extends Executable implements Observable { */ public SimpleTransition() { super(); - this.targets = new HashSet<TransitionTarget>(); + this.targets = new HashSet<>(); } private boolean isCompoundStateParent(TransitionalState ts) { @@ -151,8 +150,8 @@ public class SimpleTransition extends Executable implements Observable { * <p> * Otherwise it is treated (for determining its exit states) as if it is of type {@link TransitionType#external} * </p> - * @see <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions"> - * http://www.w3.org/TR/2014/CR-scxml-20140313/#SelectingTransitions</a> + * @see <a href="https://www.w3.org/TR/2015/REC-scxml-20150901/#SelectingTransitions"> + * https://www.w3.org/TR/2015/REC-scxml-20150901/#SelectingTransitions</a> * @return true if the effective Transition type is {@link TransitionType#internal} */ public final boolean isTypeInternal() { http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Transition.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/Transition.java b/src/main/java/org/apache/commons/scxml2/model/Transition.java index 08d45c7..69f5d38 100644 --- a/src/main/java/org/apache/commons/scxml2/model/Transition.java +++ b/src/main/java/org/apache/commons/scxml2/model/Transition.java @@ -124,7 +124,7 @@ public class Transition extends SimpleTransition implements DocumentOrder { this.event = event == null ? null : event.trim(); if (this.event != null) { // 'event' is a space separated list of event descriptors - events = new ArrayList<String>(); + events = new ArrayList<>(); StringTokenizer st = new StringTokenizer(this.event); while (st.hasMoreTokens()) { String token = st.nextToken(); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/TransitionType.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/TransitionType.java b/src/main/java/org/apache/commons/scxml2/model/TransitionType.java index a1a104e..d8f0778 100644 --- a/src/main/java/org/apache/commons/scxml2/model/TransitionType.java +++ b/src/main/java/org/apache/commons/scxml2/model/TransitionType.java @@ -22,8 +22,8 @@ package org.apache.commons.scxml2.model; * The Transition type determines whether the source state is exited in transitions * whose target state is a descendant of the source state. * </p> - * @see <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#transition"> - * http://www.w3.org/TR/2014/CR-scxml-20140313/#transition</a> + * @see <a href="https://www.w3.org/TR/2015/REC-scxml-20150901/#transition"> + * https://www.w3.org/TR/2015/REC-scxml-20150901/#transition</a> */ public enum TransitionType { internal, http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java b/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java index e7adfd0..5642dbc 100644 --- a/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java +++ b/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java @@ -27,7 +27,7 @@ public abstract class TransitionalState extends EnterableState { /** * A list of outgoing Transitions from this state, by document order. */ - private List<Transition> transitions; + private final List<Transition> transitions; /** * Optional property holding the data model for this state. @@ -38,7 +38,7 @@ public abstract class TransitionalState extends EnterableState { * List of history states owned by a given state (applies to non-leaf * states). */ - private List<History> history; + private final List<History> history; /** * The Invoke children, each which defines an external process that should @@ -47,19 +47,18 @@ public abstract class TransitionalState extends EnterableState { * process has completed its execution. * May occur 0 or more times. */ - private List<Invoke> invokes; + private final List<Invoke> invokes; /** * The set of EnterableState children contained in this TransitionalState */ - private List<EnterableState> children; + private final List<EnterableState> children; public TransitionalState() { - super(); - transitions = new ArrayList<Transition>(); - history = new ArrayList<History>(); - children = new ArrayList<EnterableState>(); - invokes = new ArrayList<Invoke>(); + transitions = new ArrayList<>(); + history = new ArrayList<>(); + children = new ArrayList<>(); + invokes = new ArrayList<>(); } /** @@ -118,7 +117,7 @@ public abstract class TransitionalState extends EnterableState { if ((event == null && t.getEvent() == null) || (event != null && event.equals(t.getEvent()))) { if (matchingTransitions == null) { - matchingTransitions = new ArrayList<Transition>(); + matchingTransitions = new ArrayList<>(); } matchingTransitions.add(t); } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/model/Var.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/model/Var.java b/src/main/java/org/apache/commons/scxml2/model/Var.java index 205076a..ee6ff71 100644 --- a/src/main/java/org/apache/commons/scxml2/model/Var.java +++ b/src/main/java/org/apache/commons/scxml2/model/Var.java @@ -60,13 +60,6 @@ public class Var extends Action { private String expr; /** - * Constructor. - */ - public Var() { - super(); - } - - /** * Get the expression that evaluates to the initial value * of the variable. * http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java b/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java index abc1a22..5fb5f2a 100644 --- a/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java +++ b/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java @@ -17,7 +17,6 @@ package org.apache.commons.scxml2.semantics; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; @@ -62,7 +61,7 @@ import org.apache.commons.scxml2.system.EventVariable; /** * This class encapsulate and implements the - * <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#AlgorithmforSCXMLInterpretation"> + * <a href="https://www.w3.org/TR/2015/REC-scxml-20150901/#AlgorithmforSCXMLInterpretation"> * W3C SCXML Algorithm for SCXML Interpretation</a> * * <p>Custom semantics can be created by sub-classing this implementation.</p> @@ -72,12 +71,6 @@ import org.apache.commons.scxml2.system.EventVariable; public class SCXMLSemanticsImpl implements SCXMLSemantics { /** - * Suffix for error event that are triggered in reaction to invalid data - * model locations. - */ - public static final String ERR_ILLEGAL_ALLOC = ".error.illegalalloc"; - - /** * Optional post processing immediately following SCXMLReader. May be used * for removing pseudo-states etc. * @@ -122,7 +115,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { // execute global script if defined executeGlobalScript(exctx); // enter initial states - HashSet<TransitionalState> statesToInvoke = new HashSet<TransitionalState>(); + HashSet<TransitionalState> statesToInvoke = new HashSet<>(); Step step = new Step(null); step.getTransitList().add(exctx.getStateMachine().getInitialTransition()); microStep(exctx, step, statesToInvoke); @@ -176,7 +169,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { Step step = new Step(event); selectTransitions(exctx, step); if (!step.getTransitList().isEmpty()) { - HashSet<TransitionalState> statesToInvoke = new HashSet<TransitionalState>(); + HashSet<TransitionalState> statesToInvoke = new HashSet<>(); microStep(exctx, step, statesToInvoke); if (exctx.isRunning()) { macroStep(exctx, statesToInvoke); @@ -209,7 +202,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { return; } ArrayList<EnterableState> configuration = new ArrayList<>(exctx.getScInstance().getStateConfiguration().getActiveStates()); - Collections.sort(configuration, DocumentOrder.reverseDocumentOrderComparator); + configuration.sort(DocumentOrder.reverseDocumentOrderComparator); for (EnterableState es : configuration) { for (OnExit onexit : es.getOnExits()) { executeContent(exctx, onexit); @@ -283,7 +276,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { Set<EnterableState> states = step.getEntrySet(); if (!step.getExitSet().isEmpty()) { // calculate result states by taking current states, subtracting exitSet and adding entrySet - states = new HashSet<EnterableState>(exctx.getScInstance().getStateConfiguration().getStates()); + states = new HashSet<>(exctx.getScInstance().getStateConfiguration().getStates()); states.removeAll(step.getExitSet()); states.addAll(step.getEntrySet()); } @@ -409,7 +402,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { if (h.isDeep()) { if (deep == null) { //calculate deep history for a given state once - deep = new HashSet<EnterableState>(); + deep = new HashSet<>(); for (EnterableState ott : atomicStates) { if (ott.isDescendantOf(es)) { deep.add(ott); @@ -420,7 +413,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { } else { if (shallow == null) { //calculate shallow history for a given state once - shallow = new HashSet<EnterableState>(ts.getChildren()); + shallow = new HashSet<>(ts.getChildren()); shallow.retainAll(activeStates); } step.getNewHistoryConfigurations().put(h, shallow); @@ -439,8 +432,8 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { * @param step The step containing the list of transitions to be taken */ public void computeEntrySet(final SCXMLExecutionContext exctx, final Step step) { - Set<History> historyTargets = new HashSet<History>(); - Set<EnterableState> entrySet = new HashSet<EnterableState>(); + Set<History> historyTargets = new HashSet<>(); + Set<EnterableState> entrySet = new HashSet<>(); for (SimpleTransition st : step.getTransitList()) { for (TransitionTarget tt : st.getTargets()) { if (tt instanceof EnterableState) { @@ -503,7 +496,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { step.getEntrySet().add(es); if (es instanceof Parallel) { for (EnterableState child : ((Parallel)es).getChildren()) { - if (!containsDescendant(step.getEntrySet(), child)) { + if (containsNoDescendant(step.getEntrySet(), child)) { addDescendantStatesToEnter(exctx, step, child); } } @@ -539,7 +532,7 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { step.getEntrySet().add(anc); if (anc instanceof Parallel) { for (EnterableState child : ((Parallel)anc).getChildren()) { - if (!containsDescendant(step.getEntrySet(), child)) { + if (containsNoDescendant(step.getEntrySet(), child)) { addDescendantStatesToEnter(exctx, step, child); } } @@ -549,17 +542,17 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { } /** - * @return Returns true if a member of the provided states set is a descendant of the provided state. + * @return Returns true if no member of the provided states set is a descendant of the provided state. * @param states the set of states to check for descendants * @param state the state to check with */ - public boolean containsDescendant(Set<EnterableState> states, EnterableState state) { + public boolean containsNoDescendant(Set<EnterableState> states, EnterableState state) { for (EnterableState es : states) { if (es.isDescendantOf(state)) { - return true; + return false; } } - return false; + return true; } /** @@ -572,12 +565,12 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { */ public void selectTransitions(final SCXMLExecutionContext exctx, final Step step) throws ModelException { step.getTransitList().clear(); - ArrayList<Transition> enabledTransitions = new ArrayList<Transition>(); + ArrayList<Transition> enabledTransitions = new ArrayList<>(); - ArrayList<EnterableState> configuration = new ArrayList<EnterableState>(exctx.getScInstance().getStateConfiguration().getActiveStates()); - Collections.sort(configuration,DocumentOrder.documentOrderComparator); + ArrayList<EnterableState> configuration = new ArrayList<>(exctx.getScInstance().getStateConfiguration().getActiveStates()); + configuration.sort(DocumentOrder.documentOrderComparator); - HashSet<EnterableState> visited = new HashSet<EnterableState>(); + HashSet<EnterableState> visited = new HashSet<>(); String eventName = step.getEvent() != null ? step.getEvent().getName() : null; for (EnterableState es : configuration) { @@ -620,25 +613,25 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { */ public void removeConflictingTransitions(final SCXMLExecutionContext exctx, final Step step, final List<Transition> enabledTransitions) { - LinkedHashSet<Transition> filteredTransitions = new LinkedHashSet<Transition>(); - LinkedHashSet<Transition> preemptedTransitions = new LinkedHashSet<Transition>(); - Map<Transition, Set<EnterableState>> exitSets = new HashMap<Transition, Set<EnterableState>>(); + LinkedHashSet<Transition> filteredTransitions = new LinkedHashSet<>(); + LinkedHashSet<Transition> preemptedTransitions = new LinkedHashSet<>(); + Map<Transition, Set<EnterableState>> exitSets = new HashMap<>(); Set<EnterableState> configuration = exctx.getScInstance().getStateConfiguration().getActiveStates(); - Collections.sort(enabledTransitions, DocumentOrder.documentOrderComparator); + enabledTransitions.sort(DocumentOrder.documentOrderComparator); for (Transition t1 : enabledTransitions) { boolean t1Preempted = false; Set<EnterableState> t1ExitSet = exitSets.get(t1); for (Transition t2 : filteredTransitions) { if (t1ExitSet == null) { - t1ExitSet = new HashSet<EnterableState>(); + t1ExitSet = new HashSet<>(); computeExitSet(t1, t1ExitSet, configuration); exitSets.put(t1, t1ExitSet); } Set<EnterableState> t2ExitSet = exitSets.get(t2); if (t2ExitSet == null) { - t2ExitSet = new HashSet<EnterableState>(); + t2ExitSet = new HashSet<>(); computeExitSet(t2, t2ExitSet, configuration); exitSets.put(t2, t2ExitSet); } @@ -783,16 +776,12 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { * states = active configuration. */ boolean legalConfig = true; // let's be optimists - Map<EnterableState, Set<EnterableState>> counts = new HashMap<EnterableState, Set<EnterableState>>(); - Set<EnterableState> scxmlCount = new HashSet<EnterableState>(); + Map<EnterableState, Set<EnterableState>> counts = new HashMap<>(); + Set<EnterableState> scxmlCount = new HashSet<>(); for (EnterableState es : states) { EnterableState parent; while ((parent = es.getParent()) != null) { - Set<EnterableState> cnt = counts.get(parent); - if (cnt == null) { - cnt = new HashSet<EnterableState>(); - counts.put(parent, cnt); - } + Set<EnterableState> cnt = counts.computeIfAbsent(parent, k -> new HashSet<>()); cnt.add(es); es = parent; } @@ -889,8 +878,8 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { if (step.getExitSet().isEmpty()) { return; } - ArrayList<EnterableState> exitList = new ArrayList<EnterableState>(step.getExitSet()); - Collections.sort(exitList, DocumentOrder.reverseDocumentOrderComparator); + ArrayList<EnterableState> exitList = new ArrayList<>(step.getExitSet()); + exitList.sort(DocumentOrder.reverseDocumentOrderComparator); for (EnterableState es : exitList) { @@ -1002,8 +991,8 @@ public class SCXMLSemanticsImpl implements SCXMLSemantics { if (step.getEntrySet().isEmpty()) { return; } - ArrayList<EnterableState> entryList = new ArrayList<EnterableState>(step.getEntrySet()); - Collections.sort(entryList, DocumentOrder.documentOrderComparator); + ArrayList<EnterableState> entryList = new ArrayList<>(step.getEntrySet()); + entryList.sort(DocumentOrder.documentOrderComparator); for (EnterableState es : entryList) { exctx.getScInstance().getStateConfiguration().enterState(es); // ensure state context creation and datamodel cloned http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/semantics/Step.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/semantics/Step.java b/src/main/java/org/apache/commons/scxml2/semantics/Step.java index 46000ae..86495db 100644 --- a/src/main/java/org/apache/commons/scxml2/semantics/Step.java +++ b/src/main/java/org/apache/commons/scxml2/semantics/Step.java @@ -38,49 +38,49 @@ public class Step { /** * The event in this step. */ - private TriggerEvent event; + private final TriggerEvent event; /** * The set of states that were exited during this step. */ - private Set<EnterableState> exitSet; + private final Set<EnterableState> exitSet; /** * The set of states that were entered during this step. */ - private Set<EnterableState> entrySet; + private final Set<EnterableState> entrySet; /** * The set of states that were entered during this step by default */ - private Set<EnterableState> defaultEntrySet; + private final Set<EnterableState> defaultEntrySet; /** * The map of default History transitions to be executed as result of entering states in this step. */ - private Map<TransitionalState, SimpleTransition> defaultHistoryTransitions; + private final Map<TransitionalState, SimpleTransition> defaultHistoryTransitions; /** * The map of new History configurations created as result of exiting states in this step */ - private Map<History, Set<EnterableState>> newHistoryConfigurations; + private final Map<History, Set<EnterableState>> newHistoryConfigurations; /** * The list of Transitions taken during this step. */ - private List<SimpleTransition> transitList; + private final List<SimpleTransition> transitList; /** * @param event The event received in this unit of progression */ public Step(TriggerEvent event) { this.event = event; - this.exitSet = new HashSet<EnterableState>(); - this.entrySet = new HashSet<EnterableState>(); - this.defaultEntrySet = new HashSet<EnterableState>(); - this.defaultHistoryTransitions = new HashMap<TransitionalState, SimpleTransition>(); - this.newHistoryConfigurations = new HashMap<History, Set<EnterableState>>(); - this.transitList = new ArrayList<SimpleTransition>(); + this.exitSet = new HashSet<>(); + this.entrySet = new HashSet<>(); + this.defaultEntrySet = new HashSet<>(); + this.defaultHistoryTransitions = new HashMap<>(); + this.newHistoryConfigurations = new HashMap<>(); + this.transitList = new ArrayList<>(); } /** http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java b/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java index 12c860e..c3c40e3 100644 --- a/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java +++ b/src/main/java/org/apache/commons/scxml2/test/StandaloneUtils.java @@ -130,12 +130,8 @@ public final class StandaloneUtils { } } } - } catch (IOException e) { + } catch (IOException | ModelException | XMLStreamException e) { e.printStackTrace(); - } catch (ModelException e) { - e.printStackTrace(); - } catch (XMLStreamException e) { - e.printStackTrace(); } } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/EventDataTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/EventDataTest.java b/src/test/java/org/apache/commons/scxml2/EventDataTest.java index 885c182..baa5f67 100644 --- a/src/test/java/org/apache/commons/scxml2/EventDataTest.java +++ b/src/test/java/org/apache/commons/scxml2/EventDataTest.java @@ -39,16 +39,16 @@ public class EventDataTest { Set<EnterableState> currentStates = exec.getStatus().getStates(); Assert.assertEquals(1, currentStates.size()); Assert.assertEquals("state1", currentStates.iterator().next().getId()); - TriggerEvent te = new EventBuilder("event.foo", TriggerEvent.SIGNAL_EVENT).data(new Integer(3)).build(); + TriggerEvent te = new EventBuilder("event.foo", TriggerEvent.SIGNAL_EVENT).data(3).build(); currentStates = SCXMLTestHelper.fireEvent(exec, te); Assert.assertEquals(1, currentStates.size()); Assert.assertEquals("state3", currentStates.iterator().next().getId()); TriggerEvent[] evts = new TriggerEvent[] { te, - new EventBuilder("event.bar", TriggerEvent.SIGNAL_EVENT).data(new Integer(6)).build()}; + new EventBuilder("event.bar", TriggerEvent.SIGNAL_EVENT).data(6).build()}; currentStates = SCXMLTestHelper.fireEvents(exec, evts); Assert.assertEquals(1, currentStates.size()); Assert.assertEquals("state6", currentStates.iterator().next().getId()); - te = new EventBuilder("event.baz", TriggerEvent.SIGNAL_EVENT).data(new Integer(7)).build(); + te = new EventBuilder("event.baz", TriggerEvent.SIGNAL_EVENT).data(7).build(); currentStates = SCXMLTestHelper.fireEvent(exec, te); Assert.assertEquals(1, currentStates.size()); Assert.assertEquals("state7", currentStates.iterator().next().getId()); @@ -98,12 +98,14 @@ public class EventDataTest { public static class ConnectionAlertingPayload { private int line; - public ConnectionAlertingPayload(int line) { + ConnectionAlertingPayload(int line) { this.line = line; } + @SuppressWarnings("unsed") public void setLine(int line) { this.line = line; } + @SuppressWarnings("unsed") public int getLine() { return line; } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java b/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java index 5f63754..4ef8706 100644 --- a/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java +++ b/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java @@ -112,7 +112,7 @@ public class SCInstanceTest { History history = new History(); history.setId("1"); - Set<EnterableState> configuration = new HashSet<EnterableState>(); + Set<EnterableState> configuration = new HashSet<>(); EnterableState tt1 = new State(); EnterableState tt2 = new State(); configuration.add(tt1); @@ -137,7 +137,7 @@ public class SCInstanceTest { History history = new History(); history.setId("1"); - Set<EnterableState> configuration = new HashSet<EnterableState>(); + Set<EnterableState> configuration = new HashSet<>(); EnterableState tt1 = new State(); configuration.add(tt1); @@ -151,7 +151,7 @@ public class SCInstanceTest { History history = new History(); history.setId("1"); - Set<EnterableState> configuration = new HashSet<EnterableState>(); + Set<EnterableState> configuration = new HashSet<>(); EnterableState tt1 = new State(); configuration.add(tt1); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java b/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java index 947d211..425ad8b 100644 --- a/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java +++ b/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java @@ -151,7 +151,7 @@ public class SCXMLExecutorTest { exec.go(); Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten"); Assert.assertEquals(3, currentStates.size()); - Set<String> expected = new HashSet<String>(); + Set<String> expected = new HashSet<>(); expected.add("twenty_one_2"); expected.add("twenty_two_2"); expected.add("twenty_three_2"); @@ -169,7 +169,7 @@ public class SCXMLExecutorTest { exec.go(); Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten"); Assert.assertEquals(3, currentStates.size()); - Set<String> expected = new HashSet<String>(); + Set<String> expected = new HashSet<>(); expected.add("twenty_one_1"); expected.add("twenty_two_1"); expected.add("twenty_three_1"); @@ -228,7 +228,7 @@ public class SCXMLExecutorTest { public void testSCXMLExecutorTransitionsWithCond01Sample() throws Exception { SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-with-cond-01.xml"); exec.go(); - Map<String, Object> payload = new HashMap<String, Object>(); + Map<String, Object> payload = new HashMap<>(); // with _event.data set to true, transition should happen as expected. payload.put("keyed", Boolean.TRUE); @@ -257,7 +257,7 @@ public class SCXMLExecutorTest { public void testSCXMLExecutorSystemEventVariable() throws Exception { SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-event-variable.xml"); exec.go(); - Map<String, Object> payload = new HashMap<String, Object>(); + Map<String, Object> payload = new HashMap<>(); payload.put("keyed", Boolean.TRUE); SCXMLTestHelper.assertPostTriggerState(exec, "open", payload, "opened"); } @@ -272,7 +272,7 @@ public class SCXMLExecutorTest { currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.twenty_one"); Assert.assertEquals(1, currentStates.size()); Assert.assertEquals("twenty_two", currentStates.iterator().next().getId()); - Set<String> stateIds = new HashSet<String>(); + Set<String> stateIds = new HashSet<>(); stateIds.add("twenty_one"); exec.setConfiguration(stateIds); Assert.assertEquals(1, exec.getStatus().getStates().size()); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java b/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java index fef7a9d..62039b9 100644 --- a/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java +++ b/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java @@ -82,8 +82,7 @@ public class SCXMLTestHelper { Configuration configuration = new Configuration(null, null, customActions); SCXML scxml = SCXMLReader.read(url, configuration); Assert.assertNotNull(scxml); - SCXML roundtrip = testModelSerializability(scxml); - return roundtrip; + return testModelSerializability(scxml); } public static SCXML parse(final Reader scxmlReader, final List<CustomAction> customActions) throws Exception { @@ -91,8 +90,7 @@ public class SCXMLTestHelper { Configuration configuration = new Configuration(null, null, customActions); SCXML scxml = SCXMLReader.read(scxmlReader, configuration); Assert.assertNotNull(scxml); - SCXML roundtrip = testModelSerializability(scxml); - return roundtrip; + return testModelSerializability(scxml); } public static SCXMLExecutor getExecutor(final URL url) throws Exception { @@ -135,7 +133,7 @@ public class SCXMLTestHelper { return exec.getSCInstance().lookupContext((EnterableState)tt); } - public static void assertState(SCXMLExecutor exec, String expectedStateId) throws Exception { + public static void assertState(SCXMLExecutor exec, String expectedStateId) { Set<EnterableState> currentStates = exec.getStatus().getStates(); Assert.assertEquals("Expected 1 simple (leaf) state with id '" + expectedStateId + "' but found " + currentStates.size() + " states instead.", @@ -209,7 +207,7 @@ public class SCXMLTestHelper { + " on firing event " + triggerEvent + " but found " + currentStates.size() + " states instead.", n, currentStates.size()); - List<String> expectedStateIdList = new ArrayList<String>(Arrays.asList(expectedStateIds)); + List<String> expectedStateIdList = new ArrayList<>(Arrays.asList(expectedStateIds)); for (TransitionTarget tt : currentStates) { String stateId = tt.getId(); if(!expectedStateIdList.remove(stateId)) { @@ -219,7 +217,7 @@ public class SCXMLTestHelper { } } Assert.assertEquals("More states in current configuration than those" - + "specified in the expected state ids '" + expectedStateIds + + "specified in the expected state ids '" + Arrays.toString(expectedStateIds) + "'", 0, expectedStateIdList.size()); } @@ -230,7 +228,7 @@ public class SCXMLTestHelper { } String filename = SERIALIZATION_FILE_PREFIX + getSequenceNumber() + SERIALIZATION_FILE_SUFFIX; - SCXML roundtrip = null; + SCXML roundtrip; ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename)); out.writeObject(scxml); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/WizardsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/WizardsTest.java b/src/test/java/org/apache/commons/scxml2/WizardsTest.java index f62c38a..c134153 100644 --- a/src/test/java/org/apache/commons/scxml2/WizardsTest.java +++ b/src/test/java/org/apache/commons/scxml2/WizardsTest.java @@ -74,9 +74,8 @@ public class WizardsTest { } static class TestEventDispatcher extends SimpleDispatcher { - private static final long serialVersionUID = 1L; - // If you change this, you must also change testWizard02Sample() + // If you change this, you must also change testWizard02Sample() int callback = 0; @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/AbstractStateMachineTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/AbstractStateMachineTest.java b/src/test/java/org/apache/commons/scxml2/env/AbstractStateMachineTest.java index 0766e14..28f5c30 100644 --- a/src/test/java/org/apache/commons/scxml2/env/AbstractStateMachineTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/AbstractStateMachineTest.java @@ -43,7 +43,7 @@ public class AbstractStateMachineTest { private boolean fooCalled; - public Foo(final URL scxmlDocument) throws ModelException { + Foo(final URL scxmlDocument) throws ModelException { super(scxmlDocument); } @@ -51,7 +51,7 @@ public class AbstractStateMachineTest { fooCalled = true; } - public boolean fooCalled() { + boolean fooCalled() { return fooCalled; } } @@ -60,7 +60,7 @@ public class AbstractStateMachineTest { private boolean barCalled; - public Bar(final URL scxmlDocument) throws ModelException { + Bar(final URL scxmlDocument) throws ModelException { super(scxmlDocument); } @@ -68,7 +68,7 @@ public class AbstractStateMachineTest { barCalled = true; } - public boolean barCalled() { + boolean barCalled() { return barCalled; } } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/StopWatch.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/StopWatch.java b/src/test/java/org/apache/commons/scxml2/env/StopWatch.java index d32a6f4..96d0d9e 100644 --- a/src/test/java/org/apache/commons/scxml2/env/StopWatch.java +++ b/src/test/java/org/apache/commons/scxml2/env/StopWatch.java @@ -87,9 +87,7 @@ public class StopWatch extends AbstractStateMachine { String padhr = dhr > 9 ? EMPTY : ZERO; String padmin = dmin > 9 ? EMPTY : ZERO; String padsec = dsec > 9 ? EMPTY : ZERO; - return new StringBuffer().append(padhr).append(dhr).append(DELIM). - append(padmin).append(dmin).append(DELIM).append(padsec). - append(dsec).append(DOT).append(dfract).toString(); + return padhr + dhr + DELIM + padmin + dmin + DELIM + padsec + dsec + DOT + dfract; } // used by the demonstration (see StopWatchDisplay usecase) http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/StopWatchDisplay.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/StopWatchDisplay.java b/src/test/java/org/apache/commons/scxml2/env/StopWatchDisplay.java index e8b18f5..7828316 100644 --- a/src/test/java/org/apache/commons/scxml2/env/StopWatchDisplay.java +++ b/src/test/java/org/apache/commons/scxml2/env/StopWatchDisplay.java @@ -48,9 +48,8 @@ import org.apache.commons.scxml2.model.ModelException; public class StopWatchDisplay extends JFrame implements ActionListener { - private static final long serialVersionUID = 1L; private StopWatch stopWatch; - private Image watchImage, watchIcon; + private Image watchImage; public StopWatchDisplay() throws ModelException { super("SCXML stopwatch"); @@ -92,7 +91,7 @@ public class StopWatchDisplay extends JFrame getResource("org/apache/commons/scxml2/env/stopwatchicon.gif"); Toolkit kit = Toolkit.getDefaultToolkit(); watchImage = kit.createImage(imageURL); - watchIcon = kit.createImage(iconURL); + Image watchIcon = kit.createImage(iconURL); WatchPanel panel = new WatchPanel(); panel.setLayout(new BorderLayout()); setContentPane(panel); @@ -135,8 +134,6 @@ public class StopWatchDisplay extends JFrame } class WatchPanel extends JPanel { - private static final long serialVersionUID = 1L; - @Override public void paintComponent(Graphics g) { if(watchImage != null) { http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyContextTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyContextTest.java b/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyContextTest.java index 04eeb87..3d916f4 100644 --- a/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyContextTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyContextTest.java @@ -32,7 +32,7 @@ public class GroovyContextTest { @Test public void testPrepopulated() { - Map<String, Object> m = new HashMap<String, Object>(); + Map<String, Object> m = new HashMap<>(); m.put("foo", "bar"); GroovyContext ctx = new GroovyContext(null, m, null); Assert.assertNotNull(ctx); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java b/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java index 73b27ce..3e4f049 100644 --- a/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java @@ -68,16 +68,16 @@ public class JSEvaluatorTest { "</scxml>"; private static final TestItem[] SIMPLE_EXPRESSIONS = { - new TestItem("'FIB: ' + (1 + 1 + 2 + 3 + 5)",new String("FIB: 12")), - new TestItem("1 + 1 + 2 + 3 + 5", new Integer(12)), // Force comparison using intValue - new TestItem("1.1 + 1.1 + 2.1 + 3.1 + 5.1", new Double(12.5)), - new TestItem("(1 + 1 + 2 + 3 + 5) == 12", new Boolean(true)), - new TestItem("(1 + 1 + 2 + 3 + 5) == 13", new Boolean(false)), + new TestItem("'FIB: ' + (1 + 1 + 2 + 3 + 5)", "FIB: 12"), + new TestItem("1 + 1 + 2 + 3 + 5", 12), // Force comparison using intValue + new TestItem("1.1 + 1.1 + 2.1 + 3.1 + 5.1", 12.5), + new TestItem("(1 + 1 + 2 + 3 + 5) == 12", true), + new TestItem("(1 + 1 + 2 + 3 + 5) == 13", false), }; private static final TestItem[] VAR_EXPRESSIONS = { - new TestItem("'FIB: ' + fibonacci",new String("FIB: 12")), - new TestItem("fibonacci * 2", new Double(24)), + new TestItem("'FIB: ' + fibonacci", "FIB: 12"), + new TestItem("fibonacci * 2", 24.0), }; private static final String FUNCTION = "function factorial(N) {\r\n" + @@ -97,7 +97,6 @@ public class JSEvaluatorTest { private Context context; private Evaluator evaluator; - private SCXMLExecutor fsm; // TEST SETUP @@ -107,10 +106,10 @@ public class JSEvaluatorTest { */ @Before public void setUp() throws Exception { - fsm = SCXMLTestHelper.getExecutor(SCXMLReader.read(new StringReader(SCRIPT))); - fsm.go(); - evaluator = fsm.getEvaluator(); - context = fsm.getGlobalContext(); + SCXMLExecutor fsm = SCXMLTestHelper.getExecutor(SCXMLReader.read(new StringReader(SCRIPT))); + fsm.go(); + evaluator = fsm.getEvaluator(); + context = fsm.getGlobalContext(); } // CLASS METHODS @@ -137,7 +136,7 @@ public class JSEvaluatorTest { Evaluator evaluator = new JSEvaluator(); Assert.assertNotNull(evaluator); - Assert.assertTrue (((Boolean) evaluator.eval(context, "1+1 == 2")).booleanValue()); + Assert.assertTrue ((Boolean) evaluator.eval(context, "1+1 == 2")); } @Test @@ -201,11 +200,11 @@ public class JSEvaluatorTest { */ @Test public void testVarExpressions() throws Exception { - context.set("fibonacci",Integer.valueOf(12)); + context.set("fibonacci", 12.0); for (TestItem item: VAR_EXPRESSIONS) { Assert.assertNotNull(context.get("fibonacci")); - Assert.assertEquals (Integer.valueOf(12),context.get("fibonacci")); + Assert.assertEquals (12.0,context.get("fibonacci")); Assert.assertEquals ("Invalid result: " + item.expression, item.result, evaluator.eval(context,item.expression)); @@ -288,17 +287,17 @@ public class JSEvaluatorTest { */ @Test public void testScriptFunctions() throws Exception { - context.set("FIVE",Integer.valueOf(5)); - Assert.assertEquals(Integer.valueOf(5),context.get("FIVE")); - Assert.assertEquals("Invalid function result",Double.valueOf(120.0),evaluator.eval(context,FUNCTION)); + context.set("FIVE", 5); + Assert.assertEquals(5,context.get("FIVE")); + Assert.assertEquals("Invalid function result", 120.0,evaluator.eval(context,FUNCTION)); } // INNER CLASSES private static class TestItem { - private String expression; - private Object result; + private final String expression; + private final Object result; private TestItem(String expression,Object result) { this.expression = expression; http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java b/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java index bf33d61..345bcdf 100644 --- a/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java @@ -46,7 +46,7 @@ public class JSExampleTest { @Test public void testExample01Sample() throws Exception { - List<CustomAction> actions = new ArrayList<CustomAction>(); + List<CustomAction> actions = new ArrayList<>(); actions.add(new CustomAction("http://my.custom-actions.domain", "eventdatamaptest", EventDataMapTest.class)); SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/env/javascript/example-01.xml", actions); @@ -60,8 +60,6 @@ public class JSExampleTest { // INNER CLASSES public static class EventDataMapTest extends Action { - private static final long serialVersionUID = 1L; - @Override public void execute(ActionExecutionContext exctx) throws ModelException, SCXMLExpressionException { exctx.getInternalIOProcessor() http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/jexl/JexlContextTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/jexl/JexlContextTest.java b/src/test/java/org/apache/commons/scxml2/env/jexl/JexlContextTest.java index 2f62544..ebeb04c 100644 --- a/src/test/java/org/apache/commons/scxml2/env/jexl/JexlContextTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/jexl/JexlContextTest.java @@ -32,18 +32,7 @@ public class JexlContextTest { @Test public void testPrepopulated() { - Map<String, Object> m = new HashMap<String, Object>(); - m.put("foo", "bar"); - JexlContext ctx = new JexlContext(null, m); - Assert.assertNotNull(ctx); - Assert.assertEquals(1, ctx.getVars().size()); - String fooValue = (String) ctx.get("foo"); - Assert.assertEquals("bar", fooValue); - } - - @Test - public void testSetVars() { - Map<String, Object> m = new HashMap<String, Object>(); + Map<String, Object> m = new HashMap<>(); m.put("foo", "bar"); JexlContext ctx = new JexlContext(null, m); Assert.assertNotNull(ctx); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/env/jexl/JexlEvaluatorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/env/jexl/JexlEvaluatorTest.java b/src/test/java/org/apache/commons/scxml2/env/jexl/JexlEvaluatorTest.java index e3f42de..440a5ce 100644 --- a/src/test/java/org/apache/commons/scxml2/env/jexl/JexlEvaluatorTest.java +++ b/src/test/java/org/apache/commons/scxml2/env/jexl/JexlEvaluatorTest.java @@ -24,13 +24,13 @@ import org.junit.Test; public class JexlEvaluatorTest { - private String BAD_EXPRESSION = ">"; - private Context ctx = new JexlContext(); + private static final String BAD_EXPRESSION = ">"; + private final Context ctx = new JexlContext(); @Test public void testPristine() throws SCXMLExpressionException { Evaluator eval = new JexlEvaluator(); - Assert.assertTrue(((Boolean) eval.eval(ctx, "1+1 eq 2")).booleanValue()); + Assert.assertTrue((Boolean) eval.eval(ctx, "1+1 eq 2")); } @Test http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java b/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java index f828cfa..9bcb040 100644 --- a/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java +++ b/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java @@ -34,8 +34,8 @@ public class InvokeParamNameTest { private SCXMLExecutor exec; - static String lastURL; - static Map<String, Object> lastParams; + private static String lastURL; + private static Map<String, Object> lastParams; @Before public void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/io/ContentParserTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/io/ContentParserTest.java b/src/test/java/org/apache/commons/scxml2/io/ContentParserTest.java index 5ded49c..3312e26 100644 --- a/src/test/java/org/apache/commons/scxml2/io/ContentParserTest.java +++ b/src/test/java/org/apache/commons/scxml2/io/ContentParserTest.java @@ -65,7 +65,7 @@ public class ContentParserTest { String jsonObjectString = "{ /*comment*/ 'string' : 'foobar', 'int' : 1, 'boolean' : false, 'null' : null }"; LinkedHashMap<String, Object> jsonObject = new LinkedHashMap<>(); jsonObject.put("string", "foobar"); - jsonObject.put("int",new Integer(1)); + jsonObject.put("int", 1); jsonObject.put("boolean", Boolean.FALSE); jsonObject.put("null", null); Assert.assertEquals(jsonObject, contentParser.parseJson(jsonObjectString)); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java b/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java index cb5707b..f69858c 100644 --- a/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java +++ b/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java @@ -169,7 +169,7 @@ public class SCXMLReaderTest { @Test public void testSCXMLReaderCustomActionWithBodyTextSample() throws Exception { - List<CustomAction> cas = new ArrayList<CustomAction>(); + List<CustomAction> cas = new ArrayList<>(); CustomAction ca = new CustomAction("http://my.custom-actions.domain", "action", MyAction.class); cas.add(ca); @@ -207,11 +207,10 @@ public class SCXMLReaderTest { // In the lenient/silent mode (strict == false && silent == true), // no model exception is logged. clearRecordedLogMessages(); - scxml = null; configuration = new Configuration(); configuration.setStrict(false); configuration.setSilent(true); - scxml = SCXMLReader.read(SCXMLTestHelper.getResource("org/apache/commons/scxml2/io/scxml-with-invalid-elems.xml"), + SCXMLReader.read(SCXMLTestHelper.getResource("org/apache/commons/scxml2/io/scxml-with-invalid-elems.xml"), configuration); Assert.assertNotNull(scxml); Assert.assertNotNull(serialize(scxml)); @@ -230,21 +229,21 @@ public class SCXMLReaderTest { // In strict/verbose mode (strict == true && silent == false), it should fail to read the model and catch a model exception // with warning logs because of the invalid <baddata> element. clearRecordedLogMessages(); - scxml = null; configuration = new Configuration(); configuration.setStrict(true); configuration.setSilent(false); try { - scxml = SCXMLReader.read(SCXMLTestHelper.getResource("org/apache/commons/scxml2/io/scxml-with-invalid-elems.xml"), + SCXMLReader.read(SCXMLTestHelper.getResource("org/apache/commons/scxml2/io/scxml-with-invalid-elems.xml"), configuration); Assert.fail("In strict mode, it should have thrown a model exception."); } catch (ModelException e) { Assert.assertTrue(e.getMessage().contains("Ignoring unknown or invalid element <baddata>")); } + assertContainsRecordedLogMessage("Ignoring unknown or invalid element <baddata> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <datamodel>"); - assertContainsRecordedLogMessage("Ignoring unknown or invalid element <baddata> in namespace \"http://www.example.com/scxml\" as child of <datamodel>"); - assertContainsRecordedLogMessage("Ignoring unknown or invalid element <trace> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <onentry>"); - assertContainsRecordedLogMessage("Ignoring unknown or invalid element <onbeforeexit> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <final>"); + assertNotContainsRecordedLogMessage("Ignoring unknown or invalid element <baddata> in namespace \"http://www.example.com/scxml\" as child of <datamodel>"); + assertNotContainsRecordedLogMessage("Ignoring unknown or invalid element <trace> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <onentry>"); + assertNotContainsRecordedLogMessage("Ignoring unknown or invalid element <onbeforeexit> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <final>"); // In strict/silent mode (strict == true && silent == true), it should fail to read the model and catch a model exception // without warning logs because of the invalid <baddata> element. @@ -333,15 +332,13 @@ public class SCXMLReaderTest { private void assertContainsRecordedLogMessage(final String message) { if (scxmlReaderLog instanceof RecordingSimpleLog) { - Assert.assertTrue(((RecordingSimpleLog) scxmlReaderLog).containsMessage( - "Ignoring unknown or invalid element <baddata> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <datamodel>")); + Assert.assertTrue(((RecordingSimpleLog) scxmlReaderLog).containsMessage(message)); } } private void assertNotContainsRecordedLogMessage(final String message) { if (scxmlReaderLog instanceof RecordingSimpleLog) { - Assert.assertFalse(((RecordingSimpleLog) scxmlReaderLog).containsMessage( - "Ignoring unknown or invalid element <baddata> in namespace \"http://www.w3.org/2005/07/scxml\" as child of <datamodel>")); + Assert.assertFalse(((RecordingSimpleLog) scxmlReaderLog).containsMessage(message)); } } @@ -352,7 +349,6 @@ public class SCXMLReaderTest { } public static class MyAction extends Action implements ParsedValueContainer { - private static final long serialVersionUID = 1L; private ParsedValue parsedValue; @@ -387,18 +383,16 @@ public class SCXMLReaderTest { */ public static class RecordingSimpleLog extends SimpleLog { - private static final long serialVersionUID = 1L; - - private List<String> messages = new LinkedList<String>(); + private final List<String> messages = new LinkedList<>(); - public RecordingSimpleLog(String name) { + RecordingSimpleLog(String name) { super(name); } /** * Clear all the recorded log messages. */ - public void clearMessages() { + void clearMessages() { messages.clear(); } @@ -407,7 +401,7 @@ public class SCXMLReaderTest { * @param msg * @return */ - public boolean containsMessage(final String msg) { + boolean containsMessage(final String msg) { for (String message : messages) { if (message.contains(msg)) { return true; @@ -423,7 +417,6 @@ public class SCXMLReaderTest { @Override protected void log(int type, Object message, Throwable t) { - super.log(type, message, t); messages.add(message.toString()); } } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java b/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java index 7c7feb1..94ea225 100644 --- a/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java +++ b/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** - * Test enforcement of required SCXML element attributes, spec http://www.w3.org/TR/2013/WD-scxml-20130801 + * Test enforcement of required SCXML element attributes, spec https://www.w3.org/TR/2015/REC-scxml-20150901 * <p> * TODO required attributes for elements: * <ul> http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/io/SCXMLWriterTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/io/SCXMLWriterTest.java b/src/test/java/org/apache/commons/scxml2/io/SCXMLWriterTest.java index 6ce85da..20c3b3e 100644 --- a/src/test/java/org/apache/commons/scxml2/io/SCXMLWriterTest.java +++ b/src/test/java/org/apache/commons/scxml2/io/SCXMLWriterTest.java @@ -21,12 +21,10 @@ import java.util.LinkedHashMap; import org.apache.commons.scxml2.model.CommonsSCXML; import org.apache.commons.scxml2.model.ModelException; -import org.apache.commons.scxml2.model.OnEntry; import org.apache.commons.scxml2.model.Parallel; import org.apache.commons.scxml2.model.SCXML; import org.apache.commons.scxml2.model.Script; import org.apache.commons.scxml2.model.State; -import org.apache.commons.scxml2.model.Var; import org.junit.Assert; import org.junit.Test; @@ -38,7 +36,7 @@ public class SCXMLWriterTest { public void testSerializeSCXMLNoStates() throws IOException, XMLStreamException { SCXML scxml = new CommonsSCXML(); // ensure namespaces are stored in insertion order for write->read comparision below - LinkedHashMap namespaces = new LinkedHashMap(scxml.getNamespaces()); + LinkedHashMap<String, String> namespaces = new LinkedHashMap<>(scxml.getNamespaces()); namespaces.put("foo", "http://f.o.o"); namespaces.put("bar", "http://b.a.r"); scxml.setNamespaces(namespaces); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java b/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java index ad27e00..dce0e4c 100644 --- a/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java +++ b/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java @@ -54,7 +54,7 @@ public class Issue112Test { CustomAction ca1 = new CustomAction("http://my.custom-actions.domain/CUSTOM", "enqueue", Enqueue.class); - List<CustomAction> customActions = new ArrayList<CustomAction>(); + List<CustomAction> customActions = new ArrayList<>(); customActions.add(ca1); SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/issues/queue-01.xml", customActions); @@ -87,13 +87,8 @@ public class Issue112Test { */ public static class Enqueue extends Action { - private static final long serialVersionUID = 1L; private String event; - public Enqueue() { - super(); - } - public String getEvent() { return event; } @@ -113,7 +108,7 @@ public class Issue112Test { // Test external event queue private static final class Application { - private static final Queue<String> QUEUE = new LinkedList<String>(); + private static final Queue<String> QUEUE = new LinkedList<>(); } } http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java b/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java index feb288c..7f81491 100644 --- a/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java +++ b/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java @@ -54,7 +54,7 @@ public class ActionsTest { runTest(exec); } - private void runTest(SCXMLExecutor exec) throws Exception { + private void runTest(SCXMLExecutor exec) { Context ctx = SCXMLTestHelper.lookupContext(exec, "actionsTest"); Assert.assertEquals(ctx.get("foo"), "foobar"); Assert.assertEquals("Missed event transition", http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java b/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java index 0a85c80..63f3213 100644 --- a/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java +++ b/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java @@ -119,7 +119,7 @@ public class CustomActionTest { CustomAction ca2 = new CustomAction("http://my.custom-actions.domain/CUSTOM2", "bar", Hello.class); - List<CustomAction> customActions = new ArrayList<CustomAction>(); + List<CustomAction> customActions = new ArrayList<>(); customActions.add(ca1); customActions.add(ca2); // (2) Parse the document @@ -146,7 +146,7 @@ public class CustomActionTest { CustomAction ca = new CustomAction("http://my.custom-actions.domain/CUSTOM", "hello", Hello.class); - List<CustomAction> customActions = new ArrayList<CustomAction>(); + List<CustomAction> customActions = new ArrayList<>(); customActions.add(ca); // (2) Parse the document SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/external-hello-world.xml", customActions); @@ -170,7 +170,7 @@ public class CustomActionTest { CustomAction ca = new CustomAction("http://my.custom-actions.domain/CUSTOM", "send", Hello.class); - List<CustomAction> customActions = new ArrayList<CustomAction>(); + List<CustomAction> customActions = new ArrayList<>(); customActions.add(ca); // (2) Parse the document SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/custom-hello-world-03.xml", customActions); @@ -195,7 +195,7 @@ public class CustomActionTest { CustomAction ca = new CustomAction("http://my.custom-actions.domain/CUSTOM", "hello", Hello.class); - List<CustomAction> customActions = new ArrayList<CustomAction>(); + List<CustomAction> customActions = new ArrayList<>(); customActions.add(ca); // (2) Parse the document SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/custom-hello-world-04-jexl.xml", customActions); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/model/Hello.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/model/Hello.java b/src/test/java/org/apache/commons/scxml2/model/Hello.java index c01cbfc..4094e39 100644 --- a/src/test/java/org/apache/commons/scxml2/model/Hello.java +++ b/src/test/java/org/apache/commons/scxml2/model/Hello.java @@ -26,8 +26,6 @@ import org.apache.commons.scxml2.EventBuilder; */ public class Hello extends Action { - /** Serial version UID. */ - private static final long serialVersionUID = 1L; /** This is who we say hello to. */ private String name; /** We count callbacks to execute() as part of the test suite. */ http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/model/SendTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/model/SendTest.java b/src/test/java/org/apache/commons/scxml2/model/SendTest.java index 2a315f7..2dbab93 100644 --- a/src/test/java/org/apache/commons/scxml2/model/SendTest.java +++ b/src/test/java/org/apache/commons/scxml2/model/SendTest.java @@ -36,7 +36,7 @@ public class SendTest { @Test @SuppressWarnings("unchecked") public void testNamelistOrderPreserved() throws Exception { - final List<Object> payloads = new ArrayList<Object>(); + final List<Object> payloads = new ArrayList<>(); final SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/model/send-test-01.xml"); final SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml, null, new SimpleDispatcher() { @Override @@ -47,7 +47,7 @@ public class SendTest { } }); exec.go(); - TriggerEvent te = new EventBuilder("event.foo", TriggerEvent.SIGNAL_EVENT).data(new Integer(3)).build(); + TriggerEvent te = new EventBuilder("event.foo", TriggerEvent.SIGNAL_EVENT).data(3).build(); SCXMLTestHelper.fireEvent(exec, te); Assert.assertFalse("Payloads empty.", payloads.isEmpty()); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java b/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java index 9aa1a54..b3e0dd4 100644 --- a/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java +++ b/src/test/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImplTest.java @@ -31,14 +31,14 @@ public class SCXMLSemanticsImplTest { @Test public void testIsLegalConfigNoStates() { - Set<EnterableState> states = new HashSet<EnterableState>(); + Set<EnterableState> states = new HashSet<>(); Assert.assertTrue(new SCXMLSemanticsImpl().isLegalConfiguration(states, new SimpleErrorReporter())); } @Test public void testIsLegalConfigInvalidParallel() { - Set<EnterableState> states = new HashSet<EnterableState>(); + Set<EnterableState> states = new HashSet<>(); Parallel parallel = new Parallel(); Parallel parent = new Parallel(); @@ -65,7 +65,7 @@ public class SCXMLSemanticsImplTest { @Test public void testIsLegalConfigMultipleTopLevel() { - Set<EnterableState> states = new HashSet<EnterableState>(); + Set<EnterableState> states = new HashSet<>(); State state1 = new State(); state1.setId("1"); @@ -84,7 +84,7 @@ public class SCXMLSemanticsImplTest { @Test public void testIsLegalConfigMultipleStatesActive() { - Set<EnterableState> states = new HashSet<EnterableState>(); + Set<EnterableState> states = new HashSet<>(); State state1 = new State(); state1.setId("1"); http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/05e94b82/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java b/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java index 1761300..29a1d49 100644 --- a/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java +++ b/src/test/java/org/apache/commons/scxml2/w3c/W3CTests.java @@ -267,7 +267,7 @@ public class W3CTests { } public List<TestCase> getTestCases() { - return testCases != null ? testCases : Collections.<TestCase>emptyList(); + return testCases != null ? testCases : Collections.emptyList(); } public Datamodel getDatamodel() { @@ -314,12 +314,12 @@ public class W3CTests { } public List<Resource> getScxmlResources() { - return scxmlResources != null ? scxmlResources : Collections.<Resource>emptyList(); + return scxmlResources != null ? scxmlResources : Collections.emptyList(); } public List<Resource> getResources() { if (resources == null) { - resources = new ArrayList<Resource>(); + resources = new ArrayList<>(); if (scxmlResources != null) { resources.addAll(scxmlResources); } @@ -385,10 +385,10 @@ public class W3CTests { * Simple TestResult data struct for tracking test results */ protected static class TestResults { - Map<Datamodel, Integer> passed = new HashMap<>(); - Map<Datamodel, Integer> failed = new HashMap<>(); - Map<Datamodel, Integer> skipped = new HashMap<>(); - ArrayList<String> changedStatusTests = new ArrayList<>(); + final Map<Datamodel, Integer> passed = new HashMap<>(); + final Map<Datamodel, Integer> failed = new HashMap<>(); + final Map<Datamodel, Integer> skipped = new HashMap<>(); + final ArrayList<String> changedStatusTests = new ArrayList<>(); public int passed(final Datamodel dm) { return passed.get(dm) != null ? passed.get(dm) : 0; @@ -510,18 +510,20 @@ public class W3CTests { throws Exception { System.out.println("processing IRP test file " + resource.getFilename()); FileUtils.copyURLToFile(new URL(SCXML_IRP_BASE_URL + resource.getUri()), new File(TXML_TESTS_DIR + resource.getFilename())); - if (specid.equals("#minimal-profile")) { - transformResource(resource, transformers.get(Datamodel.MINIMAL), Datamodel.MINIMAL.testDir()); - } - else if (specid.equals("#ecma-profile")) { - transformResource(resource, transformers.get(Datamodel.ECMA), Datamodel.ECMA.testDir()); - } - else { - for (Datamodel dm : transformers.keySet()) { - if (dm != Datamodel.MINIMAL) { - transformResource(resource, transformers.get(dm), dm.testDir()); + switch (specid) { + case "#minimal-profile": + transformResource(resource, transformers.get(Datamodel.MINIMAL), Datamodel.MINIMAL.testDir()); + break; + case "#ecma-profile": + transformResource(resource, transformers.get(Datamodel.ECMA), Datamodel.ECMA.testDir()); + break; + default: + for (Datamodel dm : transformers.keySet()) { + if (dm != Datamodel.MINIMAL) { + transformResource(resource, transformers.get(dm), dm.testDir()); + } } - } + break; } }