-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: documenting ComponentClient (#1751)
* docs: documenting ComponentClient * Apply suggestions from code review Co-authored-by: Eduardo Pinto <[email protected]> --------- Co-authored-by: Eduardo Pinto <[email protected]>
- Loading branch information
Showing
10 changed files
with
177 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...tion/src/it/java/com/example/fibonacci/FibonacciActionComponentClientIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.example.fibonacci; | ||
|
||
import com.example.Main; | ||
import com.google.protobuf.any.Any; | ||
import kalix.javasdk.DeferredCall; | ||
import kalix.spring.testkit.KalixIntegrationTestKitSupport; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.HttpStatusCode; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static java.time.temporal.ChronoUnit.SECONDS; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
@DirtiesContext | ||
// tag::testing-action[] | ||
@SpringBootTest(classes = Main.class) | ||
public class FibonacciActionComponentClientIntegrationTest extends KalixIntegrationTestKitSupport { | ||
|
||
private Duration timeout = Duration.of(5, SECONDS); | ||
|
||
@Test | ||
public void calculateNextNumber() throws ExecutionException, InterruptedException, TimeoutException { | ||
|
||
Number response = componentClient.forAction() // <1> | ||
.call(FibonacciAction::nextNumber) | ||
.params(new Number(5)) | ||
.execute() // <2> | ||
.toCompletableFuture() | ||
.get(timeout.toMillis(), MILLISECONDS); | ||
|
||
Assertions.assertEquals(8, response.value()); | ||
} | ||
// end::testing-action[] | ||
|
||
@Test | ||
public void calculateNextNumberWithLimitedFibo() throws ExecutionException, InterruptedException, TimeoutException { | ||
|
||
Number response = componentClient.forAction() | ||
.call(LimitedFibonacciAction::nextNumber) | ||
.params(new Number(5)) | ||
.execute() | ||
.toCompletableFuture() | ||
.get(timeout.toMillis(), MILLISECONDS); | ||
|
||
Assertions.assertEquals(8, response.value()); | ||
} | ||
|
||
// tag::testing-action[] | ||
} | ||
// end::testing-action[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters