Skip to content

Commit

Permalink
test: refactor: Limit the target of nowarn annotation
Browse files Browse the repository at this point in the history
- Easy to understand
- Unrelated warnings are not ignored
  • Loading branch information
tksugimoto committed Jul 15, 2021
1 parent 4ceaaa8 commit f563b43
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object ConsistencyTestBase {
}
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class ConsistencyTestReplicationActor() extends ReplicationActor[Int] {

import ConsistencyTestReplicationActor._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ConsistencyTestNormalMultiJvmNode3 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode4 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode5 extends ConsistencyTestNormal

@nowarn // for deprecated ClusterReplication(system).start
@nowarn("msg=method start in class ClusterReplication is deprecated")
class ConsistencyTestNormal extends MultiNodeSpec(ConsistencyTestBaseConfig) with STMultiNodeSpec with Inside {

import ConsistencyTestBaseConfig._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ object RaftActorCompactionSpecConfig extends MultiNodeConfig {
.withFallback(ConfigFactory.parseString("""
akka.actor.provider = cluster
akka.test.single-expect-default = 15s
lerna.akka.entityreplication.raft.multi-raft-roles = ["replica-group-1", "replica-group-2", "replica-group-3"]
// triggers compaction each event replications
lerna.akka.entityreplication.raft.compaction.log-size-threshold = 2
lerna.akka.entityreplication.raft.compaction.preserve-log-size = 1
Expand Down Expand Up @@ -80,7 +80,7 @@ object RaftActorCompactionSpec {

import DummyReplicationActor._

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(0)
Expand Down Expand Up @@ -209,7 +209,7 @@ class RaftActorCompactionSpec extends MultiNodeSpec(RaftActorCompactionSpecConfi
}
}

@nowarn // for deprecated ClusterReplication(system).start
@nowarn("msg=method start in class ClusterReplication is deprecated")
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object RaftEventSourcedSpecConfig extends MultiNodeConfig {
akka.test.single-expect-default = 15s
lerna.akka.entityreplication.raft.multi-raft-roles = ["member-1", "member-2", "member-3"]
lerna.akka.entityreplication.recovery-entity-timeout = 1s
inmemory-journal {
event-adapters {
dummy-event-adapter = "lerna.akka.entityreplication.RaftEventSourcedSpec$DummyEventAdapter"
Expand Down Expand Up @@ -92,7 +92,7 @@ object RaftEventSourcedSpec {

import DummyReplicationActor._

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(count = 0, knownRequestId = Set.empty)
Expand Down Expand Up @@ -152,7 +152,7 @@ object RaftEventSourcedSpec {
}
}

@nowarn // for deprecated ClusterReplication(system).start
@nowarn("msg=method start in class ClusterReplication is deprecated")
class RaftEventSourcedSpec extends MultiNodeSpec(RaftEventSourcedSpecConfig) with STMultiNodeSpec {

import RaftEventSourcedSpec._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class PingPongReplicationActor extends ReplicationActor[Int] {

import PingPongReplicationActor._
Expand Down Expand Up @@ -125,7 +125,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class LockReplicationActor extends ReplicationActor[NotUsed] {
import LockReplicationActor._

Expand Down Expand Up @@ -185,7 +185,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class EphemeralReplicationActor extends ReplicationActor[Int] {

import EphemeralReplicationActor._
Expand Down Expand Up @@ -223,7 +223,7 @@ class ReplicationActorMultiNodeSpecMultiJvmNode1 extends ReplicationActorMultiNo
class ReplicationActorMultiNodeSpecMultiJvmNode2 extends ReplicationActorMultiNodeSpec
class ReplicationActorMultiNodeSpecMultiJvmNode3 extends ReplicationActorMultiNodeSpec

@nowarn // for deprecated ClusterReplication(system).start
@nowarn("msg=method start in class ClusterReplication is deprecated")
class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecConfig) with STMultiNodeSpec {
import ReplicationActorMultiNodeSpec._
import ReplicationActorSpecConfig._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object ReplicationRegionSpec {
}
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor(probe: TestProbe) extends DiagnosticActorLogging with ReplicationActor[Int] {

import DummyReplicationActor._
Expand Down Expand Up @@ -116,7 +116,7 @@ object ReplicationRegionSpecConfig extends MultiNodeConfig {
.withFallback(ConfigFactory.parseString(s"""
akka.actor.provider = cluster
akka.test.single-expect-default = 15s

lerna.akka.entityreplication.raft.compaction.log-size-threshold = 2
lerna.akka.entityreplication.raft.compaction.preserve-log-size = 1
lerna.akka.entityreplication.raft.compaction.log-size-check-interval = 0.1s
Expand Down Expand Up @@ -178,7 +178,7 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w

val raftActorProbe = TestProbe("RaftActor")

@nowarn // for deprecated ClusterReplication(system).start
@nowarn("msg=method start in class ClusterReplication is deprecated")
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object ReplicationActorSpec {
case class Counted() extends Event
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class ExampleReplicationActor extends ReplicationActor[Int] {
import ExampleReplicationActor._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object TestReplicationActorPropsSpec {
final case class Counted(wordCount: Int) extends DomainEvent
}

@nowarn // for deprecated ReplicationActor
@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class WordCountReplicationActor extends ReplicationActor[Int] {
import WordCountReplicationActor._

Expand Down Expand Up @@ -57,28 +57,26 @@ object TestReplicationActorPropsSpec {
}
}

@nowarn("msg=Use typed.testkit.ReplicatedEntityBehaviorTestKit instead")
class TestReplicationActorPropsSpec extends TestKit(ActorSystem()) with WordSpecLike with Matchers with ImplicitSender {
import WordCountReplicationActor._

"TestReplicationActorProps" should {

"take in only ReplicationActor Props" in {
@nowarn // for deprecated TestReplicationActorProps
val ex = intercept[IllegalArgumentException] {
TestReplicationActorProps(Props.default)
}
ex.getMessage should be(s"The Props for [${Props.default.actorClass()}] doesn't provide ReplicationActor")
}

"forward commands to ReplicationActor" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props))
actor ! CountWord("hello")
expectMsg(Counted(wordCount = "hello".length))
}

"allow that ReplicationActor process ensureConsistency" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props))
actor ! CountWord("hello")
expectMsgType[Counted]
Expand All @@ -87,7 +85,6 @@ class TestReplicationActorPropsSpec extends TestKit(ActorSystem()) with WordSpec
}

"allow to check ReplicationActor passivation" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = watch(system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props)))
actor ! Stop() // Passivate

Expand Down

0 comments on commit f563b43

Please sign in to comment.