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

Commit

Permalink
Remove Furrer model since it is not used anywhere, extend unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdauth committed Oct 25, 2018
1 parent 3a2e07c commit 0feb461
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 92 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions src/main/scala/de/retest/guistatemachine/furrermodel/UIPath.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Persistence {
val apps = guiApplications
apps.synchronized {
val id = apps.apps.generateId
apps.apps.values = apps.apps.values + (id -> new GuiApplication(TestSuites(Map(new HashMap[Id, TestSuite]))))
apps.apps.values = apps.apps.values + (id -> GuiApplication(TestSuites(Map(new HashMap[Id, TestSuite]))))
id
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import de.retest.guistatemachine.model.Id
import de.retest.guistatemachine.model.TestSuite
import scala.collection.immutable.HashMap
import de.retest.guistatemachine.model.Map
import de.retest.guistatemachine.model.GuiApplications
import de.retest.guistatemachine.model.GuiApplication

class JsonFormatForIdMapSpec extends WordSpec with Matchers {

implicit val idFormat = jsonFormat1(Id)
implicit val testSuiteFormat = jsonFormat0(TestSuite)
implicit val hashMapFormatTestSuites = new JsonFormatForIdMap[TestSuite]
implicit val testSuitesFormat = jsonFormat1(TestSuites)
implicit val applicationFormat = jsonFormat1(GuiApplication)
implicit val hashMapFormatApplications = new JsonFormatForIdMap[GuiApplication]
implicit val applicationsFormat = jsonFormat1(GuiApplications)

"The JSON format" should {
"convert an empty test suite into JSON and back" in {
Expand All @@ -37,6 +42,24 @@ class JsonFormatForIdMapSpec extends WordSpec with Matchers {
transformedTestSuites.suites.values.isEmpty shouldEqual false
transformedTestSuites.suites.values.contains(Id(0)) shouldEqual true
}

/**
* Tests nested fields which do both contain a Map.
*/
"convert an application into JSON and back" in {
val testSuites = TestSuites(Map(new HashMap[Id, TestSuite]()))
testSuites.suites.values = testSuites.suites.values + (Id(0) -> TestSuite())
val apps = GuiApplications(Map(new HashMap[Id, GuiApplication]()))
apps.apps.values = apps.apps.values + (Id(0) -> new GuiApplication(testSuites))
val json = apps.toJson
json.toString shouldEqual "{\"apps\":{\"0\":{\"testSuites\":{\"suites\":{\"0\":{}}}}}}"
val transformedApps = json.convertTo[GuiApplications]
transformedApps.apps.values.isEmpty shouldEqual false
transformedApps.apps.values.contains(Id(0)) shouldEqual true
val transformedSuites = transformedApps.apps.values(Id(0)).testSuites.suites.values
transformedSuites.isEmpty shouldEqual false
transformedSuites.contains(Id(0)) shouldEqual true
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class RestServiceSpec extends WordSpec with Matchers with ScalatestRouteTest wit
"The service" should {
"show the default text for the GET request with the path /" in {
Get("/") ~> sut ~> check {
handled shouldEqual true
val r = responseAs[String]
r shouldEqual "GUI State Machine API"
}
Expand All @@ -42,6 +43,7 @@ class RestServiceSpec extends WordSpec with Matchers with ScalatestRouteTest wit

"allow POST for path /create-application" in {
Post("/create-application") ~> sut ~> check {
handled shouldEqual true
responseAs[Id] shouldEqual Id(0)
}
}
Expand All @@ -57,13 +59,16 @@ class RestServiceSpec extends WordSpec with Matchers with ScalatestRouteTest wit

"return an empty list for the GET request with the path /application/0/test-suites" in {
Get("/application/0/test-suites") ~> sut ~> check {
handled shouldEqual true
status shouldEqual StatusCodes.OK
val r = responseAs[TestSuites]
r.suites.values.size shouldEqual 0
}
}

"allow POST for path /application/0/create-test-suite" in {
Post("/application/0/create-test-suite") ~> sut ~> check {
handled shouldEqual true
responseAs[Id] shouldEqual Id(0)
}
}
Expand All @@ -79,6 +84,7 @@ class RestServiceSpec extends WordSpec with Matchers with ScalatestRouteTest wit

"return status OK for the DELETE request with the path /application/0" in {
Delete("/application/0") ~> sut ~> check {
handled shouldEqual true
status shouldEqual StatusCodes.OK
responseAs[String] shouldEqual "OK"
}
Expand Down

0 comments on commit 0feb461

Please sign in to comment.