diff --git a/internal/integration/actions.go b/internal/integration/actions.go index 50cf02296d..e1afad09c3 100644 --- a/internal/integration/actions.go +++ b/internal/integration/actions.go @@ -401,6 +401,22 @@ func VerifyKubeState(check func(ctx context.Context, t testing.TB, namespace str } } +// VerifyKubeState lets you test the current kube state +func VerifySchema(check func(ctx context.Context, t testing.TB, sch *schemapb.Schema)) Action { + return func(t testing.TB, ic TestContext) { + sch, err := ic.Controller.GetSchema(ic, connect.NewRequest(&ftlv1.GetSchemaRequest{})) + if err != nil { + t.Errorf("failed to get schema: %v", err) + return + } + if err != nil { + t.Errorf("failed to deserialize schema: %v", err) + return + } + check(ic.Context, t, sch.Msg.GetSchema()) + } +} + // Fail expects the next action to Fail. func Fail(next Action, msg string, args ...any) Action { return func(t testing.TB, ic TestContext) { diff --git a/internal/integration/harness.go b/internal/integration/harness.go index 318e1abd26..e55292a5a1 100644 --- a/internal/integration/harness.go +++ b/internal/integration/harness.go @@ -224,7 +224,7 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) { err = ftlexec.Command(ctx, log.Debug, rootDir, "just", "build", "ftl").RunBuffered(ctx) assert.NoError(t, err) } - if opts.requireJava || slices.Contains(opts.languages, "java") { + if opts.requireJava || slices.Contains(opts.languages, "java") || slices.Contains(opts.languages, "kotlin") { err = ftlexec.Command(ctx, log.Debug, rootDir, "just", "build-java", "-DskipTests", "-B").RunBuffered(ctx) assert.NoError(t, err) } diff --git a/jvm-runtime/ftl-runtime/kotlin/build-parent/pom.xml b/jvm-runtime/ftl-runtime/kotlin/build-parent/pom.xml index f8a6929d9a..3d04da517f 100644 --- a/jvm-runtime/ftl-runtime/kotlin/build-parent/pom.xml +++ b/jvm-runtime/ftl-runtime/kotlin/build-parent/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 xyz.block.ftl @@ -10,7 +11,9 @@ ftl-build-parent-kotlin pom Ftl Kotlin Build Parent POM - This pom.xml can be used as a parent pom to inherit all required configuration to build a FTL Kotlin app. + This pom.xml can be used as a parent pom to inherit all required configuration to build a FTL Kotlin + app. + @@ -28,6 +31,26 @@ kotlin-maven-plugin ${kotlin.version} + + kapt + + kapt + + + + src/main/kotlin + src/main/java + + + + + xyz.block.ftl + ftl-java-runtime + ${project.version} + + + + compile diff --git a/jvm-runtime/jvm_integration_test.go b/jvm-runtime/jvm_integration_test.go index f378d3178e..6c0bbf2a8c 100644 --- a/jvm-runtime/jvm_integration_test.go +++ b/jvm-runtime/jvm_integration_test.go @@ -3,11 +3,14 @@ package ftl_test import ( + "context" + "strings" "testing" "time" "github.com/alecthomas/assert/v2" + schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" "github.com/TBD54566975/ftl/go-runtime/ftl" in "github.com/TBD54566975/ftl/internal/integration" @@ -166,6 +169,41 @@ func TestGradle(t *testing.T) { }), ) } +func TestSchemaComments(t *testing.T) { + in.Run(t, + in.WithJavaBuild(), + in.CopyModuleWithLanguage("gomodule", "go"), + in.CopyModuleWithLanguage("javamodule", "java"), + in.CopyModuleWithLanguage("kotlinmodule", "kotlin"), + in.Deploy("gomodule"), + in.Deploy("javamodule"), + in.Deploy("kotlinmodule"), + in.VerifySchema(func(ctx context.Context, t testing.TB, sch *schemapb.Schema) { + javaOk := false + kotlinOk := false + for _, module := range sch.Modules { + if module.Name == "gomodule" { + continue + } + for _, decl := range module.Decls { + if decl.GetVerb() != nil { + for _, comment := range decl.GetVerb().GetComments() { + if strings.Contains(comment, "JAVA COMMENT") { + javaOk = true + } + if strings.Contains(comment, "KOTLIN COMMENT") { + kotlinOk = true + } + } + } + } + } + assert.True(t, javaOk, "java comment not found") + assert.True(t, kotlinOk, "kotlin comment not found") + + }), + ) +} func PairedTest(name string, testFunc func(module string) in.Action) []in.SubTest { return []in.SubTest{ diff --git a/jvm-runtime/testdata/go/gomodule/types.ftl.go b/jvm-runtime/testdata/go/gomodule/types.ftl.go index 95c3dd09b5..88067b985a 100644 --- a/jvm-runtime/testdata/go/gomodule/types.ftl.go +++ b/jvm-runtime/testdata/go/gomodule/types.ftl.go @@ -3,14 +3,12 @@ package gomodule import ( "context" - stdtime "time" - - "github.com/TBD54566975/ftl/go-runtime/ftl" + "github.com/TBD54566975/ftl/go-runtime/ftl" "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" "github.com/tbd54566975/web5-go/dids/did" + stdtime "time" ) - type BoolVerbClient func(context.Context, bool) (bool, error) type BytesVerbClient func(context.Context, []byte) ([]byte, error) @@ -71,88 +69,88 @@ func init() { reflection.Register( reflection.ExternalType(*new(did.DID)), reflection.ProvideResourcesForVerb( - BoolVerb, + BoolVerb, ), reflection.ProvideResourcesForVerb( - BytesVerb, + BytesVerb, ), reflection.ProvideResourcesForVerb( - EmptyVerb, + EmptyVerb, ), reflection.ProvideResourcesForVerb( - ErrorEmptyVerb, + ErrorEmptyVerb, ), reflection.ProvideResourcesForVerb( - ExternalTypeVerb, + ExternalTypeVerb, ), reflection.ProvideResourcesForVerb( - FloatVerb, + FloatVerb, ), reflection.ProvideResourcesForVerb( - IntVerb, + IntVerb, ), reflection.ProvideResourcesForVerb( - ObjectArrayVerb, + ObjectArrayVerb, ), reflection.ProvideResourcesForVerb( - ObjectMapVerb, + ObjectMapVerb, ), reflection.ProvideResourcesForVerb( - OptionalBoolVerb, + OptionalBoolVerb, ), reflection.ProvideResourcesForVerb( - OptionalBytesVerb, + OptionalBytesVerb, ), reflection.ProvideResourcesForVerb( - OptionalFloatVerb, + OptionalFloatVerb, ), reflection.ProvideResourcesForVerb( - OptionalIntVerb, + OptionalIntVerb, ), reflection.ProvideResourcesForVerb( - OptionalStringArrayVerb, + OptionalStringArrayVerb, ), reflection.ProvideResourcesForVerb( - OptionalStringMapVerb, + OptionalStringMapVerb, ), reflection.ProvideResourcesForVerb( - OptionalStringVerb, + OptionalStringVerb, ), reflection.ProvideResourcesForVerb( - OptionalTestObjectOptionalFieldsVerb, + OptionalTestObjectOptionalFieldsVerb, ), reflection.ProvideResourcesForVerb( - OptionalTestObjectVerb, + OptionalTestObjectVerb, ), reflection.ProvideResourcesForVerb( - OptionalTimeVerb, + OptionalTimeVerb, ), reflection.ProvideResourcesForVerb( - ParameterizedObjectVerb, + ParameterizedObjectVerb, ), reflection.ProvideResourcesForVerb( - SinkVerb, + SinkVerb, ), reflection.ProvideResourcesForVerb( - SourceVerb, + SourceVerb, ), reflection.ProvideResourcesForVerb( - StringArrayVerb, + StringArrayVerb, ), reflection.ProvideResourcesForVerb( - StringMapVerb, + StringMapVerb, ), reflection.ProvideResourcesForVerb( - StringVerb, + StringVerb, ), reflection.ProvideResourcesForVerb( - TestObjectOptionalFieldsVerb, + TestObjectOptionalFieldsVerb, ), reflection.ProvideResourcesForVerb( - TestObjectVerb, + TestObjectVerb, ), reflection.ProvideResourcesForVerb( - TimeVerb, + TimeVerb, ), ) -} \ No newline at end of file +} diff --git a/jvm-runtime/testdata/java/javamodule/src/main/java/xyz/block/ftl/test/TestInvokeGoFromJava.java b/jvm-runtime/testdata/java/javamodule/src/main/java/xyz/block/ftl/test/TestInvokeGoFromJava.java index 075b07b784..a3b377ba85 100644 --- a/jvm-runtime/testdata/java/javamodule/src/main/java/xyz/block/ftl/test/TestInvokeGoFromJava.java +++ b/jvm-runtime/testdata/java/javamodule/src/main/java/xyz/block/ftl/test/TestInvokeGoFromJava.java @@ -60,7 +60,9 @@ public void sinkVerb(String input, SinkVerbClient sinkVerbClient) { public String sourceVerb(SourceVerbClient sourceVerbClient) { return sourceVerbClient.call(); } - + /** + * JAVA COMMENT + */ @Export @Verb public void errorEmptyVerb(ErrorEmptyVerbClient client) { diff --git a/jvm-runtime/testdata/kotlin/kotlinmodule/src/main/kotlin/xyz/block/ftl/test/TestInvokeGoFromKotlin.kt b/jvm-runtime/testdata/kotlin/kotlinmodule/src/main/kotlin/xyz/block/ftl/test/TestInvokeGoFromKotlin.kt index 887eef8549..a1fc798f90 100644 --- a/jvm-runtime/testdata/kotlin/kotlinmodule/src/main/kotlin/xyz/block/ftl/test/TestInvokeGoFromKotlin.kt +++ b/jvm-runtime/testdata/kotlin/kotlinmodule/src/main/kotlin/xyz/block/ftl/test/TestInvokeGoFromKotlin.kt @@ -24,6 +24,9 @@ fun sourceVerb(sourceVerbClient: SourceVerbClient): String { return sourceVerbClient.call() } +/** + * KOTLIN COMMENT + */ @Export @Verb fun errorEmptyVerb(client: ErrorEmptyVerbClient) {