Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support junit5 in Java Protobuf SDK #1876

Merged
merged 13 commits into from
Nov 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ object ActionTestKitGenerator {
s"${packageName}.${className}TestKit",
"akka.stream.javadsl.Source",
"kalix.javasdk.testkit.ActionResult",
"org.junit.Ignore",
"org.junit.Test",
"static org.junit.Assert.*")
"org.junit.jupiter.api.Disabled",
"org.junit.jupiter.api.Test",
"static org.junit.jupiter.api.Assertions.*")
++ commandStreamedTypes(commands))

val testClassName = s"${className}Test"
Expand All @@ -125,7 +125,7 @@ object ActionTestKitGenerator {
|public class $testClassName {
|
| @Test
| @Ignore("to be implemented")
| @Disabled("to be implemented")
| public void exampleTest() {
| ${className}TestKit service = ${className}TestKit.of($className::new);
| // // use the testkit to execute a command
Expand Down Expand Up @@ -198,7 +198,7 @@ object ActionTestKitGenerator {
commands
.map { command =>
s"""|@Test
|@Ignore("to be implemented")
|@Disabled("to be implemented")
|public void ${lowerFirst(command.name)}Test() {
| ${service.className}TestKit testKit = ${service.className}TestKit.of(${service.className}::new);""".stripMargin +
(if (command.isUnary || command.isStreamOut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ object EntityServiceSourceGenerator {
List(service.messageType.parent.javaPackage + "." + serviceName) ++
Seq(
"kalix.javasdk.testkit.junit.KalixTestKitResource",
"org.junit.ClassRule",
"org.junit.Ignore",
"org.junit.Test",
"org.junit.jupiter.api.extension.RegisterExtension",
"org.junit.jupiter.api.Disabled",
"org.junit.jupiter.api.Test",
mainClassPackageName + "." + mainClassName) ++ extraImports)

val testCases = service.commands.map { command =>
s"""|@Test
|@Ignore("to be implemented")
|@Disabled("to be implemented")
|public void ${lowerFirst(command.name)}OnNonExistingEntity() throws Exception {
| // TODO: set fields in command, and provide assertions to match replies
| // client.${lowerFirst(command.name)}(${qualifiedType(command.inputType)}.newBuilder().build())
Expand All @@ -222,7 +222,7 @@ object EntityServiceSourceGenerator {
| /**
| * The test kit starts both the service container and the Kalix proxy.
| */
| @ClassRule
| @RegisterExtension
| public static final KalixTestKitResource testKit =
| new KalixTestKitResource(${mainClassName}.createKalix());
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ object EventSourcedEntityTestKitGenerator {
"kalix.javasdk.eventsourcedentity.EventSourcedEntity",
"kalix.javasdk.eventsourcedentity.EventSourcedEntityContext",
"kalix.javasdk.testkit.EventSourcedResult",
"org.junit.Ignore",
"org.junit.Test"))
"org.junit.jupiter.api.Disabled",
"org.junit.jupiter.api.Test"))

val entityClassName = entity.messageType.name
val testkitClassName = s"${entityClassName}TestKit"

val dummyTestCases = commands.map { command =>
s"""|@Test
|@Ignore("to be implemented")
|@Disabled("to be implemented")
|public void ${lowerFirst(command.name)}Test() {
| $testkitClassName service = $testkitClassName.of(${entityClassName}::new);
| // ${command.inputType.name} command = ${command.inputType.name}.newBuilder()...build();
Expand All @@ -210,14 +210,14 @@ object EventSourcedEntityTestKitGenerator {
|
|${writeImports(imports)}
|
|import static org.junit.Assert.*;
|import static org.junit.jupiter.api.Assertions.*;
|
|$unmanagedComment
|
|public class ${entityClassName}Test {
|
| @Test
| @Ignore("to be implemented")
| @Disabled("to be implemented")
| public void exampleTest() {
| $testkitClassName service = $testkitClassName.of(${entityClassName}::new);
| // // use the testkit to execute a command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ object ValueEntityTestKitGenerator {
"com.google.protobuf.Empty",
"kalix.javasdk.valueentity.ValueEntity",
"kalix.javasdk.testkit.ValueEntityResult",
"org.junit.Ignore",
"org.junit.Test"))
"org.junit.jupiter.api.Disabled",
"org.junit.jupiter.api.Test"))

val entityClassName = entity.messageType.name
val testkitClassName = s"${entityClassName}TestKit"

val dummyTestCases = service.commands.map { command =>
s"""|@Test
|@Ignore("to be implemented")
|@Disabled("to be implemented")
|public void ${lowerFirst(command.name)}Test() {
| $testkitClassName service = $testkitClassName.of(${entityClassName}::new);
| // ${command.inputType.name} command = ${command.inputType.name}.newBuilder()...build();
Expand All @@ -215,14 +215,14 @@ object ValueEntityTestKitGenerator {
|
|${writeImports(imports)}
|
|import static org.junit.Assert.*;
|import static org.junit.jupiter.api.Assertions.*;
|
|$unmanagedComment
|
|public class ${entityClassName}Test {
|
| @Test
| @Ignore("to be implemented")
| @Disabled("to be implemented")
| public void exampleTest() {
| $testkitClassName service = $testkitClassName.of(${entityClassName}::new);
| // // use the testkit to execute a command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.example.service.MyServiceNamedAction;
import org.example.service.MyServiceNamedActionTestKit;
import org.example.service.ServiceOuterClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

// This class was initially generated based on the .proto definition by Kalix tooling.
//
Expand All @@ -19,7 +19,7 @@
public class MyServiceNamedActionTest {

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void exampleTest() {
MyServiceNamedActionTestKit service = MyServiceNamedActionTestKit.of(MyServiceNamedAction::new);
// // use the testkit to execute a command
Expand All @@ -31,28 +31,28 @@ public void exampleTest() {
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void simpleMethodTest() {
MyServiceNamedActionTestKit testKit = MyServiceNamedActionTestKit.of(MyServiceNamedAction::new);
// ActionResult<Empty> result = testKit.simpleMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedOutputMethodTest() {
MyServiceNamedActionTestKit testKit = MyServiceNamedActionTestKit.of(MyServiceNamedAction::new);
// Source<ActionResult<Empty>, akka.NotUsed> result = testKit.streamedOutputMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedInputMethodTest() {
MyServiceNamedActionTestKit testKit = MyServiceNamedActionTestKit.of(MyServiceNamedAction::new);
// ActionResult<Empty> result = testKit.streamedInputMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void fullStreamedMethodTest() {
MyServiceNamedActionTestKit testKit = MyServiceNamedActionTestKit.of(MyServiceNamedAction::new);
// Source<ActionResult<Empty>, akka.NotUsed> result = testKit.fullStreamedMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.example.service.MyServiceActionTestKit;
import org.example.service.ServiceOuterClass;
import org.external.ExternalDomain;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

// This class was initially generated based on the .proto definition by Kalix tooling.
//
Expand All @@ -19,7 +19,7 @@
public class MyServiceActionTest {

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void exampleTest() {
MyServiceActionTestKit service = MyServiceActionTestKit.of(MyServiceAction::new);
// // use the testkit to execute a command
Expand All @@ -31,28 +31,28 @@ public void exampleTest() {
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void simpleMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// ActionResult<ExternalDomain.Empty> result = testKit.simpleMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedOutputMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// Source<ActionResult<ExternalDomain.Empty>, akka.NotUsed> result = testKit.streamedOutputMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedInputMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// ActionResult<ExternalDomain.Empty> result = testKit.streamedInputMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void fullStreamedMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// Source<ActionResult<ExternalDomain.Empty>, akka.NotUsed> result = testKit.fullStreamedMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.example.service.MyServiceActionTestKit;
import org.example.service.ServiceOuterClass;
import org.external.ExternalDomain;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

// This class was initially generated based on the .proto definition by Kalix tooling.
//
Expand All @@ -19,7 +19,7 @@
public class MyServiceActionTest {

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void exampleTest() {
MyServiceActionTestKit service = MyServiceActionTestKit.of(MyServiceAction::new);
// // use the testkit to execute a command
Expand All @@ -31,28 +31,28 @@ public void exampleTest() {
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void simpleMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// ActionResult<ExternalDomain.Empty> result = testKit.simpleMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedOutputMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// Source<ActionResult<ExternalDomain.Empty>, akka.NotUsed> result = testKit.streamedOutputMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void streamedInputMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// ActionResult<ExternalDomain.Empty> result = testKit.streamedInputMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void fullStreamedMethodTest() {
MyServiceActionTestKit testKit = MyServiceActionTestKit.of(MyServiceAction::new);
// Source<ActionResult<ExternalDomain.Empty>, akka.NotUsed> result = testKit.fullStreamedMethod(Source.single(ServiceOuterClass.MyRequest.newBuilder()...build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.example.service.MyServiceActionImpl;
import org.example.service.MyServiceActionImplTestKit;
import org.example.service.ServiceOuterClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

// This class was initially generated based on the .proto definition by Kalix tooling.
//
Expand All @@ -18,7 +18,7 @@
public class MyServiceActionImplTest {

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void exampleTest() {
MyServiceActionImplTestKit service = MyServiceActionImplTestKit.of(MyServiceActionImpl::new);
// // use the testkit to execute a command
Expand All @@ -30,7 +30,7 @@ public void exampleTest() {
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void simpleMethodTest() {
MyServiceActionImplTestKit testKit = MyServiceActionImplTestKit.of(MyServiceActionImpl::new);
// ActionResult<Empty> result = testKit.simpleMethod(ServiceOuterClass.MyRequest.newBuilder()...build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import kalix.javasdk.testkit.junit.KalixTestKitResource;
import org.example.Main;
import org.example.state.OuterCounterState;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static java.util.concurrent.TimeUnit.*;

Expand All @@ -22,7 +22,7 @@ public class CounterIntegrationTest {
/**
* The test kit starts both the service container and the Kalix proxy.
*/
@ClassRule
@RegisterExtension
public static final KalixTestKitResource testKit =
new KalixTestKitResource(Main.createKalix());

Expand All @@ -36,15 +36,15 @@ public CounterIntegrationTest() {
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void increaseOnNonExistingEntity() throws Exception {
// TODO: set fields in command, and provide assertions to match replies
// client.increase(CounterApi.IncreaseValue.newBuilder().build())
// .toCompletableFuture().get(5, SECONDS);
}

@Test
@Ignore("to be implemented")
@Disabled("to be implemented")
public void decreaseOnNonExistingEntity() throws Exception {
// TODO: set fields in command, and provide assertions to match replies
// client.decrease(CounterApi.DecreaseValue.newBuilder().build())
Expand Down
Loading