Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Allow storing possible actions per state #34
Browse files Browse the repository at this point in the history
  • Loading branch information
tdauth authored and rebazer committed May 21, 2019
1 parent 474a259 commit 8738a68
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/main/scala/de/retest/guistatemachine/api/State.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ trait State {
*/
def getIncomingActionTransitions: Map[ActionIdentifier, ActionTransitions]

/**
* @groupname possibleactions Possible Actions
* The set of possible actions has to be restricted for certain action types like ChangeValueAction. The set should always be the same for the same elements per state. It can be used for exploration strategies.
*
* @param possibleActions The possible actions of the state.
* @group possibleactions
*/
def setPossibleActions(possibleActions: Set[ActionIdentifier])

/**
* @return The possible actions of the state.
* @group possibleactions
*/
def getPossibleActions: Set[ActionIdentifier]

/**
* Overriding this method is required to allow the usage of a set of states.
* Comparing the descriptors should check for the equality of all root elements which compares the identifying attributes and the contained components
Expand Down
16 changes: 13 additions & 3 deletions src/main/scala/de/retest/guistatemachine/api/impl/StateImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package de.retest.guistatemachine.api.impl

import de.retest.guistatemachine.api.{ActionIdentifier, ActionTransitions, State, SutStateIdentifier}

import scala.collection.immutable.HashMap
import scala.collection.immutable.{HashMap, HashSet}

@SerialVersionUID(1L)
case class StateImpl(sutState: SutStateIdentifier) extends State with Serializable {
Expand All @@ -18,9 +18,19 @@ case class StateImpl(sutState: SutStateIdentifier) extends State with Serializab
*/
private var incomingActionTransitions = HashMap[ActionIdentifier, ActionTransitions]()

private var possibleActions: Set[ActionIdentifier] = HashSet[ActionIdentifier]()

override def getSutStateIdentifier: SutStateIdentifier = this.synchronized { sutState }
override def getOutgoingActionTransitions: Map[ActionIdentifier, ActionTransitions] = this.synchronized { outgoingActionTransitions }
override def getIncomingActionTransitions: Map[ActionIdentifier, ActionTransitions] = this.synchronized { incomingActionTransitions }
override def getOutgoingActionTransitions: Map[ActionIdentifier, ActionTransitions] = this.synchronized {
outgoingActionTransitions
}
override def getIncomingActionTransitions: Map[ActionIdentifier, ActionTransitions] = this.synchronized {
incomingActionTransitions
}
override def setPossibleActions(possibleActions: Set[ActionIdentifier]): Unit = this.synchronized {
this.possibleActions = possibleActions
}
override def getPossibleActions: Set[ActionIdentifier] = this.synchronized { possibleActions }

private[api] override def addTransition(a: ActionIdentifier, to: State): Int = {
val executionCounter = this.synchronized {
Expand Down

0 comments on commit 8738a68

Please sign in to comment.