-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
141 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,7 @@ package object api { | |
|
||
val PARENT_UP = "../" | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/scala/com/fluency03/blockchain/api/routes/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.fluency03.blockchain.api | ||
|
||
package object routes { | ||
|
||
// generics | ||
val SLASH = "/" | ||
val GENERIC = "generic" | ||
val TO_SHA256 = "to-sha256" | ||
val TO_BASE64 = "to-base64" | ||
val FROM_BASE64 = "from-base64" | ||
val TO_EPOCH_TIME = "to-epoch-time" | ||
val TIME_FROM_EPOCH = "time-from-epoch" | ||
|
||
def pathOf(seg: String*): String = SLASH + seg.mkString(SLASH) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/test/scala/com/fluency03/blockchain/api/routes/BlockRoutesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.fluency03.blockchain.api.routes | ||
|
||
class BlockRoutesTest { | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import org.scalatest.{Matchers, WordSpec} | ||
|
||
class BlockRoutesTest extends WordSpec with Matchers with ScalatestRouteTest { | ||
|
||
} |
9 changes: 8 additions & 1 deletion
9
src/test/scala/com/fluency03/blockchain/api/routes/BlockchainRoutesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
package com.fluency03.blockchain.api.routes | ||
|
||
class BlockchainRoutesTest { | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import org.scalatest.{Matchers, WordSpec} | ||
|
||
class BlockchainRoutesTest extends WordSpec with Matchers with ScalatestRouteTest { | ||
|
||
|
||
|
||
|
||
|
||
} |
49 changes: 48 additions & 1 deletion
49
src/test/scala/com/fluency03/blockchain/api/routes/GenericRoutesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,52 @@ | ||
package com.fluency03.blockchain.api.routes | ||
|
||
class GenericRoutesTest { | ||
import akka.http.scaladsl.model.StatusCodes | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import com.fluency03.blockchain.api.{Input, JsonSupport, SuccessMsg} | ||
import org.scalatest.{Matchers, WordSpec} | ||
import com.fluency03.blockchain.api.Server.genericRoutes | ||
|
||
class GenericRoutesTest extends WordSpec with Matchers with ScalatestRouteTest with JsonSupport { | ||
|
||
"GenericRoutes" should { | ||
"return a greeting for GET requests to the root path." in { | ||
Get() ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("Welcome to Blockchain in Scala!") | ||
} | ||
} | ||
|
||
"return corresponding value." in { | ||
Post(pathOf(GENERIC, TO_SHA256), Input("open sesame")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("41ef4bb0b23661e66301aac36066912dac037827b4ae63a7b1165a5aa93ed4eb") | ||
} | ||
|
||
Post(pathOf(GENERIC, TO_SHA256), Input("")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") | ||
} | ||
|
||
Post(pathOf(GENERIC, TO_BASE64), Input("open sesame")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("b3BlbiBzZXNhbWU=") | ||
} | ||
|
||
Post(pathOf(GENERIC, FROM_BASE64), Input("b3BlbiBzZXNhbWU=")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("open sesame") | ||
} | ||
|
||
Post(pathOf(GENERIC, TO_EPOCH_TIME), Input("2018-04-11T18:52:01Z")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("1523472721") | ||
} | ||
|
||
Post(pathOf(GENERIC, TIME_FROM_EPOCH), Input("1523472721")) ~> genericRoutes ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[SuccessMsg] shouldEqual SuccessMsg("2018-04-11T18:52:01Z") | ||
} | ||
} | ||
} | ||
|
||
} |
5 changes: 4 additions & 1 deletion
5
src/test/scala/com/fluency03/blockchain/api/routes/NetworkRoutesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.fluency03.blockchain.api.routes | ||
|
||
class NetworkRoutesTest { | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import org.scalatest.{Matchers, WordSpec} | ||
|
||
class NetworkRoutesTest extends WordSpec with Matchers with ScalatestRouteTest { | ||
|
||
} |
5 changes: 4 additions & 1 deletion
5
src/test/scala/com/fluency03/blockchain/api/routes/TransactionRoutesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.fluency03.blockchain.api.routes | ||
|
||
class TransactionRoutesTest { | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import org.scalatest.{Matchers, WordSpec} | ||
|
||
class TransactionRoutesTest extends WordSpec with Matchers with ScalatestRouteTest { | ||
|
||
} |