add hasNoReply method on CommandResult (#31277)

This commit is contained in:
梦境迷离 2022-03-24 22:49:31 +08:00 committed by GitHub
parent f8d7e0fb34
commit ec567fbbce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View file

@ -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<Done>>
result = eventSourcedTestKit.runCommand(AccountEntity.CreateAccount::new);
assertFalse(result.hasNoReply());
}
@Test
public void handleWithdraw() {
eventSourcedTestKit.runCommand(AccountEntity.CreateAccount::new);

View file

@ -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]

View file

@ -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
}
/**

View file

@ -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
}
/**