Commit 0977ebed authored by Tom Käsler's avatar Tom Käsler

implement package/directory structure for tests

parent 070d242d
Pipeline #7860 passed with stage
in 2 minutes and 18 seconds
import services.BaseService package de.thm.arsnova
import models.User
import de.thm.arsnova.services.BaseService
import de.thm.arsnova.models._
import de.thm.arsnova.utils.{DatabaseConfig, MigrationConfig}
import akka.event.{ NoLogging, LoggingAdapter } import akka.event.{ NoLogging, LoggingAdapter }
import utils.MigrationConfig
import org.scalatest._ import org.scalatest._
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration._ import scala.concurrent.duration._
import services.BaseService
import models._
import scala.language.existentials import scala.language.existentials
import org.scalatest.BeforeAndAfterEach import org.scalatest.BeforeAndAfterEach
import utils.DatabaseConfig
class BaseServiceSpec extends FunSpec with Matchers with MigrationConfig with BeforeAndAfterAll with DatabaseConfig class BaseServiceSpec extends FunSpec with Matchers with MigrationConfig with BeforeAndAfterAll with DatabaseConfig
with BaseService with HateoasSpec with SessionApiSpec with QuestionApiSpec with FreetextAnswerApiSpec with ChoiceAnswerApiSpec with CommentApiSpec with BaseService with HateoasSpec with SessionApiSpec with QuestionApiSpec with FreetextAnswerApiSpec with ChoiceAnswerApiSpec with CommentApiSpec
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, SessionService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.ChoiceAnswerApi
import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode} import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode}
import services.{BaseService, SessionService}
import models._
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import models._
import api.ChoiceAnswerApi
import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.Unmarshal import akka.http.scaladsl.unmarshalling.Unmarshal
...@@ -13,7 +15,6 @@ import scala.concurrent.Future ...@@ -13,7 +15,6 @@ import scala.concurrent.Future
import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.Matchers import org.scalatest.Matchers
import services.BaseService
import org.scalatest._ import org.scalatest._
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration._ import scala.concurrent.duration._
...@@ -21,7 +22,7 @@ import akka.http.scaladsl.server.MissingQueryParamRejection ...@@ -21,7 +22,7 @@ import akka.http.scaladsl.server.MissingQueryParamRejection
trait ChoiceAnswerApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes trait ChoiceAnswerApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes
with TestData with ChoiceAnswerApi { with TestData with ChoiceAnswerApi {
import mappings.ChoiceAnswerJsonProtocol._ import de.thm.arsnova.mappings.ChoiceAnswerJsonProtocol._
describe("ChoiceAnswer api") { describe("ChoiceAnswer api") {
it("retrieve choice answers for question") { it("retrieve choice answers for question") {
Get("/question/5/choiceAnswer") ~> choiceAnswerApi ~> check { Get("/question/5/choiceAnswer") ~> choiceAnswerApi ~> check {
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, SessionService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.CommentApi
import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode} import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode}
import services.{BaseService, SessionService}
import models._
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import models._
import api.CommentApi
import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.Unmarshal import akka.http.scaladsl.unmarshalling.Unmarshal
import scala.concurrent.Future
import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.Matchers import org.scalatest.Matchers
import services.BaseService
import org.scalatest._ import org.scalatest._
import scala.concurrent.{Future, Await}
import scala.concurrent.Await
import scala.concurrent.duration._ import scala.concurrent.duration._
import akka.http.scaladsl.server.MissingQueryParamRejection import akka.http.scaladsl.server.MissingQueryParamRejection
trait CommentApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes trait CommentApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes
with TestData with CommentApi { with TestData with CommentApi {
import mappings.CommentJsonProtocol._ import de.thm.arsnova.mappings.CommentJsonProtocol._
describe("Comment api") { describe("Comment api") {
it("retrieve comment by id") { it("retrieve comment by id") {
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, FeaturesService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.FeaturesApi
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{FunSpec, Matchers} import org.scalatest.{FunSpec, Matchers}
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import services.BaseService
import models._
import api.FeaturesApi
import services.FeaturesService
import spray.json._ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.{HttpEntity, MediaTypes} import akka.http.scaladsl.model.{HttpEntity, MediaTypes}
...@@ -12,7 +14,7 @@ import akka.http.scaladsl.model.StatusCodes._ ...@@ -12,7 +14,7 @@ import akka.http.scaladsl.model.StatusCodes._
trait FeaturesApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes trait FeaturesApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes
with TestData with FeaturesApi { with TestData with FeaturesApi {
import mappings.FeatureJsonProtocol._ import de.thm.arsnova.mappings.FeatureJsonProtocol._
describe("Features api") { describe("Features api") {
it("retrieve features by id") { it("retrieve features by id") {
Get("/features/1") ~> featuresApi ~> check { Get("/features/1") ~> featuresApi ~> check {
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, SessionService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.FreetextAnswerApi
import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode} import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode}
import services.{BaseService, SessionService}
import models._
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import models._
import api.FreetextAnswerApi
import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.Unmarshal import akka.http.scaladsl.unmarshalling.Unmarshal
import scala.concurrent.Future
import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.Matchers import org.scalatest.Matchers
import services.BaseService
import org.scalatest._ import org.scalatest._
import scala.concurrent.Await import scala.concurrent.{Future, Await}
import scala.concurrent.duration._ import scala.concurrent.duration._
import akka.http.scaladsl.server.MissingQueryParamRejection import akka.http.scaladsl.server.MissingQueryParamRejection
trait FreetextAnswerApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes trait FreetextAnswerApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes
with TestData with FreetextAnswerApi { with TestData with FreetextAnswerApi {
import mappings.FreetextAnswerJsonProtocol._ import de.thm.arsnova.mappings.FreetextAnswerJsonProtocol._
describe("FreetextAnswer api") { describe("FreetextAnswer api") {
it("retrieve freetext answers for question") { it("retrieve freetext answers for question") {
Get("/question/1/freetextAnswer") ~> freetextAnswerApi ~> check { Get("/question/1/freetextAnswer") ~> freetextAnswerApi ~> check {
......
package de.thm.arsnova
import de.thm.arsnova.services.BaseService
import de.thm.arsnova.hateoas._
import de.thm.arsnova.api._
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{FunSpec, Matchers} import org.scalatest.{FunSpec, Matchers}
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import services.BaseService import scala.concurrent.{Future, Await}
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration._ import scala.concurrent.duration._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.unmarshalling.Unmarshal import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.http.scaladsl.server.Route import akka.http.scaladsl.server.Route
import hateoas._
import api._
trait HateoasSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes { trait HateoasSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes {
import hateoas.LinkJsonProtocol._ import hateoas.LinkJsonProtocol._
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, SessionService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.QuestionApi
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.unmarshalling._ import akka.http.scaladsl.unmarshalling._
import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode} import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode}
import services.{BaseService, SessionService}
import models._
import api.QuestionApi
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Directives._
import scala.concurrent.Future import scala.concurrent.Future
import scala.util.{Failure, Success} import scala.util.{Failure, Success}
import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.StatusCodes._
...@@ -16,7 +18,7 @@ import akka.http.scaladsl.server.MissingQueryParamRejection ...@@ -16,7 +18,7 @@ import akka.http.scaladsl.server.MissingQueryParamRejection
import org.scalatest.{FunSpec, Matchers} import org.scalatest.{FunSpec, Matchers}
trait QuestionApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes with TestData with QuestionApi { trait QuestionApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes with TestData with QuestionApi {
import mappings.QuestionJsonProtocol._ import de.thm.arsnova.mappings.QuestionJsonProtocol._
// you need to call unmarshal because of the question trait // you need to call unmarshal because of the question trait
describe("Question api") { describe("Question api") {
it("retrieve question by id 1") { it("retrieve question by id 1") {
......
package de.thm.arsnova
import de.thm.arsnova.services.{BaseService, SessionService}
import de.thm.arsnova.models._
import de.thm.arsnova.api.SessionApi
import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode} import akka.http.scaladsl.model.{HttpEntity, MediaTypes, StatusCode}
import services.{BaseService, SessionService}
import models._
import api.SessionApi
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
import spray.json._ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import models._
import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.Unmarshal import akka.http.scaladsl.unmarshalling.Unmarshal
...@@ -13,12 +15,11 @@ import scala.concurrent.Future ...@@ -13,12 +15,11 @@ import scala.concurrent.Future
import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.Matchers import org.scalatest.Matchers
import services.BaseService
import org.scalatest._ import org.scalatest._
import akka.http.scaladsl.server.MissingQueryParamRejection import akka.http.scaladsl.server.MissingQueryParamRejection
trait SessionApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes with TestData with SessionApi { trait SessionApiSpec extends FunSpec with Matchers with ScalaFutures with BaseService with ScalatestRouteTest with Routes with TestData with SessionApi {
import mappings.SessionJsonProtocol._ import de.thm.arsnova.mappings.SessionJsonProtocol._
describe("Session api") { describe("Session api") {
it("retrieve sessions for user 1") { it("retrieve sessions for user 1") {
......
import models._ package de.thm.arsnova
import de.thm.arsnova.models._
trait TestData { trait TestData {
val FOUR = 4 val FOUR = 4
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment