diff --git a/.gitignore b/.gitignore index 3e82fc7..d6aff20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.project /.classpath /.settings /.idea diff --git a/build.sbt b/build.sbt index e9ace65..ed152cb 100644 --- a/build.sbt +++ b/build.sbt @@ -1,14 +1,14 @@ name := "gui-state-machine-api" -version := "1.0" +version := "0.1.0" organization := "retest" scalaVersion := "2.12.7" // Dependencies to represent the input of states and actions: -libraryDependencies += "de.retest" % "retest-model" % "5.0.0" -libraryDependencies += "org.seleniumhq.selenium" % "selenium-java" % "2.35.0" +libraryDependencies += "de.retest" % "retest-model" % "5.0.0" withSources() withJavadoc() +libraryDependencies += "org.seleniumhq.selenium" % "selenium-java" % "2.35.0" withSources() withJavadoc() // Dependencies to provide a REST service: libraryDependencies += "com.github.scopt" % "scopt_2.12" % "3.7.0" @@ -27,4 +27,14 @@ libraryDependencies += "org.scalamock" %% "scalamock" % "4.1.0" % "test" // set the main class for 'sbt run' mainClass in (Compile, run) := Some("de.retest.guistatemachine.rest.WebServer") // set the main class for packaging the main jar -mainClass in (Compile, packageBin) := Some("de.retest.guistatemachine.rest.WebServer") \ No newline at end of file +mainClass in (Compile, packageBin) := Some("de.retest.guistatemachine.rest.WebServer") + +publishTo := { + val nexus = "https://my.artifact.repo.net/" + if (isSnapshot.value) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") +} + +credentials += Credentials(Path.userHome / ".sbt" / ".credentials") \ No newline at end of file diff --git a/project/sbtrelease.sbt b/project/sbtrelease.sbt new file mode 100644 index 0000000..1654adf --- /dev/null +++ b/project/sbtrelease.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10") \ No newline at end of file diff --git a/src/main/scala/de/retest/guistatemachine/api/Action.scala b/src/main/scala/de/retest/guistatemachine/api/Action.scala index 1b6f7f1..aa77304 100644 --- a/src/main/scala/de/retest/guistatemachine/api/Action.scala +++ b/src/main/scala/de/retest/guistatemachine/api/Action.scala @@ -2,9 +2,10 @@ package de.retest.guistatemachine.api /** * Interaction from the user with the GUI. + * TODO #6 Use an abstract representation of actions from retest-model instead of Selenium. */ case class Action(a: org.openqa.selenium.interactions.Action) { - // TODO #5 Convert abstract representation of actions into string. + // TODO #6 Convert abstract representation of actions into string. override def toString: String = "Selenium Action" } \ No newline at end of file diff --git a/src/main/scala/de/retest/guistatemachine/api/State.scala b/src/main/scala/de/retest/guistatemachine/api/State.scala index 87c65db..b82047c 100644 --- a/src/main/scala/de/retest/guistatemachine/api/State.scala +++ b/src/main/scala/de/retest/guistatemachine/api/State.scala @@ -2,16 +2,24 @@ package de.retest.guistatemachine.api /** * A state should be identified by its corresponding [[Descriptors]]. - * It consists of actions which have not been explored yet and transitions which build up the state machine. + * It consists of actions which have not been explored yet and transitions to states which build up the state machine. */ trait State { + + /** + * @return The descriptors which identify this state. + */ def getDescriptors: Descriptors + /** + * @return All actions which have not already been explored/executed from this state. + */ def getNeverExploredActions: Set[Action] /** * NFA states can lead to different states by consuming the same symbol. * Hence, we have a set of states per action. + * In the legacy code there was a type called `AmbigueState` but a multimap simplifies the implementation. */ def getTransitions: Map[Action, Set[State]] @@ -39,4 +47,4 @@ trait State { override def hashCode(): Int = this.getDescriptors.hashCode() override def toString: String = s"descriptors=${getDescriptors},neverExploredActions=${getNeverExploredActions},transitions=${getTransitions}" -} \ No newline at end of file +} diff --git a/src/main/scala/de/retest/guistatemachine/api/impl/GuiStateMachineApiImpl.scala b/src/main/scala/de/retest/guistatemachine/api/impl/GuiStateMachineApiImpl.scala index c440e39..31f5532 100644 --- a/src/main/scala/de/retest/guistatemachine/api/impl/GuiStateMachineApiImpl.scala +++ b/src/main/scala/de/retest/guistatemachine/api/impl/GuiStateMachineApiImpl.scala @@ -6,7 +6,6 @@ import de.retest.guistatemachine.api.GuiStateMachine import scala.collection.mutable.HashSet object GuiStateMachineApiImpl extends GuiStateMachineApi { - // TODO #4 Use Persistence instead of a custom set? val stateMachines = new HashSet[GuiStateMachine] override def createStateMachine: GuiStateMachine = { diff --git a/src/main/scala/de/retest/guistatemachine/api/impl/StateImpl.scala b/src/main/scala/de/retest/guistatemachine/api/impl/StateImpl.scala index 2556093..711c132 100644 --- a/src/main/scala/de/retest/guistatemachine/api/impl/StateImpl.scala +++ b/src/main/scala/de/retest/guistatemachine/api/impl/StateImpl.scala @@ -8,6 +8,7 @@ class StateImpl(val descriptors: Descriptors, var neverExploredActions: Set[Acti /** * TODO #4 Currently, there is no MultiMap trait for immutable maps in the Scala standard library. + * The legacy code used `AmbigueState` here which was more complicated than just a multi map. */ var transitions = new HashMap[Action, Set[State]] @@ -24,4 +25,4 @@ class StateImpl(val descriptors: Descriptors, var neverExploredActions: Set[Acti transitions = transitions + (a -> (transitions(a) + to)) } } -} \ No newline at end of file +} diff --git a/src/main/scala/de/retest/guistatemachine/persistence/Persistence.scala b/src/main/scala/de/retest/guistatemachine/persistence/Persistence.scala index c5b4d6e..94ddb7c 100644 --- a/src/main/scala/de/retest/guistatemachine/persistence/Persistence.scala +++ b/src/main/scala/de/retest/guistatemachine/persistence/Persistence.scala @@ -12,7 +12,7 @@ class Persistence { def getStateMachine(id: Id): Option[StateMachine] = if (stateMachines.stateMachines.hasElement(id)) Some(stateMachines.stateMachines.getElement(id)) else None - // TODO #4 Pass all unexplored actions for the initial state! + // TODO #1 Pass all unexplored actions for the initial state! def createStateMachine(): Id = stateMachines.stateMachines.addNewElement(StateMachine()) def deleteStateMachine(id: Id): Boolean = stateMachines.stateMachines.removeElement(id) diff --git a/src/main/scala/de/retest/guistatemachine/rest/WebServer.scala b/src/main/scala/de/retest/guistatemachine/rest/WebServer.scala index 625be27..f53775f 100644 --- a/src/main/scala/de/retest/guistatemachine/rest/WebServer.scala +++ b/src/main/scala/de/retest/guistatemachine/rest/WebServer.scala @@ -48,5 +48,6 @@ object WebServer extends App with RestService { bindingFuture .flatMap(_.unbind()) // trigger unbinding from the port .onComplete(_ => system.terminate()) // and shutdown when done + case None => println("Missing config.") } -} \ No newline at end of file +}