Skip to content

Commit 0d422b3

Browse files
Improve testing tools Javadocs (#388)
1 parent 5880f27 commit 0d422b3

File tree

6 files changed

+41
-14
lines changed

6 files changed

+41
-14
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
uses: gradle/actions/wrapper-validation@v3
3232

3333
- name: Build with Gradle
34-
run: ./gradlew build
34+
# Javadoc 11 won't work with our Javadocs, they need 21
35+
run: ./gradlew build -x javadoc
3536

3637
- name: Upload test results
3738
if: always()

sdk-testing/src/main/java/dev/restate/sdk/testing/ManualRestateRunner.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@
3030
import org.testcontainers.images.builder.Transferable;
3131
import org.testcontainers.utility.DockerImageName;
3232

33-
/** Manual runner for Restate. We recommend using {@link RestateRunner} with JUnit 5. */
33+
/**
34+
* Manual runner for the Restate test infra, starting the Restate server container together with the
35+
* provided services and automatically registering them. To start the infra use {@link #run()} and
36+
* to stop it use {@link #stop()}.
37+
*
38+
* <p>Use {@link RestateRunnerBuilder#buildManualRunner()} to build an instance of this class.
39+
*
40+
* <p>If you use JUnit 5, we suggest using {@link RestateRunner} instead.
41+
*/
3442
public class ManualRestateRunner
3543
implements AutoCloseable, ExtensionContext.Store.CloseableResource {
3644

@@ -75,6 +83,12 @@ public class ManualRestateRunner
7583
}
7684

7785
/** Run restate, run the embedded service endpoint server, and register the services. */
86+
public void start() {}
87+
88+
/**
89+
* @deprecated Use {@link #start()} instead.
90+
*/
91+
@Deprecated(forRemoval = true)
7892
public void run() {
7993
// Start listening the local server
8094
try {

sdk-testing/src/main/java/dev/restate/sdk/testing/RestateRunner.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,29 @@
1515
* Restate runner for JUnit 5. Example:
1616
*
1717
* <pre>{@code
18-
* {@literal @}RegisterExtension
18+
* @RegisterExtension
1919
* private final static RestateRunner restateRunner = RestateRunnerBuilder.create()
2020
* .withService(new MyService())
2121
* .buildRunner();
2222
* }</pre>
2323
*
24-
* <p>The runner will deploy the services locally, execute Restate as container using
25-
* testcontainers, and register the services.
24+
* <p>The runner will deploy the services locally, execute Restate as container using <a
25+
* href="https://java.testcontainers.org/">Testcontainers</a>, and register the services.
2626
*
2727
* <p>This extension is scoped per test class, meaning that the restate runner will be shared among
2828
* test methods.
2929
*
3030
* <p>Use the annotations {@link RestateClient}, {@link RestateURL} and {@link RestateAdminClient}
31-
* to interact with the deployed runtime:
31+
* to interact with the deployed server:
3232
*
3333
* <pre>{@code
34-
* {@literal @}Test
35-
* void testGreet({@literal @}RestateGrpcChannel ManagedChannel channel) {
36-
* CounterGrpc.CounterBlockingStub client = CounterGrpc.newBlockingStub(channel);
37-
* // Use client
34+
* @Test
35+
* void initialCountIsZero(@RestateClient Client client) {
36+
* var client = CounterClient.fromClient(ingressClient, "my-counter");
37+
*
38+
* // Use client as usual
39+
* long response = client.get();
40+
* assertThat(response).isEqualTo(0L);
3841
* }
3942
* }</pre>
4043
*/

sdk-testing/src/main/java/dev/restate/sdk/testing/RestateRunnerBuilder.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
import java.util.HashMap;
1414
import java.util.Map;
1515

16-
/** Builder for {@link RestateRunner}. See {@link RestateRunner} for more details. */
16+
/**
17+
* Builder for {@link RestateRunner}.
18+
*
19+
* @see RestateRunner
20+
*/
1721
public class RestateRunnerBuilder {
1822

1923
private static final String DEFAULT_RESTATE_CONTAINER = "docker.io/restatedev/restate";
@@ -73,6 +77,9 @@ public <O> RestateRunnerBuilder bind(ServiceDefinition<O> serviceDefinition, O o
7377
return this;
7478
}
7579

80+
/**
81+
* @return a {@link ManualRestateRunner} to start and stop the test infra manually.
82+
*/
7683
public ManualRestateRunner buildManualRunner() {
7784
return new ManualRestateRunner(
7885
this.endpointBuilder.build(),
@@ -81,6 +88,9 @@ public ManualRestateRunner buildManualRunner() {
8188
this.configFile);
8289
}
8390

91+
/**
92+
* @return a {@link RestateRunner} to be used as JUnit 5 Extension.
93+
*/
8494
public RestateRunner buildRunner() {
8595
return new RestateRunner(this.buildManualRunner());
8696
}

sdk-testing/src/main/java/dev/restate/sdk/testing/RestateURL.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
import java.net.URL;
1616

1717
/**
18-
* Inject Restate's URL (either {@link String} or {@link URL}) to interact with the deployed
19-
* runtime.
18+
* Inject Restate's URL (either {@link String} or {@link URL}) to interact with the deployed server.
2019
*/
2120
@Target(value = ElementType.PARAMETER)
2221
@Retention(RetentionPolicy.RUNTIME)

sdk-testing/src/test/java/dev/restate/sdk/testing/CounterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class CounterTest {
2929
@Timeout(value = 10)
3030
void testGreet(@RestateClient Client ingressClient) {
3131
var client = CounterClient.fromClient(ingressClient, "my-counter");
32-
long response = client.get();
3332

33+
long response = client.get();
3434
assertThat(response).isEqualTo(0L);
3535
}
3636
}

0 commit comments

Comments
 (0)