Hello everyone
We are still working with M5. I know there is a new version, but still we need work on M5 before refactor the whole thing. Saying that we got the following problem.
We have a command in kotlin
class UpdatePasswordTokenCommand(@TargetAggregateIdentifier override val accountId: String, override val firstName: String,
override val lastName: String, override val email: String, override val phone: String,
override val companyNumber: String, override val type: String, override val password: String, override val active: Boolean,
val passwordResetToken: String)
And an event
class AccountUpdatedPasswordTokenEvent(val accountId: String, val password: String, val passwordResetToken: String)
We are using the commandGateway to raise a command handler and this is our handler
@CommandHandler
public void handle(UpdatePasswordTokenCommand command) {
AccountUpdatedPasswordTokenEvent updateEvent = new AccountUpdatedPasswordTokenEvent(command.getAccountId(),command.getPassword(),command.getPasswordResetToken());
apply(updateEvent);
}
and this is our event
@EventHandler
public void on(AccountUpdatedPasswordTokenEvent event) {
this.accountId = event.getAccountId();
this.password = event.getPassword();
this.passwordResetToken = event.getPasswordResetToken();
}
This is our test:
public class AccountTest {
private FixtureConfiguration fixture;
@Before
public void setUp() throws Exception {
fixture = Fixtures.newGivenWhenThenFixture(Account.class);
Account account = new Account();
fixture.registerAnnotatedCommandHandler(account);
}
@Test
public void testUpdateToken() {
fixture.givenNoPriorActivity()
.when(new UpdatePasswordTokenCommand("1","firstName","lastName","com",
"12344555","4000","CUSTOMER","mypassword",true,"1234@"))
.expectEvents(new AccountUpdatedPasswordTokenEvent("1","mypassword","1234@"));
}
}
However we are getting the following error:
Expected | Actual |
---|---|
com.myapp.coreapi.AccountUpdatedPasswordTokenEvent < | > |
A probable cause for the wrong chain of events is an exception that occurred while handling the command.
java.lang.IllegalStateException: Cannot retrieve current AggregateLifecycle; none is yet defined
Could you please someone help us?
Ganneshh