diff --git a/.circleci/config.yml b/.circleci/config.yml index 850a4930dc..57b8562bd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -173,7 +173,7 @@ jobs: - restore_deps_cache - run: name: Run tests - command: sbt test codegenCore/publishLocal codegenScala/publishLocal sdkCore/publishLocal sdkJava/publishLocal sdkScala/publishLocal sdkScalaTestKit/publishLocal scripted + command: sbt test codegenCore/publishLocal codegenScala/publishLocal sdkCore/publishLocal sdkJava/publishLocal sdkScala/publishLocal sdkJavaTestKit/publishLocal sdkScalaTestKit/publishLocal scripted - save_deps_cache integration-tests: diff --git a/build.sbt b/build.sbt index 69fe4f30aa..d9207c4e5c 100644 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,7 @@ lazy val sdkCore = project val javaSourceDir = (Compile / javaSource).value.getAbsolutePath (Compile / doc / sources).value.filter(_.getAbsolutePath.startsWith(javaSourceDir)) }, + Compile / javacOptions ++= Seq("--release", "8"), Compile / scalacOptions ++= Seq("-release", "8")) .settings(Dependencies.sdkCore) @@ -104,6 +105,7 @@ lazy val sdkScala = project lazy val sdkScalaTestKit = project .in(file("sdk/scala-sdk-testkit")) .dependsOn(sdkScala) + .dependsOn(sdkJavaTestKit) .enablePlugins(BuildInfoPlugin, PublishSonatype) .settings( name := "akkaserverless-scala-sdk-testkit", @@ -114,6 +116,7 @@ lazy val sdkScalaTestKit = project "protocolMinorVersion" -> AkkaServerless.ProtocolVersionMinor, "scalaVersion" -> scalaVersion.value), buildInfoPackage := "com.akkaserverless.scalasdk.testkit", + Compile / javacOptions ++= Seq("--release", "8"), Compile / scalacOptions ++= Seq("-release", "8"), inTask(doc)( Seq( @@ -190,7 +193,9 @@ lazy val codegenCore = .settings(Compile / akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Java)) .settings( crossScalaVersions := Dependencies.ScalaVersionForCodegen, - scalaVersion := Dependencies.ScalaVersionForCodegen.head) + scalaVersion := Dependencies.ScalaVersionForCodegen.head, + Compile / javacOptions ++= Seq("--release", "8"), + Compile / scalacOptions ++= Seq("-release", "8")) lazy val codegenJava = project diff --git a/codegen/java-gen/src/main/scala/com/lightbend/akkasls/codegen/java/EntityServiceSourceGenerator.scala b/codegen/java-gen/src/main/scala/com/lightbend/akkasls/codegen/java/EntityServiceSourceGenerator.scala index 29b9386e47..e3d8768930 100644 --- a/codegen/java-gen/src/main/scala/com/lightbend/akkasls/codegen/java/EntityServiceSourceGenerator.scala +++ b/codegen/java-gen/src/main/scala/com/lightbend/akkasls/codegen/java/EntityServiceSourceGenerator.scala @@ -492,7 +492,7 @@ object EntityServiceSourceGenerator { packageName, List(service.fqn.parent.javaPackage + "." + serviceName + "Client") ++ Seq( - "com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource", + "com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource", "org.junit.ClassRule", "org.junit.Test", mainClassPackageName + "." + mainClassName) ++ extraImports) @@ -524,8 +524,8 @@ object EntityServiceSourceGenerator { | * The test kit starts both the service container and the Akka Serverless proxy. | */ | @ClassRule - | public static final AkkaServerlessTestkitResource testkit = - | new AkkaServerlessTestkitResource(${mainClassName}.createAkkaServerless()); + | public static final AkkaServerlessTestKitResource testKit = + | new AkkaServerlessTestKitResource(${mainClassName}.createAkkaServerless()); | | /** | * Use the generated gRPC client to call the service through the Akka Serverless proxy. @@ -533,7 +533,7 @@ object EntityServiceSourceGenerator { | private final ${serviceName}Client client; | | public ${testClassName}() { - | client = ${serviceName}Client.create(testkit.getGrpcClientSettings(), testkit.getActorSystem()); + | client = ${serviceName}Client.create(testKit.getGrpcClientSettings(), testKit.getActorSystem()); | } | | ${Format.indent(testCases, num = 2)} diff --git a/codegen/java-gen/src/test/scala/com/lightbend/akkasls/codegen/java/EventSourcedEntitySourceGeneratorSuite.scala b/codegen/java-gen/src/test/scala/com/lightbend/akkasls/codegen/java/EventSourcedEntitySourceGeneratorSuite.scala index c76832e6f7..63dff408ca 100644 --- a/codegen/java-gen/src/test/scala/com/lightbend/akkasls/codegen/java/EventSourcedEntitySourceGeneratorSuite.scala +++ b/codegen/java-gen/src/test/scala/com/lightbend/akkasls/codegen/java/EventSourcedEntitySourceGeneratorSuite.scala @@ -286,7 +286,7 @@ class EventSourcedEntitySourceGeneratorSuite extends munit.FunSuite { generatedSrc, """package com.example.service; | - |import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; + |import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; |import com.example.service.domain.EntityOuterClass; |import com.external.Empty; |import org.junit.ClassRule; @@ -307,8 +307,8 @@ class EventSourcedEntitySourceGeneratorSuite extends munit.FunSuite { | * The test kit starts both the service container and the Akka Serverless proxy. | */ | @ClassRule - | public static final AkkaServerlessTestkitResource testkit = - | new AkkaServerlessTestkitResource(SomeMain.createAkkaServerless()); + | public static final AkkaServerlessTestKitResource testKit = + | new AkkaServerlessTestKitResource(SomeMain.createAkkaServerless()); | | /** | * Use the generated gRPC client to call the service through the Akka Serverless proxy. @@ -316,7 +316,7 @@ class EventSourcedEntitySourceGeneratorSuite extends munit.FunSuite { | private final MyServiceClient client; | | public MyServiceEntityIntegrationTest() { - | client = MyServiceClient.create(testkit.getGrpcClientSettings(), testkit.getActorSystem()); + | client = MyServiceClient.create(testKit.getGrpcClientSettings(), testKit.getActorSystem()); | } | | @Test diff --git a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/MainSourceGenerator.scala b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/MainSourceGenerator.scala index ef9ef0881d..295653ce2b 100644 --- a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/MainSourceGenerator.scala +++ b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/MainSourceGenerator.scala @@ -60,9 +60,22 @@ object MainSourceGenerator { // FIXME remove filtering Seq(akkaServerlessFactorySource(excludedUntilImplemented(model))) - private[codegen] def mainSource(model: ModelBuilder.Model): File = { + def mainClassName(model: ModelBuilder.Model): FullyQualifiedName = { val packageName = mainPackageName(model.services.keys ++ model.entities.keys).mkString(".") val className = "Main" + FullyQualifiedName( + className, + new PackageNaming( + protoFileName = "", + name = "", + protoPackage = packageName, + javaPackageOption = None, + javaOuterClassnameOption = None, + javaMultipleFiles = false)) + } + + private[codegen] def mainSource(model: ModelBuilder.Model): File = { + val mainClass = mainClassName(model) val entityImports = model.entities.values.collect { case entity: ModelBuilder.EventSourcedEntity => entity.fqn.fullQualifiedName @@ -79,7 +92,7 @@ object MainSourceGenerator { List("com.akkaserverless.scalasdk.AkkaServerless", "org.slf4j.LoggerFactory") val imports = - generateImports(Iterable.empty, packageName, allImports, semi = false) + generateImports(Iterable.empty, mainClass.parent.scalaPackage, allImports, semi = false) val entityRegistrationParameters = model.entities.values.toList .sortBy(_.fqn.name) @@ -99,17 +112,17 @@ object MainSourceGenerator { val registrationParameters = entityRegistrationParameters ::: serviceRegistrationParameters File( - packageName, - className, - s"""|package $packageName + mainClass.parent.scalaPackage, + mainClass.name, + s"""|package ${mainClass.parent.scalaPackage} | |$imports | |$unmanagedComment | - |object $className { + |object ${mainClass.name} { | - | private val log = LoggerFactory.getLogger("$packageName.$className") + | private val log = LoggerFactory.getLogger("${mainClass.parent.scalaPackage}.${mainClass.name}") | | def createAkkaServerless(): AkkaServerless = { | // The AkkaServerlessFactory automatically registers any generated Actions, Views or Entities, diff --git a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/SourceGenerator.scala b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/SourceGenerator.scala index fb9cb15074..825d064817 100644 --- a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/SourceGenerator.scala +++ b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/SourceGenerator.scala @@ -93,26 +93,20 @@ object SourceGenerator { /** * Generate the 'unmanaged' code for this model: code that is generated once on demand and then maintained by the user */ - // FIXME we need to call this from the sbt plugin - def generateUnmanagedTest(model: ModelBuilder.Model): Seq[File] = { - model.services.values - .flatMap { - case service: ModelBuilder.EntityService => - model.lookupEntity(service) match { - case entity: ModelBuilder.ValueEntity => - ValueEntityTestKitGenerator.generateUnmanagedTest(entity, service) - case _: ModelBuilder.EventSourcedEntity => - Nil // FIXME - case _: ModelBuilder.ReplicatedEntity => - Nil - } - case _: ModelBuilder.ViewService => - Nil - case _: ModelBuilder.ActionService => - Nil - } - .map(_.prepend(unmanagedComment)) - .toList - } - + def generateUnmanagedTest(model: ModelBuilder.Model): Seq[File] = + model.services.values.flatMap { + case service: ModelBuilder.EntityService => + model.lookupEntity(service) match { + case entity: ModelBuilder.ValueEntity => + ValueEntityTestKitGenerator.generateUnmanagedTest(MainSourceGenerator.mainClassName(model), entity, service) + case _: ModelBuilder.EventSourcedEntity => + Nil // FIXME + case _: ModelBuilder.ReplicatedEntity => + Nil + } + case _: ModelBuilder.ViewService => + Nil + case _: ModelBuilder.ActionService => + Nil + }.toList } diff --git a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/ValueEntityTestKitGenerator.scala b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/ValueEntityTestKitGenerator.scala index a903a98154..5788cf3c6f 100644 --- a/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/ValueEntityTestKitGenerator.scala +++ b/codegen/scala-gen/src/main/scala/com/akkaserverless/codegen/scalasdk/impl/ValueEntityTestKitGenerator.scala @@ -17,14 +17,16 @@ package com.akkaserverless.codegen.scalasdk.impl import com.akkaserverless.codegen.scalasdk.File -import com.lightbend.akkasls.codegen.Format -import com.lightbend.akkasls.codegen.ModelBuilder +import com.lightbend.akkasls.codegen.{ Format, FullyQualifiedName, ModelBuilder } object ValueEntityTestKitGenerator { import com.lightbend.akkasls.codegen.SourceGeneratorUtils._ - def generateUnmanagedTest(valueEntity: ModelBuilder.ValueEntity, service: ModelBuilder.EntityService): Seq[File] = - Seq(test(valueEntity, service)) + def generateUnmanagedTest( + main: FullyQualifiedName, + valueEntity: ModelBuilder.ValueEntity, + service: ModelBuilder.EntityService): Seq[File] = + Seq(test(valueEntity, service), integrationTest(main, valueEntity, service)) def generateManagedTest(valueEntity: ModelBuilder.ValueEntity, service: ModelBuilder.EntityService): Seq[File] = Seq(testkit(valueEntity, service)) @@ -164,4 +166,73 @@ object ValueEntityTestKitGenerator { |""".stripMargin) } + def integrationTest( + main: FullyQualifiedName, + valueEntity: ModelBuilder.ValueEntity, + service: ModelBuilder.EntityService): File = { + + val client = FullyQualifiedName(service.fqn.name + "Client", service.fqn.parent) + + implicit val imports: Imports = + generateImports( + Seq(main, valueEntity.state.fqn, client) ++ + service.commands.map(_.inputType) ++ + service.commands.map(_.outputType), + service.fqn.parent.scalaPackage, + otherImports = Seq( + "akka.actor.ActorSystem", + "com.akkaserverless.scalasdk.valueentity.ValueEntity", + "com.akkaserverless.scalasdk.testkit.ValueEntityResult", + "com.akkaserverless.scalasdk.testkit.AkkaServerlessTestKit", + "org.scalatest.matchers.should.Matchers", + "org.scalatest.wordspec.AnyWordSpec", + "org.scalatest.BeforeAndAfterAll", + "org.scalatest.concurrent.ScalaFutures", + "org.scalatest.time.Span", + "org.scalatest.time.Seconds", + "org.scalatest.time.Millis"), + packageImports = Seq(valueEntity.fqn.parent.scalaPackage), + semi = false) + + val entityClassName = service.fqn.name + + File( + service.fqn.fileBasename + "IntegrationSpec.scala", + s"""|package ${service.fqn.parent.scalaPackage} + | + |$imports + | + |$unmanagedComment + | + |class ${entityClassName}IntegrationSpec + | extends AnyWordSpec + | with Matchers + | with BeforeAndAfterAll + | with ScalaFutures { + | + | implicit val patience: PatienceConfig = + | PatienceConfig(Span(5, Seconds), Span(500, Millis)) + | + | val testKit = AkkaServerlessTestKit(Main.createAkkaServerless()) + | testKit.start() + | implicit val system: ActorSystem = testKit.system + | + | "${entityClassName}" must { + | val client: ${typeName(client)} = + | ${typeName(client)}(testKit.grpcClientSettings) + | + | "have example test that can be removed" in { + | // use the gRPC client to send requests to the + | // proxy and verify the results + | } + | + | } + | + | override def afterAll() = { + | testKit.stop() + | super.afterAll() + | } + |} + |""".stripMargin) + } } diff --git a/codegen/scala-gen/src/test/scala/com/akkaserverless/codegen/scalasdk/ValueEntityTestKitGeneratorSuite.scala b/codegen/scala-gen/src/test/scala/com/akkaserverless/codegen/scalasdk/ValueEntityTestKitGeneratorSuite.scala index a65cff48f0..6074e7dd2c 100644 --- a/codegen/scala-gen/src/test/scala/com/akkaserverless/codegen/scalasdk/ValueEntityTestKitGeneratorSuite.scala +++ b/codegen/scala-gen/src/test/scala/com/akkaserverless/codegen/scalasdk/ValueEntityTestKitGeneratorSuite.scala @@ -164,6 +164,67 @@ class ValueEntityTestKitGeneratorSuite extends munit.FunSuite { assertNoDiff(sourceCode, expected) } + test("it can generate an specific integration test stub for the entity") { + val entity = createShoppingCartEntity() + val service = createShoppingCartService(entity) + val main = FullyQualifiedName("Main", packageNaming.copy(protoPackage = "com.example.shoppingcart")) + + assertEquals( + ValueEntityTestKitGenerator.integrationTest(main, entity, service).content, + """package com.example.shoppingcart.api + | + |import akka.actor.ActorSystem + |import com.akkaserverless.scalasdk.testkit.AkkaServerlessTestKit + |import com.akkaserverless.scalasdk.testkit.ValueEntityResult + |import com.akkaserverless.scalasdk.valueentity.ValueEntity + |import com.example.shoppingcart.Main + |import com.example.shoppingcart.domain + |import com.google.protobuf.Empty + |import org.scalatest.BeforeAndAfterAll + |import org.scalatest.concurrent.ScalaFutures + |import org.scalatest.matchers.should.Matchers + |import org.scalatest.time.Millis + |import org.scalatest.time.Seconds + |import org.scalatest.time.Span + |import org.scalatest.wordspec.AnyWordSpec + | + |// This class was initially generated based on the .proto definition by Akka Serverless tooling. + |// + |// As long as this file exists it will not be overwritten: you can maintain it yourself, + |// or delete it so it is regenerated as needed. + | + |class ShoppingCartServiceIntegrationSpec + | extends AnyWordSpec + | with Matchers + | with BeforeAndAfterAll + | with ScalaFutures { + | + | implicit val patience: PatienceConfig = + | PatienceConfig(Span(5, Seconds), Span(500, Millis)) + | + | val testKit = AkkaServerlessTestKit(Main.createAkkaServerless()) + | testKit.start() + | implicit val system: ActorSystem = testKit.system + | + | "ShoppingCartService" must { + | val client: ShoppingCartServiceClient = + | ShoppingCartServiceClient(testKit.grpcClientSettings) + | + | "have example test that can be removed" in { + | // use the gRPC client to send requests to the + | // proxy and verify the results + | } + | + | } + | + | override def afterAll() = { + | testKit.stop() + | super.afterAll() + | } + |} + |""".stripMargin) + } + def createShoppingCartEntity(): ModelBuilder.ValueEntity = { val domainProto = { diff --git a/docs/src/modules/java/pages/value-entity.adoc b/docs/src/modules/java/pages/value-entity.adoc index 8eb2f1620c..c806828791 100644 --- a/docs/src/modules/java/pages/value-entity.adoc +++ b/docs/src/modules/java/pages/value-entity.adoc @@ -241,18 +241,26 @@ The unit tests can be run from sbt using `sbt test` or if you prefer from inside === Integration tests +An example integration test class to start from is also generated for you. It uses [.group-java]#an `AkkaServerlessTestKitResource`# [.group-scala]#`AkkaServerlessTestKit`# to start docker containers and interacts with the entity with an actual gRPC client. + [.tabset] Java:: + -An example integration test class to start from is also generated for you. It uses an `AkkaServerlessTestkitResource` to start docker containers and interacts with the entity with an actual gRPC client. -+ [source,java] -./src/test/java/com/example/domain/CounterTest.java +./src/it/java/com/example/domain/CounterTest.java ---- include::example$java-valueentity-counter/src/it/java/com/example/domain/CounterIntegrationTest.java[tag=sample-it-test] ---- + The integration tests are in a special profile `it` of the project and can be run using `mvn verify -Pit`. + +Scala:: + +[source,scala] +./src/test/scala/com/example/CounterServiceIntegrationSpec.scala +---- +include::example$scala-valueentity-counter/src/test/scala/com/example/CounterServiceIntegrationSpec.scala[] +---- + Note that since these tests require building and deploying a docker image as well as actual (local) networking, they depend on docker on the development machine. This also mean they take a bit more time to execute compared to the unit tests which are completely local and does not involve networking. diff --git a/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerByNameViewIntegrationTest.java b/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerByNameViewIntegrationTest.java index 865456c020..ef20741f89 100644 --- a/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerByNameViewIntegrationTest.java +++ b/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerByNameViewIntegrationTest.java @@ -20,7 +20,7 @@ import akka.stream.javadsl.Sink; import io.grpc.StatusRuntimeException; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import customer.api.CustomerApi; import customer.api.CustomerServiceClient; import customer.domain.CustomerDomain; @@ -42,8 +42,8 @@ public class CustomerByNameViewIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerIntegrationTest.java b/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerIntegrationTest.java index 04e146a744..ce4566723b 100644 --- a/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerIntegrationTest.java +++ b/samples/java-customer-registry-quickstart/src/it/java/customer/CustomerIntegrationTest.java @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit.*; import io.grpc.StatusRuntimeException; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import customer.api.CustomerApi; import customer.api.CustomerServiceClient; import org.junit.ClassRule; @@ -38,8 +38,8 @@ public class CustomerIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-customer-registry-quickstart/src/it/java/customer/domain/CustomerIntegrationTest.java b/samples/java-customer-registry-quickstart/src/it/java/customer/domain/CustomerIntegrationTest.java index 14c4b79b70..24717f8b50 100644 --- a/samples/java-customer-registry-quickstart/src/it/java/customer/domain/CustomerIntegrationTest.java +++ b/samples/java-customer-registry-quickstart/src/it/java/customer/domain/CustomerIntegrationTest.java @@ -4,7 +4,7 @@ */ package customer.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.google.protobuf.Empty; import customer.Main; import customer.api.CustomerApi; @@ -22,8 +22,8 @@ public class CustomerIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-eventsourced-counter/src/it/java/com/example/domain/CounterIntegrationTest.java b/samples/java-eventsourced-counter/src/it/java/com/example/domain/CounterIntegrationTest.java index ee60b1e165..fe20a2cec2 100644 --- a/samples/java-eventsourced-counter/src/it/java/com/example/domain/CounterIntegrationTest.java +++ b/samples/java-eventsourced-counter/src/it/java/com/example/domain/CounterIntegrationTest.java @@ -4,7 +4,7 @@ */ package com.example.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.CounterApi; import com.example.CounterServiceClient; import com.example.Main; @@ -24,8 +24,8 @@ public class CounterIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-eventsourced-customer-registry/src/it/java/customer/domain/CustomerEntityIntegrationTest.java b/samples/java-eventsourced-customer-registry/src/it/java/customer/domain/CustomerEntityIntegrationTest.java index a58daef4ee..5d09e6ddca 100644 --- a/samples/java-eventsourced-customer-registry/src/it/java/customer/domain/CustomerEntityIntegrationTest.java +++ b/samples/java-eventsourced-customer-registry/src/it/java/customer/domain/CustomerEntityIntegrationTest.java @@ -7,7 +7,7 @@ import customer.Main; import customer.api.CustomerServiceClient; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import org.junit.ClassRule; import org.junit.Test; @@ -21,8 +21,8 @@ public class CustomerEntityIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-eventsourced-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java b/samples/java-eventsourced-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java index 7e955a0e05..7ad6855f6b 100644 --- a/samples/java-eventsourced-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java +++ b/samples/java-eventsourced-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java @@ -15,7 +15,7 @@ */ package com.example.shoppingcart.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.shoppingcart.Main; import com.example.shoppingcart.ShoppingCartApi; import com.example.shoppingcart.ShoppingCartServiceClient; @@ -34,8 +34,8 @@ public class ShoppingCartIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); private final ShoppingCartServiceClient client; diff --git a/samples/java-fibonacci-action/src/it/java/com/example/fibonacci/FibonacciActionIntegrationTest.java b/samples/java-fibonacci-action/src/it/java/com/example/fibonacci/FibonacciActionIntegrationTest.java index c7043eb3f5..9b76f7be1a 100644 --- a/samples/java-fibonacci-action/src/it/java/com/example/fibonacci/FibonacciActionIntegrationTest.java +++ b/samples/java-fibonacci-action/src/it/java/com/example/fibonacci/FibonacciActionIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.fibonacci; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.Main; import org.junit.Assert; import org.junit.ClassRule; @@ -15,8 +15,8 @@ public class FibonacciActionIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); private final FibonacciClient client; diff --git a/samples/java-first-service/src/it/java/com/example/domain/CounterIntegrationTest.java b/samples/java-first-service/src/it/java/com/example/domain/CounterIntegrationTest.java index 1cb46e489c..720756ccd9 100644 --- a/samples/java-first-service/src/it/java/com/example/domain/CounterIntegrationTest.java +++ b/samples/java-first-service/src/it/java/com/example/domain/CounterIntegrationTest.java @@ -4,7 +4,7 @@ */ package com.example.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.CounterApi; import com.example.CounterServiceClient; import com.example.Main; @@ -22,8 +22,8 @@ public class CounterIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/counter/domain/SomeCounterIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/counter/domain/SomeCounterIntegrationTest.java index f94553f87a..b89a5a487c 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/counter/domain/SomeCounterIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/counter/domain/SomeCounterIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.counter.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.counter.CounterServiceClient; import com.example.replicated.counter.SomeCounterApi; @@ -15,8 +15,8 @@ public class SomeCounterIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final CounterServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/countermap/domain/SomeCounterMapIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/countermap/domain/SomeCounterMapIntegrationTest.java index 1ca4fb8ad3..c0490a77e7 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/countermap/domain/SomeCounterMapIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/countermap/domain/SomeCounterMapIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.countermap.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.countermap.CounterMapServiceClient; import com.example.replicated.countermap.SomeCounterMapApi; @@ -20,8 +20,8 @@ public class SomeCounterMapIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final CounterMapServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/map/domain/SomeMapIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/map/domain/SomeMapIntegrationTest.java index 7c11d5f74b..a626e7e9ed 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/map/domain/SomeMapIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/map/domain/SomeMapIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.map.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.map.MapServiceClient; import com.example.replicated.map.SomeMapApi; @@ -17,8 +17,8 @@ public class SomeMapIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final MapServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/multimap/domain/SomeMultiMapIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/multimap/domain/SomeMultiMapIntegrationTest.java index 8f9e993701..87d771d69d 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/multimap/domain/SomeMultiMapIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/multimap/domain/SomeMultiMapIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.multimap.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.multimap.MultiMapServiceClient; import com.example.replicated.multimap.SomeMultiMapApi; @@ -24,8 +24,8 @@ public class SomeMultiMapIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final MultiMapServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/register/domain/SomeRegisterIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/register/domain/SomeRegisterIntegrationTest.java index feb3a750d0..af9889f41c 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/register/domain/SomeRegisterIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/register/domain/SomeRegisterIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.register.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.register.RegisterServiceClient; import com.example.replicated.register.SomeRegisterApi; @@ -15,8 +15,8 @@ public class SomeRegisterIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final RegisterServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/registermap/domain/SomeRegisterMapIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/registermap/domain/SomeRegisterMapIntegrationTest.java index 7144f5b988..d5501ad041 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/registermap/domain/SomeRegisterMapIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/registermap/domain/SomeRegisterMapIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.registermap.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.registermap.RegisterMapServiceClient; import com.example.replicated.registermap.SomeRegisterMapApi; @@ -21,8 +21,8 @@ public class SomeRegisterMapIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final RegisterMapServiceClient client; diff --git a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/set/domain/SomeSetIntegrationTest.java b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/set/domain/SomeSetIntegrationTest.java index 5825e68eaa..f3b12d7c94 100644 --- a/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/set/domain/SomeSetIntegrationTest.java +++ b/samples/java-replicatedentity-examples/src/it/java/com/example/replicated/set/domain/SomeSetIntegrationTest.java @@ -1,6 +1,6 @@ package com.example.replicated.set.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.replicated.Main; import com.example.replicated.set.SetServiceClient; import com.example.replicated.set.SomeSetApi; @@ -19,8 +19,8 @@ public class SomeSetIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final SetServiceClient client; diff --git a/samples/java-replicatedentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java b/samples/java-replicatedentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java index b07efc8d6b..7bd627089a 100644 --- a/samples/java-replicatedentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java +++ b/samples/java-replicatedentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java @@ -4,7 +4,7 @@ */ package com.example.shoppingcart.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.shoppingcart.Main; import com.example.shoppingcart.ShoppingCartApi; import com.example.shoppingcart.ShoppingCartServiceClient; @@ -26,8 +26,8 @@ public class ShoppingCartIntegrationTest { /** The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** Use the generated gRPC client to call the service through the Akka Serverless proxy. */ private final ShoppingCartServiceClient client; diff --git a/samples/java-shopping-cart-quickstart/src/it/java/shopping/cart/domain/ShoppingCartEntityIntegrationTest.java b/samples/java-shopping-cart-quickstart/src/it/java/shopping/cart/domain/ShoppingCartEntityIntegrationTest.java index 3fbc8e2d92..e7cfcea6d0 100644 --- a/samples/java-shopping-cart-quickstart/src/it/java/shopping/cart/domain/ShoppingCartEntityIntegrationTest.java +++ b/samples/java-shopping-cart-quickstart/src/it/java/shopping/cart/domain/ShoppingCartEntityIntegrationTest.java @@ -4,7 +4,7 @@ */ package shopping.cart.domain; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.google.protobuf.Empty; import org.junit.ClassRule; import org.junit.Test; @@ -22,8 +22,8 @@ public class ShoppingCartEntityIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-valueentity-counter/src/it/java/com/example/domain/CounterIntegrationTest.java b/samples/java-valueentity-counter/src/it/java/com/example/domain/CounterIntegrationTest.java index 0c203ecf65..996d17b653 100644 --- a/samples/java-valueentity-counter/src/it/java/com/example/domain/CounterIntegrationTest.java +++ b/samples/java-valueentity-counter/src/it/java/com/example/domain/CounterIntegrationTest.java @@ -8,7 +8,7 @@ import com.example.Main; import com.example.CounterApi; import com.example.CounterServiceClient; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import org.junit.ClassRule; import org.junit.Test; import static org.hamcrest.MatcherAssert.*; @@ -24,8 +24,8 @@ public class CounterIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/java-valueentity-customer-registry/src/it/java/customer/domain/CustomerValueEntityIntegrationTest.java b/samples/java-valueentity-customer-registry/src/it/java/customer/domain/CustomerValueEntityIntegrationTest.java index 7686ca2036..1e124cde6e 100644 --- a/samples/java-valueentity-customer-registry/src/it/java/customer/domain/CustomerValueEntityIntegrationTest.java +++ b/samples/java-valueentity-customer-registry/src/it/java/customer/domain/CustomerValueEntityIntegrationTest.java @@ -7,7 +7,7 @@ import customer.Main; import customer.api.CustomerServiceClient; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import org.junit.ClassRule; import org.junit.Test; @@ -21,8 +21,8 @@ public class CustomerValueEntityIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testKit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. @@ -30,7 +30,7 @@ public class CustomerValueEntityIntegrationTest { private final CustomerServiceClient client; public CustomerValueEntityIntegrationTest() { - client = CustomerServiceClient.create(testkit.getGrpcClientSettings(), testkit.getActorSystem()); + client = CustomerServiceClient.create(testKit.getGrpcClientSettings(), testKit.getActorSystem()); } @Test diff --git a/samples/java-valueentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java b/samples/java-valueentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java index d5f8ceba4e..df11157f2b 100644 --- a/samples/java-valueentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java +++ b/samples/java-valueentity-shopping-cart/src/it/java/com/example/shoppingcart/domain/ShoppingCartIntegrationTest.java @@ -16,7 +16,7 @@ package com.example.shoppingcart.domain; import com.example.shoppingcart.Main; -import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestkitResource; +import com.akkaserverless.javasdk.testkit.junit.AkkaServerlessTestKitResource; import com.example.shoppingcart.ShoppingCartApi; import com.example.shoppingcart.ShoppingCartServiceClient; import org.junit.ClassRule; @@ -35,8 +35,8 @@ public class ShoppingCartIntegrationTest { * The test kit starts both the service container and the Akka Serverless proxy. */ @ClassRule - public static final AkkaServerlessTestkitResource testkit = - new AkkaServerlessTestkitResource(Main.createAkkaServerless()); + public static final AkkaServerlessTestKitResource testkit = + new AkkaServerlessTestKitResource(Main.createAkkaServerless()); /** * Use the generated gRPC client to call the service through the Akka Serverless proxy. diff --git a/samples/scala-valueentity-counter/src/test/scala/com/example/CounterServiceIntegrationSpec.scala b/samples/scala-valueentity-counter/src/test/scala/com/example/CounterServiceIntegrationSpec.scala new file mode 100644 index 0000000000..721b3b45e2 --- /dev/null +++ b/samples/scala-valueentity-counter/src/test/scala/com/example/CounterServiceIntegrationSpec.scala @@ -0,0 +1,49 @@ +package com.example + +import akka.actor.ActorSystem +import com.akkaserverless.scalasdk.testkit.AkkaServerlessTestKit +import com.akkaserverless.scalasdk.testkit.ValueEntityResult +import com.akkaserverless.scalasdk.valueentity.ValueEntity +import com.google.protobuf.empty.Empty +import org.scalatest.BeforeAndAfterAll +import org.scalatest.concurrent.ScalaFutures +import org.scalatest.matchers.should.Matchers +import org.scalatest.time.Millis +import org.scalatest.time.Seconds +import org.scalatest.time.Span +import org.scalatest.wordspec.AnyWordSpec + +// This class was initially generated based on the .proto definition by Akka Serverless tooling. +// +// As long as this file exists it will not be overwritten: you can maintain it yourself, +// or delete it so it is regenerated as needed. + +class CounterServiceIntegrationSpec + extends AnyWordSpec + with Matchers + with BeforeAndAfterAll + with ScalaFutures { + + implicit val patience: PatienceConfig = + PatienceConfig(Span(5, Seconds), Span(500, Millis)) + + val testKit = AkkaServerlessTestKit(Main.createAkkaServerless()) + testKit.start() + implicit val system: ActorSystem = testKit.system + + "CounterService" must { + val client: CounterServiceClient = + CounterServiceClient(testKit.grpcClientSettings) + + "have example test that can be removed" in { + // use the gRPC client to send requests to the + // proxy and verify the results + } + + } + + override def afterAll() = { + testKit.stop() + super.afterAll() + } +} diff --git a/sbt-plugin/src/main/scala/com/akkaserverless/sbt/AkkaserverlessPlugin.scala b/sbt-plugin/src/main/scala/com/akkaserverless/sbt/AkkaserverlessPlugin.scala index 7d05690fd0..7a70c00ddc 100644 --- a/sbt-plugin/src/main/scala/com/akkaserverless/sbt/AkkaserverlessPlugin.scala +++ b/sbt-plugin/src/main/scala/com/akkaserverless/sbt/AkkaserverlessPlugin.scala @@ -35,6 +35,7 @@ import sbt.{ Compile, _ } import sbt.Keys._ import sbtprotoc.ProtocPlugin import sbtprotoc.ProtocPlugin.autoImport.PB +import sbtprotoc.ProtocPlugin.protobufConfigSettings import scalapb.GeneratorOption object AkkaserverlessPlugin extends AutoPlugin { @@ -47,7 +48,6 @@ object AkkaserverlessPlugin extends AutoPlugin { "These are the source files that are placed in the source tree, and after initial generation should typically be maintained by the user.\n" + "Files that already exist they are not re-generated.") val temporaryUnmanagedDirectory = settingKey[File]("Directory to generate 'unmanaged' sources into") - val temporaryUnmanagedTestDirectory = settingKey[File]("Directory to generate 'unmanaged' test sources into") } object autoImport extends Keys @@ -64,7 +64,7 @@ object AkkaserverlessPlugin extends AutoPlugin { gen( akkaGrpcCodeGeneratorSettings.value :+ AkkaserverlessGenerator.enableDebug) -> (Compile / sourceManaged).value / "akkaserverless", Compile / temporaryUnmanagedDirectory := (Compile / baseDirectory).value / "target" / "akkaserverless-unmanaged", - Test / temporaryUnmanagedTestDirectory := (Test / baseDirectory).value / "target" / "akkaserverless-unmanaged-test", + Test / temporaryUnmanagedDirectory := (Test / baseDirectory).value / "target" / "akkaserverless-unmanaged-test", // FIXME there is a name clash between the Akka gRPC server-side service 'handler' // and the Akka Serverless 'handler'. For now working around it by only generating // the client, but we should probably resolve this before the first public release. @@ -72,7 +72,7 @@ object AkkaserverlessPlugin extends AutoPlugin { Compile / PB.targets ++= Seq(genUnmanaged( akkaGrpcCodeGeneratorSettings.value :+ AkkaserverlessGenerator.enableDebug) -> (Compile / temporaryUnmanagedDirectory).value), Test / PB.targets ++= Seq(genUnmanagedTest( - akkaGrpcCodeGeneratorSettings.value :+ AkkaserverlessGenerator.enableDebug) -> (Test / temporaryUnmanagedTestDirectory).value), + akkaGrpcCodeGeneratorSettings.value :+ AkkaserverlessGenerator.enableDebug) -> (Test / temporaryUnmanagedDirectory).value), Test / PB.protoSources ++= (Compile / PB.protoSources).value, Test / PB.targets += genTests( @@ -87,12 +87,12 @@ object AkkaserverlessPlugin extends AutoPlugin { Paths.get((Compile / sourceDirectory).value.toURI).resolve("scala")) }, Test / generateUnmanaged := { - Files.createDirectories(Paths.get((Test / temporaryUnmanagedTestDirectory).value.toURI)) + Files.createDirectories(Paths.get((Test / temporaryUnmanagedDirectory).value.toURI)) // Make sure generation has happened val _ = (Test / PB.generate).value // Then copy over any new generated unmanaged sources copyIfNotExist( - Paths.get((Test / temporaryUnmanagedTestDirectory).value.toURI), + Paths.get((Test / temporaryUnmanagedDirectory).value.toURI), Paths.get((Test / sourceDirectory).value.toURI).resolve("scala")) }, Compile / managedSources := @@ -100,7 +100,7 @@ object AkkaserverlessPlugin extends AutoPlugin { Compile / unmanagedSources := (Compile / generateUnmanaged).value ++ (Compile / unmanagedSources).value, Test / managedSources := - (Test / managedSources).value.filter(s => !isIn(s, (Test / temporaryUnmanagedTestDirectory).value)), + (Test / managedSources).value.filter(s => !isIn(s, (Test / temporaryUnmanagedDirectory).value)), Test / unmanagedSources := (Test / generateUnmanaged).value ++ (Test / unmanagedSources).value) diff --git a/sbt-plugin/src/sbt-test/sbt-akkaserverless/basic/test b/sbt-plugin/src/sbt-test/sbt-akkaserverless/basic/test index 9515e5600f..00548e546f 100644 --- a/sbt-plugin/src/sbt-test/sbt-akkaserverless/basic/test +++ b/sbt-plugin/src/sbt-test/sbt-akkaserverless/basic/test @@ -70,4 +70,5 @@ $ exists target/scala-2.13/src_managed/main/akkaserverless/com/example/valueenti # com/example/valueentity/some_value_entity_api.proto # com/example/valueentity/domain/some_value_entity_domain.proto $ exists src/test/scala/com/example/valueentity/domain/SomeValueEntitySpec.scala +$ exists src/test/scala/com/example/valueentity/SomeValueEntityServiceIntegrationSpec.scala $ exists target/scala-2.13/src_managed/test/akkaserverless/com/example/valueentity/domain/SomeValueEntityTestKit.scala diff --git a/sdk/scala-sdk-testkit/src/main/scala/com/akkaserverless/scalasdk/testkit/AkkaServerlessTestKit.scala b/sdk/scala-sdk-testkit/src/main/scala/com/akkaserverless/scalasdk/testkit/AkkaServerlessTestKit.scala new file mode 100644 index 0000000000..4756fb5ca8 --- /dev/null +++ b/sdk/scala-sdk-testkit/src/main/scala/com/akkaserverless/scalasdk/testkit/AkkaServerlessTestKit.scala @@ -0,0 +1,53 @@ +/* + * Copyright 2021 Lightbend Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akkaserverless.scalasdk.testkit + +import akka.actor.ActorSystem +import akka.grpc.GrpcClientSettings +import com.akkaserverless.scalasdk.AkkaServerless +import com.akkaserverless.javasdk.testkit.{ AkkaServerlessTestKit => JTestKit } + +/** + * TestKit for running Akka Serverless services locally. + * + *

Requires Docker for starting a local instance of the Akka Serverless proxy. + * + *

Create an AkkaServerlessTestKit with an {@link AkkaServerless} service descriptor, and then {@link #start} the + * testkit before testing the service with gRPC or HTTP clients. Call {@link #stop} after tests are complete. + */ +object AkkaServerlessTestKit { + def apply(main: AkkaServerless): AkkaServerlessTestKit = + new AkkaServerlessTestKit(new JTestKit(main.delegate)) +} +class AkkaServerlessTestKit private (delegate: JTestKit) { + def start(): AkkaServerlessTestKit = { + delegate.start() + this + } + + /** + * Get {@link GrpcClientSettings} for creating Akka gRPC clients. + * + * @return + * test gRPC client settings + */ + def grpcClientSettings: GrpcClientSettings = delegate.getGrpcClientSettings() + + def system: ActorSystem = delegate.getActorSystem() + + def stop(): Unit = delegate.stop() +} diff --git a/sdk/scala-sdk/src/main/scala/com/akkaserverless/scalasdk/AkkaServerless.scala b/sdk/scala-sdk/src/main/scala/com/akkaserverless/scalasdk/AkkaServerless.scala index f46ec6bcaa..0dfa0c9d4f 100644 --- a/sdk/scala-sdk/src/main/scala/com/akkaserverless/scalasdk/AkkaServerless.scala +++ b/sdk/scala-sdk/src/main/scala/com/akkaserverless/scalasdk/AkkaServerless.scala @@ -47,7 +47,7 @@ object AkkaServerless { * The AkkaServerless class is the main interface to configuring entities to deploy, and subsequently starting a local * server which will expose these entities to the AkkaServerless Proxy Sidecar. */ -class AkkaServerless private (impl: javasdk.AkkaServerless) { +class AkkaServerless private (private[akkaserverless] val delegate: javasdk.AkkaServerless) { /** * Sets the ClassLoader to be used for reflective access, the default value is the ClassLoader of the AkkaServerless @@ -59,7 +59,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This AkkaServerless instance. */ def withClassLoader(classLoader: ClassLoader): AkkaServerless = - AkkaServerless(impl.withClassLoader(classLoader)) + AkkaServerless(delegate.withClassLoader(classLoader)) /** * Sets the type URL prefix to be used when serializing and deserializing types from and to Protobyf Any values. @@ -71,7 +71,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This AkkaServerless instance. */ def withTypeUrlPrefix(prefix: String): AkkaServerless = - AkkaServerless(impl.withTypeUrlPrefix(prefix)) + AkkaServerless(delegate.withTypeUrlPrefix(prefix)) /** * When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies @@ -81,7 +81,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This AkkaServerless instance. */ def preferJavaProtobufs: AkkaServerless = - AkkaServerless(impl.preferJavaProtobufs) + AkkaServerless(delegate.preferJavaProtobufs) /** * When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies @@ -91,7 +91,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This AkkaServerless instance. */ def preferScalaProtobufs: AkkaServerless = - AkkaServerless(impl.preferScalaProtobufs) + AkkaServerless(delegate.preferScalaProtobufs) /** * Register a replicated entity using a [[ReplicatedEntityProvider]]. The concrete `ReplicatedEntityProvider` is @@ -105,7 +105,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { */ def register[D <: ReplicatedData, E <: ReplicatedEntity[D]]( provider: ReplicatedEntityProvider[D, E]): AkkaServerless = - AkkaServerless(impl.register(provider.impl)) + AkkaServerless(delegate.register(provider.impl)) /** * Register a value based entity using a [[ValueEntityProvider]]. The concrete ` ValueEntityProvider` is generated for @@ -117,7 +117,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This stateful service builder. */ def register[S, E <: ValueEntity[S]](provider: ValueEntityProvider[S, E]): AkkaServerless = - AkkaServerless(impl.register(new JavaValueEntityProviderAdapter(provider))) + AkkaServerless(delegate.register(new JavaValueEntityProviderAdapter(provider))) /** * Register a event sourced entity using a [[EventSourcedEntityProvider]]. The concrete `EventSourcedEntityProvider` @@ -130,7 +130,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This stateful service builder. */ def register[S, E <: EventSourcedEntity[S]](provider: EventSourcedEntityProvider[S, E]): AkkaServerless = - AkkaServerless(impl.register(new JavaEventSourcedEntityProviderAdapter(provider))) + AkkaServerless(delegate.register(new JavaEventSourcedEntityProviderAdapter(provider))) /** * Register a view using a [[ViewProvider]]. The concrete ` ViewProvider` is generated for the specific views defined @@ -140,7 +140,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This stateful service builder. */ def register[S, V <: View[S]](provider: ViewProvider[S, V]): AkkaServerless = - AkkaServerless(impl.register(new JavaViewProviderAdapter(provider))) + AkkaServerless(delegate.register(new JavaViewProviderAdapter(provider))) /** * Register an action using an [[ActionProvider]]. The concrete ` ActionProvider` is generated for the specific @@ -150,7 +150,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * This stateful service builder. */ def register[A <: Action](provider: ActionProvider[A]): AkkaServerless = - AkkaServerless(impl.register(JavaActionProviderAdapter(provider))) + AkkaServerless(delegate.register(JavaActionProviderAdapter(provider))) /** * Starts a server with the configured entities. @@ -180,7 +180,7 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * an AkkaServerlessRunner */ def createRunner(): AkkaServerlessRunner = - AkkaServerlessRunner(impl.createRunner()) + AkkaServerlessRunner(delegate.createRunner()) /** * Creates an AkkaServerlessRunner using the currently configured services, using the supplied configuration. In order @@ -190,5 +190,5 @@ class AkkaServerless private (impl: javasdk.AkkaServerless) { * an AkkaServerlessRunner */ def createRunner(config: Config): AkkaServerlessRunner = - AkkaServerlessRunner(impl.createRunner(config)) + AkkaServerlessRunner(delegate.createRunner(config)) } diff --git a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestkit.java b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestKit.java similarity index 94% rename from testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestkit.java rename to testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestKit.java index f1916cc08b..811ad15811 100644 --- a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestkit.java +++ b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/AkkaServerlessTestKit.java @@ -24,7 +24,6 @@ import com.typesafe.config.ConfigFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.Testcontainers; import java.io.IOException; import java.net.ServerSocket; @@ -36,13 +35,13 @@ /** * Testkit for running Akka Serverless services locally. * - *

Requires Docker for starting a local instance of Akka Serverless. + *

Requires Docker for starting a local instance of the Akka Serverless proxy. * *

Create an AkkaServerlessTestkit with an {@link AkkaServerless} service descriptor, and then * {@link #start} the testkit before testing the service with gRPC or HTTP clients. Call {@link * #stop} after tests are complete. */ -public class AkkaServerlessTestkit { +public class AkkaServerlessTestKit { /** Settings for AkkaServerlessTestkit. */ public static class Settings { @@ -74,7 +73,7 @@ public Settings withStopTimeout(final Duration stopTimeout) { } } - private static final Logger log = LoggerFactory.getLogger(AkkaServerlessTestkit.class); + private static final Logger log = LoggerFactory.getLogger(AkkaServerlessTestKit.class); private final AkkaServerless akkaServerless; private final Settings settings; @@ -89,7 +88,7 @@ public Settings withStopTimeout(final Duration stopTimeout) { * * @param akkaServerless AkkaServerless service descriptor */ - public AkkaServerlessTestkit(final AkkaServerless akkaServerless) { + public AkkaServerlessTestKit(final AkkaServerless akkaServerless) { this(akkaServerless, Settings.DEFAULT); } @@ -99,7 +98,7 @@ public AkkaServerlessTestkit(final AkkaServerless akkaServerless) { * @param akkaServerless AkkaServerless service descriptor * @param settings custom testkit settings */ - public AkkaServerlessTestkit(final AkkaServerless akkaServerless, final Settings settings) { + public AkkaServerlessTestKit(final AkkaServerless akkaServerless, final Settings settings) { this.akkaServerless = akkaServerless; this.settings = settings; } @@ -109,7 +108,7 @@ public AkkaServerlessTestkit(final AkkaServerless akkaServerless, final Settings * * @return this AkkaServerlessTestkit */ - public AkkaServerlessTestkit start() { + public AkkaServerlessTestKit start() { return start(ConfigFactory.load()); } @@ -119,7 +118,7 @@ public AkkaServerlessTestkit start() { * @param config custom test configuration for the AkkaServerlessRunner * @return this AkkaServerlessTestkit */ - public AkkaServerlessTestkit start(final Config config) { + public AkkaServerlessTestKit start(final Config config) { if (started) throw new IllegalStateException("AkkaServerlessTestkit already started"); int port = availableLocalPort(); Map conf = new HashMap<>(); diff --git a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestkitResource.java b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestKitResource.java similarity index 78% rename from testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestkitResource.java rename to testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestKitResource.java index 53f2aacb54..5692726e5e 100644 --- a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestkitResource.java +++ b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/AkkaServerlessTestKitResource.java @@ -19,11 +19,11 @@ import akka.actor.ActorSystem; import akka.grpc.GrpcClientSettings; import com.akkaserverless.javasdk.AkkaServerless; -import com.akkaserverless.javasdk.testkit.AkkaServerlessTestkit; +import com.akkaserverless.javasdk.testkit.AkkaServerlessTestKit; import org.junit.rules.ExternalResource; /** - * A JUnit external resource for {@link AkkaServerlessTestkit}, which automatically manages the + * A JUnit external resource for {@link AkkaServerlessTestKit}, which automatically manages the * lifecycle of the testkit. The testkit will be automatically stopped when the test completes or * fails. * @@ -40,12 +40,12 @@ * private static final AkkaServerless MY_AKKA_SERVERLESS = new AkkaServerless(); // with registered services * * @ClassRule - * public static final AkkaServerlessTestkitResource testkit = new AkkaServerlessTestkitResource(MY_AKKA_SERVERLESS); + * public static final AkkaServerlessTestKitResource testKit = new AkkaServerlessTestKitResource(MY_AKKA_SERVERLESS); * * private final MyServiceClient client; // generated Akka gRPC client * * public MyAkkaServerlessIntegrationTest() { - * this.client = MyServiceClient.create(testkit.getGrpcClientSettings(), testkit.getActorSystem()); + * this.client = MyServiceClient.create(testKit.getGrpcClientSettings(), testKit.getActorSystem()); * } * * @Test @@ -55,17 +55,17 @@ * } * */ -public final class AkkaServerlessTestkitResource extends ExternalResource { +public final class AkkaServerlessTestKitResource extends ExternalResource { - private final AkkaServerlessTestkit testkit; + private final AkkaServerlessTestKit testkit; - public AkkaServerlessTestkitResource(AkkaServerless akkaServerless) { - this(akkaServerless, AkkaServerlessTestkit.Settings.DEFAULT); + public AkkaServerlessTestKitResource(AkkaServerless akkaServerless) { + this(akkaServerless, AkkaServerlessTestKit.Settings.DEFAULT); } - public AkkaServerlessTestkitResource( - AkkaServerless akkaServerless, AkkaServerlessTestkit.Settings settings) { - this.testkit = new AkkaServerlessTestkit(akkaServerless, settings); + public AkkaServerlessTestKitResource( + AkkaServerless akkaServerless, AkkaServerlessTestKit.Settings settings) { + this.testkit = new AkkaServerlessTestKit(akkaServerless, settings); } @Override diff --git a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTest.java b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTest.java index 669b21c565..c306fd4a0f 100644 --- a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTest.java +++ b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTest.java @@ -16,7 +16,7 @@ package com.akkaserverless.javasdk.testkit.junit.jupiter; -import com.akkaserverless.javasdk.testkit.AkkaServerlessTestkit; +import com.akkaserverless.javasdk.testkit.AkkaServerlessTestKit; import org.junit.jupiter.api.extension.ExtendWith; import java.lang.annotation.ElementType; @@ -27,7 +27,7 @@ /** * {@code @AkkaServerlessTest} registers a JUnit Jupiter extension to automatically manage the - * lifecycle of {@link AkkaServerlessTestkit} and Akka gRPC clients. + * lifecycle of {@link AkkaServerlessTestKit} and Akka gRPC clients. * *

Note: JUnit Jupiter is not provided as a transitive dependency of the Java SDK testkit * module but must be added explicitly to your project. @@ -69,6 +69,6 @@ */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -@ExtendWith(AkkaServerlessTestkitExtension.class) +@ExtendWith(AkkaServerlessTestKitExtension.class) @Inherited public @interface AkkaServerlessTest {} diff --git a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestkitExtension.java b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestKitExtension.java similarity index 88% rename from testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestkitExtension.java rename to testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestKitExtension.java index cd9035419c..c52356ea7b 100644 --- a/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestkitExtension.java +++ b/testkit-java/src/main/java/com/akkaserverless/javasdk/testkit/junit/jupiter/AkkaServerlessTestKitExtension.java @@ -20,7 +20,7 @@ import akka.grpc.GrpcClientSettings; import akka.grpc.javadsl.AkkaGrpcClient; import com.akkaserverless.javasdk.AkkaServerless; -import com.akkaserverless.javasdk.testkit.AkkaServerlessTestkit; +import com.akkaserverless.javasdk.testkit.AkkaServerlessTestKit; import org.junit.jupiter.api.extension.*; import org.junit.jupiter.api.extension.ExtensionContext.Namespace; import org.junit.jupiter.api.extension.ExtensionContext.Store; @@ -30,27 +30,27 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; -class AkkaServerlessTestkitExtension implements BeforeAllCallback, ParameterResolver { +class AkkaServerlessTestKitExtension implements BeforeAllCallback, ParameterResolver { - private static final Namespace NAMESPACE = Namespace.create(AkkaServerlessTestkitExtension.class); + private static final Namespace NAMESPACE = Namespace.create(AkkaServerlessTestKitExtension.class); private static final String TESTKIT = "testkit"; @Override public void beforeAll(ExtensionContext context) { Class testClass = context.getRequiredTestClass(); AkkaServerless akkaServerless = findAkkaServerlessDescriptor(testClass); - AkkaServerlessTestkit testkit = new AkkaServerlessTestkit(akkaServerless).start(); + AkkaServerlessTestKit testkit = new AkkaServerlessTestKit(akkaServerless).start(); context.getStore(NAMESPACE).put(TESTKIT, new StoredTestkit(testkit)); } private static AkkaServerless findAkkaServerlessDescriptor(final Class testClass) { return ReflectionUtils.findFields( testClass, - AkkaServerlessTestkitExtension::isAkkaServerlessDescriptor, + AkkaServerlessTestKitExtension::isAkkaServerlessDescriptor, ReflectionUtils.HierarchyTraversalMode.TOP_DOWN) .stream() .findFirst() - .map(AkkaServerlessTestkitExtension::getAkkaServerlessDescriptor) + .map(AkkaServerlessTestKitExtension::getAkkaServerlessDescriptor) .orElseThrow( () -> new ExtensionConfigurationException( @@ -84,15 +84,15 @@ private static AkkaServerless getAkkaServerlessDescriptor(final Field field) { @Override public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) { Class type = parameterContext.getParameter().getType(); - return (type == AkkaServerlessTestkit.class) || AkkaGrpcClient.class.isAssignableFrom(type); + return (type == AkkaServerlessTestKit.class) || AkkaGrpcClient.class.isAssignableFrom(type); } @Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) { Class type = parameterContext.getParameter().getType(); Store store = context.getStore(NAMESPACE); - AkkaServerlessTestkit testkit = store.get(TESTKIT, StoredTestkit.class).getTestkit(); - if (type == AkkaServerlessTestkit.class) { + AkkaServerlessTestKit testkit = store.get(TESTKIT, StoredTestkit.class).getTestkit(); + if (type == AkkaServerlessTestKit.class) { return testkit; } else if (AkkaGrpcClient.class.isAssignableFrom(type)) { return store @@ -119,13 +119,13 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte // Wrap testkit in CloseableResource, auto-closed when test finishes (extension store is closed) private static class StoredTestkit implements Store.CloseableResource { - private final AkkaServerlessTestkit testkit; + private final AkkaServerlessTestKit testkit; - private StoredTestkit(AkkaServerlessTestkit testkit) { + private StoredTestkit(AkkaServerlessTestKit testkit) { this.testkit = testkit; } - public AkkaServerlessTestkit getTestkit() { + public AkkaServerlessTestKit getTestkit() { return testkit; }