From 66603e5e89616711da64828363f743de5c18b6fa Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Mon, 13 Jun 2022 11:53:50 +0200 Subject: [PATCH] [BE2] migrate code to scala3 --- be2-scala/build.sbt | 14 +++++--------- be2-scala/project/plugins.sbt | 1 - be2-scala/src/main/scala/ch/epfl/pop/Server.scala | 2 +- .../scala/ch/epfl/pop/json/HighLevelProtocol.scala | 10 +++++----- .../epfl/pop/model/objects/ElectionChannel.scala | 2 +- .../scala/ch/epfl/pop/pubsub/ClientActor.scala | 4 ++-- .../scala/ch/epfl/pop/pubsub/graph/Answerer.scala | 2 +- .../pop/pubsub/graph/handlers/LaoHandler.scala | 2 +- .../pop/pubsub/graph/handlers/ParamsHandler.scala | 2 +- .../pubsub/graph/handlers/RollCallHandler.scala | 2 +- .../pubsub/graph/handlers/SocialMediaHandler.scala | 4 ++-- .../ch/epfl/pop/model/objects/ChannelSuite.scala | 1 - .../pop/pubsub/graph/AnswerGeneratorSuite.scala | 2 +- .../graph/handlers/ElectionHandlerTest.scala | 6 +++--- .../graph/handlers/RollCallHandlerTest.scala | 2 +- .../graph/handlers/SocialMediaHandlerSuite.scala | 2 +- .../graph/validators/ElectionValidatorSuite.scala | 8 ++++---- .../graph/validators/LaoValidatorSuite.scala | 2 +- .../graph/validators/MessageValidatorSuite.scala | 2 +- .../graph/validators/RollCallValidatorSuite.scala | 8 +++----- .../validators/SocialMediaValidatorSuite.scala | 2 +- .../scala/ch/epfl/pop/storage/DbActorSuite.scala | 2 +- 22 files changed, 37 insertions(+), 45 deletions(-) diff --git a/be2-scala/build.sbt b/be2-scala/build.sbt index 04ba261a75..ee936d2ae6 100644 --- a/be2-scala/build.sbt +++ b/be2-scala/build.sbt @@ -3,7 +3,7 @@ import sbtsonar.SonarPlugin.autoImport.sonarProperties name := "pop" -scalaVersion := "2.13.7" +scalaVersion := "3.1.2" // Recommended 2.13 Scala flags (https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13) slightly adapted for PoP scalacOptions ++= Seq( @@ -15,11 +15,7 @@ scalacOptions ++= Seq( "-language:higherKinds", // Allow higher-kinded types "-language:implicitConversions", // Allow definition of implicit functions called views "-unchecked", // Enable additional warnings where generated code depends on assumptions. - "-check-init", // Wrap field accessors to throw an exception on uninitialized access. "-Xfatal-warnings", // Fail the compilation if there are any warnings. - "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. - "-Ycache-plugin-class-loader:last-modified", // Enables caching of classloaders for compiler plugins - "-Ycache-macro-class-loader:last-modified", // and macro definitions. This can lead to performance improvements. ) // Reload changes automatically @@ -85,9 +81,9 @@ sonarProperties := Map( "sonar.tests" -> "src/test/scala", "sonar.sourceEncoding" -> "UTF-8", - "sonar.scala.version" -> "2.13.7", + "sonar.scala.version" -> scalaVersion.value, // Paths to the test and coverage reports - "sonar.scala.coverage.reportPaths" -> "./target/scala-2.13/scoverage-report/scoverage.xml", + "sonar.scala.coverage.reportPaths" -> "./target/scala-3.1/scoverage-report/scoverage.xml", ) assembly/ assemblyMergeStrategy := { @@ -107,7 +103,7 @@ val AkkaHttpVersion = "10.2.9" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-stream-typed" % AkkaVersion, // Akka streams (Graph) - "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion, // Akka http (WebSockets) + ("com.typesafe.akka" %% "akka-http" % AkkaHttpVersion).cross(CrossVersion.for3Use2_13), // Akka http (WebSockets) "com.typesafe.akka" %% "akka-cluster-tools" % AkkaVersion, // Akka distributed publish/subscribe cluster "ch.qos.logback" % "logback-classic" % "1.1.3" % Runtime, // Akka logging library @@ -127,7 +123,7 @@ libraryDependencies += "com.google.crypto.tink" % "tink" % "1.5.0" libraryDependencies += "ch.epfl.dedis" % "cothority" % "3.3.1" // Scala unit tests -libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.9" % Test +libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.12" % Test // Json Schema Validator w/ Jackson Databind libraryDependencies += "com.networknt" % "json-schema-validator" % "1.0.60" diff --git a/be2-scala/project/plugins.sbt b/be2-scala/project/plugins.sbt index 6cc7a61b62..f193421344 100644 --- a/be2-scala/project/plugins.sbt +++ b/be2-scala/project/plugins.sbt @@ -2,4 +2,3 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("com.sonar-scala" % "sbt-sonar" % "2.3.0") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0") addSbtPlugin("com.rallyhealth.sbt" % "sbt-git-versioning" % "1.6.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.1") diff --git a/be2-scala/src/main/scala/ch/epfl/pop/Server.scala b/be2-scala/src/main/scala/ch/epfl/pop/Server.scala index 8962d90a09..677b02e93d 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/Server.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/Server.scala @@ -7,7 +7,7 @@ import akka.actor.{ActorRef, Props} import akka.http.scaladsl.Http import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.{RequestContext, RouteResult} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.util.Timeout import ch.epfl.pop.config.{RuntimeEnvironment, ServerConf} import ch.epfl.pop.pubsub.{MessageRegistry, PubSubMediator, PublishSubscribe} diff --git a/be2-scala/src/main/scala/ch/epfl/pop/json/HighLevelProtocol.scala b/be2-scala/src/main/scala/ch/epfl/pop/json/HighLevelProtocol.scala index b714b5efe6..05d70f7405 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/json/HighLevelProtocol.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/json/HighLevelProtocol.scala @@ -84,13 +84,13 @@ object HighLevelProtocol extends DefaultJsonProtocol { Broadcast(params.channel, params.message) } - override def write(obj: Broadcast): JsValue = obj.toJson(ParamsFormat.write) + override def write(obj: Broadcast): JsValue = obj.toJson(ParamsFormat.write _) } implicit object CatchupFormat extends RootJsonFormat[Catchup] { override def read(json: JsValue): Catchup = Catchup(json.convertTo[Params].channel) - override def write(obj: Catchup): JsValue = obj.toJson(ParamsFormat.write) + override def write(obj: Catchup): JsValue = obj.toJson(ParamsFormat.write _) } implicit object PublishFormat extends RootJsonFormat[Publish] { @@ -99,19 +99,19 @@ object HighLevelProtocol extends DefaultJsonProtocol { Publish(params.channel, params.message) } - override def write(obj: Publish): JsValue = obj.toJson(ParamsFormat.write) + override def write(obj: Publish): JsValue = obj.toJson(ParamsFormat.write _) } implicit object SubscribeFormat extends RootJsonFormat[Subscribe] { override def read(json: JsValue): Subscribe = Subscribe(json.convertTo[Params].channel) - override def write(obj: Subscribe): JsValue = obj.toJson(ParamsFormat.write) + override def write(obj: Subscribe): JsValue = obj.toJson(ParamsFormat.write _) } implicit object UnsubscribeFormat extends RootJsonFormat[Unsubscribe] { override def read(json: JsValue): Unsubscribe = Unsubscribe(json.convertTo[Params].channel) - override def write(obj: Unsubscribe): JsValue = obj.toJson(ParamsFormat.write) + override def write(obj: Unsubscribe): JsValue = obj.toJson(ParamsFormat.write _) } diff --git a/be2-scala/src/main/scala/ch/epfl/pop/model/objects/ElectionChannel.scala b/be2-scala/src/main/scala/ch/epfl/pop/model/objects/ElectionChannel.scala index 8b2f3d8ff1..ce5c4cbc56 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/model/objects/ElectionChannel.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/model/objects/ElectionChannel.scala @@ -20,7 +20,7 @@ object ElectionChannel { * @tparam T type of data to extract from the election channel * @return Future of a list of tuple containing the message and the data extracted */ - def extractMessages[T: Manifest](dbActor: AskableActorRef = DbActor.getInstance): Future[List[(Message, T)]] = { + def extractMessages[T: reflect.ClassTag](dbActor: AskableActorRef = DbActor.getInstance): Future[List[(Message, T)]] = { for { DbActor.DbActorCatchupAck(messages) <- dbActor ? DbActor.Catchup(channel) result <- Future.traverse(messages.flatMap(message => diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/ClientActor.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/ClientActor.scala index a8fbc7f666..94f3417022 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/ClientActor.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/ClientActor.scala @@ -2,7 +2,7 @@ package ch.epfl.pop.pubsub import akka.actor.{Actor, ActorLogging, ActorRef, Props} import akka.event.LoggingReceive -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import ch.epfl.pop.model.objects.Channel import ch.epfl.pop.pubsub.ClientActor._ import ch.epfl.pop.pubsub.PubSubMediator._ @@ -93,7 +93,7 @@ object ClientActor { final case class ConnectWsHandle(wsClient: ActorRef) extends Event // unsubscribe from all channels - final case object DisconnectWsHandle extends Event + case object DisconnectWsHandle extends Event // subscribe to a particular channel final case class SubscribeTo(channel: Channel) extends Event diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/Answerer.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/Answerer.scala index 5ea8ade042..c44a9080fe 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/Answerer.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/Answerer.scala @@ -45,7 +45,7 @@ object Answerer { // Send the ClientAnswer to clientActorRef. Whenever the stream between the client // actor and the actual client (front-end) is broken, the message DisconnectWsHandle // is sent to clientActorRef - .to(Sink.actorRef(clientActorRef, DisconnectWsHandle, { t: Throwable => println(t); DisconnectWsHandle })) + .to(Sink.actorRef(clientActorRef, DisconnectWsHandle, { (t: Throwable) => println(t); DisconnectWsHandle })) // Integration point between Akka Streams and above actor val source: Source[TextMessage, NotUsed] = Source diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/LaoHandler.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/LaoHandler.scala index 16d4ab43f0..96971700f2 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/LaoHandler.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/LaoHandler.scala @@ -54,7 +54,7 @@ case object LaoHandler extends MessageHandler { _ <- dbActor ? DbActor.WriteLaoData(laoChannel, message, address) //after creating the lao, we need to send a lao#greet message to the frontend greet: GreetLao = GreetLao(data.id, params.get.sender, address.get, List.empty) - broadcastGreet: Base64Data = Base64Data.encode(GreetLaoFormat.write(greet).toString()) + broadcastGreet: Base64Data = Base64Data.encode(GreetLaoFormat.write(greet).toString) _ <- dbBroadcast(rpcMessage, laoChannel, broadcastGreet, laoChannel) } yield () diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/ParamsHandler.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/ParamsHandler.scala index f54ffac40b..3fd3ac44e1 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/ParamsHandler.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/ParamsHandler.scala @@ -2,7 +2,7 @@ package ch.epfl.pop.pubsub.graph.handlers import akka.NotUsed import akka.actor.ActorRef -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.stream.FlowShape import akka.stream.scaladsl.{Flow, GraphDSL, Merge, Partition} import ch.epfl.pop.model.network.method.{Catchup, Subscribe, Unsubscribe} diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandler.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandler.scala index b2601ea98c..2c8dc9893c 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandler.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandler.scala @@ -174,7 +174,7 @@ class RollCallHandler(dbRef: => AskableActorRef) extends MessageHandler { )) } case error@Right(_) => error - case _ => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswer, rpcRequest.id)) + case null => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswer, rpcRequest.id)) } } diff --git a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandler.scala b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandler.scala index 1434ff17ed..a91c10eae8 100644 --- a/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandler.scala +++ b/be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandler.scala @@ -58,7 +58,7 @@ class SocialMediaHandler(dbRef: => AskableActorRef) extends MessageHandler { case None => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, "Server failed to extract LAO id for the broadcast", rpcMessage.id)) } case error@Right(_) => error - case _ => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswerDatabase, rpcMessage.id)) + case null => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswerDatabase, rpcMessage.id)) } } @@ -81,7 +81,7 @@ class SocialMediaHandler(dbRef: => AskableActorRef) extends MessageHandler { case None => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, "Server failed to extract LAO id for the broadcast", rpcMessage.id)) } case error@Right(_) => error - case _ => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswerDatabase, rpcMessage.id)) + case null => Right(PipelineError(ErrorCodes.SERVER_ERROR.id, unknownAnswerDatabase, rpcMessage.id)) } } diff --git a/be2-scala/src/test/scala/ch/epfl/pop/model/objects/ChannelSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/model/objects/ChannelSuite.scala index edbd307ea3..b34b88574a 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/model/objects/ChannelSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/model/objects/ChannelSuite.scala @@ -64,7 +64,6 @@ class ChannelSuite extends AnyFunSuite with should.Matchers { def channel = Channel("/root/full/pop") val expected = Hash(Base64Data("pop")) - an[IllegalArgumentException] shouldNot be(thrownBy(channel)) channel.extractChildChannel should equal(expected) } test("Encoded LaoId extraction channel test") { diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/AnswerGeneratorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/AnswerGeneratorSuite.scala index ab4e38236e..77d453ea10 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/AnswerGeneratorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/AnswerGeneratorSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph import akka.actor.{Actor, ActorSystem, Props, Status} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.model.network.method.message.Message diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/ElectionHandlerTest.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/ElectionHandlerTest.scala index 86095fc635..fa216bf9d0 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/ElectionHandlerTest.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/ElectionHandlerTest.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.handlers import akka.actor.{Actor, ActorSystem, Props, Status} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.model.network.method.message.Message @@ -36,12 +36,12 @@ class ElectionHandlerTest extends TestKit(ActorSystem("Election-DB-System")) wit private val keyPair: KeyPair = KeyPair() private val electionData: ElectionData = ElectionData(Hash(Base64Data.encode("election")), keyPair) - private final val sender: PublicKey = SetupElectionExamples.SENDER_SETUPELECTION + private final val SENDER: PublicKey = SetupElectionExamples.SENDER_SETUPELECTION private final val PUBLIC_KEY: PublicKey = PublicKey(Base64Data("jsNj23IHALvppqV1xQfP71_3IyAHzivxiCz236_zzQc=")) private final val PRIVATE_KEY: PrivateKey = PrivateKey(Base64Data("qRfms3wzSLkxAeBz6UtwA-L1qP0h8D9XI1FSvY68t7Y=")) private final val PK_OWNER: PublicKey = PublicKey(Base64Data.encode("wrongOwner")) - private final val laoDataRight: LaoData = LaoData(sender, List(sender), PRIVATE_KEY, PUBLIC_KEY, List.empty) + private final val laoDataRight: LaoData = LaoData(SENDER, List(SENDER), PRIVATE_KEY, PUBLIC_KEY, List.empty) private final val channelDataWithSetupAndOpenAndCastMessage: ChannelData = ChannelData(ObjectType.ELECTION, List(DATA_CAST_VOTE_MESSAGE, DATA_SET_UP_OPEN_BALLOT, DATA_OPEN_MESSAGE)) private final val messages: List[Message] = List(MESSAGE_CAST_VOTE_ELECTION_WORKING, MESSAGE_SETUPELECTION_OPEN_BALLOT_WORKING, MESSAGE_OPEN_ELECTION_WORKING, MESSAGE_END_ELECTION_WORKING) diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandlerTest.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandlerTest.scala index ad8757578b..cb1d1b63af 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandlerTest.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/RollCallHandlerTest.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.handlers import akka.actor.{Actor, ActorSystem, Props, Status} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.model.objects.DbActorNAckException diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandlerSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandlerSuite.scala index c88bfff911..e71d0b6af0 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandlerSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/handlers/SocialMediaHandlerSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.handlers import akka.actor.{Actor, ActorSystem, Props, Status} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.model.objects.DbActorNAckException diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/ElectionValidatorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/ElectionValidatorSuite.scala index 4ca5ed7801..88ef5b02c0 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/ElectionValidatorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/ElectionValidatorSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.validators import akka.actor.{Actor, ActorRef, ActorSystem, Props} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively @@ -46,12 +46,12 @@ class ElectionValidatorSuite extends TestKit(ActorSystem("electionValidatorTestA deleteRecursively(directory) } - private final val sender: PublicKey = SetupElectionExamples.SENDER_SETUPELECTION + private final val SENDER: PublicKey = SetupElectionExamples.SENDER_SETUPELECTION private final val PUBLIC_KEY: PublicKey = PublicKey(Base64Data("jsNj23IHALvppqV1xQfP71_3IyAHzivxiCz236_zzQc=")) private final val PRIVATE_KEY: PrivateKey = PrivateKey(Base64Data("qRfms3wzSLkxAeBz6UtwA-L1qP0h8D9XI1FSvY68t7Y=")) private final val PK_WRONG: PublicKey = PublicKey(Base64Data.encode("wrongOwner")) - private final val laoDataRight: LaoData = LaoData(sender, List(sender), PRIVATE_KEY, PUBLIC_KEY, List.empty) + private final val laoDataRight: LaoData = LaoData(SENDER, List(SENDER), PRIVATE_KEY, PUBLIC_KEY, List.empty) private final val laoDataWrong: LaoData = LaoData(PK_WRONG, List(PK_WRONG), PRIVATE_KEY, PUBLIC_KEY, List.empty) private final val channelDataRightSetup: ChannelData = ChannelData(ObjectType.LAO, List.empty) private final val channelDataWrongSetup: ChannelData = ChannelData(ObjectType.ELECTION, List.empty) @@ -433,7 +433,7 @@ class ElectionValidatorSuite extends TestKit(ActorSystem("electionValidatorTestA test("Open up an election with invalid lao id fails") { val dbActorRef = mockDbWorking val message: GraphMessage = new ElectionValidator(dbActorRef).validateOpenElection(OPEN_ELECTION_WRONG_LAO_ID_RPC) - val messageStandardActor: GraphMessage = ElectionValidator.validateOpenElection(OPEN_ELECTION_WRONG_LAO_ID_RPC) + val messageStandardActor: GraphMessage = ElectionValidator.validateOpenElection(OPEN_ELECTION_WRONG_LAO_ID_RPC) message shouldBe a[Right[_, PipelineError]] messageStandardActor shouldBe a[Right[_, PipelineError]] system.stop(dbActorRef.actorRef) diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/LaoValidatorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/LaoValidatorSuite.scala index 4e75e74ce5..a4ce7ebc86 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/LaoValidatorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/LaoValidatorSuite.scala @@ -5,7 +5,7 @@ import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively import ch.epfl.pop.model.network.method.message.data.ObjectType import ch.epfl.pop.model.objects.{Base64Data, ChannelData, LaoData, PrivateKey, PublicKey} import ch.epfl.pop.storage.{DbActor, InMemoryStorage} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.pubsub.graph.{GraphMessage, PipelineError} diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/MessageValidatorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/MessageValidatorSuite.scala index dccd9a3086..15b367a4d0 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/MessageValidatorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/MessageValidatorSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.validators import akka.actor.{Actor, ActorSystem, Props, Status} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.model.network.method.message.data.ObjectType diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/RollCallValidatorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/RollCallValidatorSuite.scala index c5ff644635..19b1d05913 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/RollCallValidatorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/RollCallValidatorSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.pubsub.graph.validators import akka.actor.{Actor, ActorRef, ActorSystem, Props} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively @@ -46,13 +46,11 @@ class RollCallValidatorSuite extends TestKit(ActorSystem("rollcallValidatorTestA deleteRecursively(directory) } - private final val sender: PublicKey = SENDER - private final val PUBLIC_KEY: PublicKey = PublicKey(Base64Data("jsNj23IHALvppqV1xQfP71_3IyAHzivxiCz236_zzQc=")) private final val PRIVATE_KEY: PrivateKey = PrivateKey(Base64Data("qRfms3wzSLkxAeBz6UtwA-L1qP0h8D9XI1FSvY68t7Y=")) private final val PK_OWNER: PublicKey = PublicKey(Base64Data.encode("wrongOwner")) - private final val laoDataRight: LaoData = LaoData(sender, List(sender), PRIVATE_KEY, PUBLIC_KEY, List.empty) - private final val laoDataWrong: LaoData = LaoData(sender, List(PK_OWNER), PRIVATE_KEY, PUBLIC_KEY, List.empty) + private final val laoDataRight: LaoData = LaoData(SENDER, List(SENDER), PRIVATE_KEY, PUBLIC_KEY, List.empty) + private final val laoDataWrong: LaoData = LaoData(SENDER, List(PK_OWNER), PRIVATE_KEY, PUBLIC_KEY, List.empty) private final val channelDataWrong: ChannelData = ChannelData(ObjectType.INVALID, List.empty) private final val channelDataRight: ChannelData = ChannelData(ObjectType.LAO, List.empty) private final val rollcallDataCreate: RollCallData = RollCallData(CreateRollCallExamples.R_ID, ActionType.CREATE) diff --git a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/SocialMediaValidatorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/SocialMediaValidatorSuite.scala index 5f13364815..9dc053fb6f 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/SocialMediaValidatorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/pubsub/graph/validators/SocialMediaValidatorSuite.scala @@ -4,7 +4,7 @@ import java.io.File import java.util.concurrent.TimeUnit import akka.actor.{Actor, ActorRef, ActorSystem, Props} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import akka.util.Timeout import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively diff --git a/be2-scala/src/test/scala/ch/epfl/pop/storage/DbActorSuite.scala b/be2-scala/src/test/scala/ch/epfl/pop/storage/DbActorSuite.scala index 936d9a409b..3292c8ae44 100644 --- a/be2-scala/src/test/scala/ch/epfl/pop/storage/DbActorSuite.scala +++ b/be2-scala/src/test/scala/ch/epfl/pop/storage/DbActorSuite.scala @@ -1,7 +1,7 @@ package ch.epfl.pop.storage import akka.actor.{ActorRef, ActorSystem, Props} -import akka.pattern.AskableActorRef +import akka.pattern.{AskableActorRef, ask} import akka.testkit.{ImplicitSender, TestKit} import ch.epfl.pop.model.network.method.message.Message import ch.epfl.pop.model.network.method.message.data.ActionType.{ActionType, CREATE}