Hello,
Please can the community help me.
I am mocking an AgendaListener on my working memory session using Mockito.
However, Mockito's ArgumentCaptor is not picking up the event. Please can
you tell me where I am going wrong (code below):
Code:
// Set up knowledge base and sessions etc ....
AgendaEventListener ael = mock(AgendaEventListener.class);
ksession.addEventListener(ael);
// push data into session ....
ArgumentCaptor<AfterActivationFiredEvent> af =
ArgumentCaptor.forClass(AfterActivationFiredEvent.class);
verify(ael).afterActivationFired(af.capture()); *// This fails*
List<AfterActivationFiredEvent> events = aafe.getAllValues();
AfterActivationFiredEvent first = events.get(0);
assertThat(first.getActivation().getRule().getName(), is("My rule"));
If I add the listener as follows, I can see that the afterActivationFired()
method is being called:
ksession.addEventListener(new AgendaEventListener() {
@Override
public void beforeRuleFlowGroupDeactivated(
RuleFlowGroupDeactivatedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent
event) {
// TODO Auto-generated method stub
}
@Override
public void beforeActivationFired(BeforeActivationFiredEvent event) {
// TODO Auto-generated method stub
}
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void afterRuleFlowGroupDeactivated(
RuleFlowGroupDeactivatedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent
event) {
// TODO Auto-generated method stub
}
@Override
public void afterActivationFired(AfterActivationFiredEvent event) {
// TODO Auto-generated method stub
System.out.println(event.getActivation().getRule().getName());
}
@Override
public void activationCreated(ActivationCreatedEvent event) {
// TODO Auto-generated method stub
}
@Override
public void activationCancelled(ActivationCancelledEvent event) {
// TODO Auto-generated method stub
}
});
Thanks for your help in advance.
Regards,
--
View this message in context:
http://drools.46999.n3.nabble.com/AgendaListener-Mockito-not-capturing-ar...
Sent from the Drools: User forum mailing list archive at
Nabble.com.