Thank for your reply, here my Test:
`
private FixtureConfiguration fixture;
@Mock
private ClaimedUserNameRepository claimedUserNameRepository;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
fixture = Fixtures.newGivenWhenThenFixture(MyAggregate.class);
final MyAggregateCommandHandler commandHandler = new MyAggregateCommandHandler();
commandHandler.setRepository(fixture.getRepository());
commandHandler.setClaimedUserNameRepository(claimedUserNameRepository);
fixture.registerAnnotatedCommandHandler(commandHandler);
}
@Test
public void testExpireRichiestaIscrizione_happypath() throws Exception {
final MyAggregateId aggregateIdentifier = new MyAggregateId();
final String token = UUID.randomUUID().toString();
final String userName = “userName”;
final String plainPassword = “password”;
final String passwordHash = DigestUtils.sha1(plainPassword);
fixture//
.given(new MyAggregateCreatedEvent(aggregateIdentifier, userName, passwordHash, token))//
.when(new ExpireMyAggregateCommand(aggregateIdentifier, userName))//
.expectEvents(new MyAggregateExpiredEvent(aggregateIdentifier));
}
`
Note: Dubugging my Test I noticed the method
`
@EventHandler
public void handle(final MyAggregateNameExpiredEvent event) {
markDeleted();
}
`
was called twice and second time get the Exception, so error should be in the test irself or Command/Event roundtrip
Any suggestion are welcome