diff --git a/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java b/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java index 052f8e14f4..0dcae9c2e9 100644 --- a/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java +++ b/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java @@ -9,6 +9,7 @@ import akka.pattern.StatusReply; import org.scalatestplus.junit.JUnitSuite; import static jdocs.akka.cluster.sharding.typed.AccountExampleWithEventHandlersInState.AccountEntity; +import static org.junit.Assert.*; // #test import java.math.BigDecimal; @@ -23,8 +24,6 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; // #test @@ -64,6 +63,14 @@ public class AccountExampleDocTest assertEquals(BigDecimal.ZERO, result.stateOfType(AccountEntity.OpenedAccount.class).balance); } + @Test + public void createWithUnHandle() { + CommandResultWithReply< + AccountEntity.Command, AccountEntity.Event, AccountEntity.Account, StatusReply> + result = eventSourcedTestKit.runCommand(AccountEntity.CreateAccount::new); + assertFalse(result.hasNoReply()); + } + @Test public void handleWithdraw() { eventSourcedTestKit.runCommand(AccountEntity.CreateAccount::new); diff --git a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/internal/EventSourcedBehaviorTestKitImpl.scala b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/internal/EventSourcedBehaviorTestKitImpl.scala index d448ecb862..5f01bcd548 100644 --- a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/internal/EventSourcedBehaviorTestKitImpl.scala +++ b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/internal/EventSourcedBehaviorTestKitImpl.scala @@ -69,6 +69,8 @@ import akka.stream.scaladsl.Sink s"but was [${other.getClass.getName}]") } } + + override def hasNoReply: Boolean = replyOption.isEmpty } final case class RestartResultImpl[State](state: State) extends RestartResult[State] diff --git a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/javadsl/EventSourcedBehaviorTestKit.scala b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/javadsl/EventSourcedBehaviorTestKit.scala index b5984adfa4..0899d8c8de 100644 --- a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/javadsl/EventSourcedBehaviorTestKit.scala +++ b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/javadsl/EventSourcedBehaviorTestKit.scala @@ -186,6 +186,12 @@ object EventSourcedBehaviorTestKit { */ def replyOfType[R <: Reply](replyClass: Class[R]): R = delegate.replyOfType(ClassTag[R](replyClass)) + + /** + * `true` if there is no reply. + */ + def hasNoReply: Boolean = delegate.hasNoReply + } /** diff --git a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/scaladsl/EventSourcedBehaviorTestKit.scala b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/scaladsl/EventSourcedBehaviorTestKit.scala index b1a66f6ce4..9c0309fd92 100644 --- a/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/scaladsl/EventSourcedBehaviorTestKit.scala +++ b/akka-persistence-testkit/src/main/scala/akka/persistence/testkit/scaladsl/EventSourcedBehaviorTestKit.scala @@ -172,6 +172,12 @@ object EventSourcedBehaviorTestKit { * if the reply is of a different type. */ def replyOfType[R <: Reply: ClassTag]: R + + /** + * `true` if there is no reply. + */ + def hasNoReply: Boolean + } /**