Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.lightbend.akkasls.codegen

class PackagingSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.scalaStyle

test("fqn should be able to produce filenames") {
val parent = testData.domainProto()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.lightbend.akkasls.codegen

object TestData {
val defaultPackageNamingTemplate: PackageNaming =
val javaStylePackageNamingTemplate: PackageNaming =
PackageNaming(
"undefined.proto",
"Undefined",
Expand All @@ -26,12 +26,12 @@ object TestData {
Some("UndefinedOuterClass"),
javaMultipleFiles = false)

def apply(): TestData =
apply(defaultPackageNamingTemplate)

def apply(packageNamingTemplate: PackageNaming): TestData = {
new TestData(packageNamingTemplate)
}

val javaStyle = apply(javaStylePackageNamingTemplate)
val scalaStyle = apply(javaStylePackageNamingTemplate.copy(javaOuterClassnameOption = None))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.akkasls.codegen
package java

class ActionServiceSourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test("Action source generation") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.akkasls.codegen
package java

class EventSourcedEntitySourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test("EventSourcedEntity source") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.akkasls.codegen
package java

class EventSourcedEntityTestKitGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test(
"it can generate an specific TestKit for the proto files " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.akkasls.codegen
package java

class MainSourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

def domainType(name: String): ModelBuilder.TypeArgument =
ModelBuilder.TypeArgument(name, testData.domainProto())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.lightbend.akkasls.codegen.ModelBuilder.ReplicatedVote
import com.lightbend.akkasls.codegen.ModelBuilder.TypeArgument

class ReplicatedEntitySourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

def testEntityServiceImplementation(
testName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SourceGeneratorSuite extends munit.FunSuite {
override def info(message: String): Unit = log.info(message)
}

private val testData = TestData()
private val testData = TestData.javaStyle

def domainType(name: String): ModelBuilder.TypeArgument =
ModelBuilder.TypeArgument(name, testData.domainProto())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.lightbend.akkasls.codegen.TestData
import munit.Location

class ValueEntitySourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test("ValueEntity source") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.lightbend.akkasls.codegen.PackageNaming
import com.lightbend.akkasls.codegen.TestData

class ValueEntityTestKitGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test(
"it can generate an specific TestKit for the proto files " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.akkasls.codegen
package java

class ViewServiceSourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData()
private val testData = TestData.javaStyle

test("source, transform_updates=true") {
val service = testData.simpleViewService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ object ActionServiceSourceGenerator {
}

private[codegen] def actionProvider(service: ModelBuilder.ActionService): File = {
val imports = generateImports(
implicit val imports: Imports = generateImports(
commandTypes(service.commands),
service.fqn.parent.scalaPackage,
otherImports = Seq(
Expand Down Expand Up @@ -291,13 +291,13 @@ object ActionServiceSourceGenerator {
| extends ActionProvider[${service.className}] {
|
| override final def serviceDescriptor: Descriptors.ServiceDescriptor =
| ${service.fqn.parent.name}Proto.javaDescriptor.findServiceByName("${service.fqn.protoName}")
| ${typeName(service.descriptorObject)}.javaDescriptor.findServiceByName("${service.fqn.protoName}")
|
| override final def newHandler(context: ActionCreationContext): ${service.handlerName} =
| new ${service.handlerName}(actionFactory(context))
|
| override final def additionalDescriptors: immutable.Seq[Descriptors.FileDescriptor] =
| ${service.fqn.parent.name}Proto.javaDescriptor ::
| ${typeName(service.descriptorObject)}.javaDescriptor ::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I just fixed this and is merged already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might be thinking of #475 (comment) , which seems to be failing that PR and motivated me to do this cleanup :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks. I will rebase #475

| Nil
|
| def withOptions(options: ActionOptions): ${service.providerName} =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import com.lightbend.akkasls.codegen.TestData

class ActionServiceSourceGeneratorSuite extends munit.FunSuite {

private val testData = TestData()

private val testData = TestData.scalaStyle
test("action source") {
val service = testData.simpleActionService()
val generatedSrc =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.lightbend.akkasls.codegen.ModelBuilder
import com.lightbend.akkasls.codegen.TestData

class MainSourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData(TestData.defaultPackageNamingTemplate.copy(javaOuterClassnameOption = None))
private val testData = TestData.scalaStyle

def domainType(name: String): ModelBuilder.TypeArgument =
ModelBuilder.TypeArgument(name, testData.domainProto())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ import scalapb.compiler.{ DescriptorImplicits, GeneratorParams }
class ValueEntitySourceGeneratorSuite extends munit.FunSuite {
import com.akkaserverless.codegen.scalasdk.impl.ValueEntitySourceGenerator._

// TODO use package naming template parameter to generate Scala-style testData
private val testData = TestData()

val domainParent = PackageNaming("domain.proto", "", "com.example.service.domain", None, None, false)
val apiParent = PackageNaming("api.proto", "", "com.example.service", None, None, false)
private val testData = TestData.scalaStyle

test("it can generate a value entity implementation skeleton") {
val file =
generateImplementationSkeleton(testData.valueEntity(domainParent), testData.simpleEntityService(apiParent))
generateImplementationSkeleton(testData.valueEntity(), testData.simpleEntityService())
assertNoDiff(
file.content,
s"""package com.example.service.domain
Expand All @@ -56,7 +52,7 @@ class ValueEntitySourceGeneratorSuite extends munit.FunSuite {
|""".stripMargin)
}
test("it can generate an abstract value entity implementation") {
val str = abstractEntity(testData.valueEntity(domainParent), testData.simpleEntityService(apiParent)).content
val str = abstractEntity(testData.valueEntity(), testData.simpleEntityService()).content
assertNoDiff(
str,
s"""package com.example.service.domain
Expand All @@ -78,7 +74,7 @@ class ValueEntitySourceGeneratorSuite extends munit.FunSuite {
}

test("it can generate a value entity handler implementation") {
val str = handler(testData.valueEntity(domainParent), testData.simpleEntityService(apiParent)).content
val str = handler(testData.valueEntity(), testData.simpleEntityService()).content
assertNoDiff(
str,
s"""package com.example.service.domain
Expand Down Expand Up @@ -113,7 +109,7 @@ class ValueEntitySourceGeneratorSuite extends munit.FunSuite {

test("it can generate a provider") {
val file =
provider(testData.valueEntity(domainParent), testData.simpleEntityService(apiParent))
provider(testData.valueEntity(), testData.simpleEntityService())
assertNoDiff(
file.content,
"""package com.example.service.domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.akkaserverless.codegen.scalasdk.impl.ViewServiceSourceGenerator
import com.lightbend.akkasls.codegen.TestData

class ViewServiceSourceGeneratorSuite extends munit.FunSuite {
private val testData = TestData(TestData.defaultPackageNamingTemplate.copy(javaOuterClassnameOption = None))
private val testData = TestData.scalaStyle

test("source, transform_updates=true") {
val service = testData.simpleViewService()
Expand Down