com.github.dreamhead.moco.MocoEventTrigger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco;
public class MocoEventTrigger implements ConfigApplier {
private final MocoEvent event;
private final MocoEventAction action;
public MocoEventTrigger(final MocoEvent event, final MocoEventAction action) {
this.event = event;
this.action = action;
}
public boolean isFor(final MocoEvent event) {
return this.event == event;
}
public void fireEvent(final Request request) {
action.execute(request);
}
@Override
public MocoEventTrigger apply(final MocoConfig config) {
MocoEventAction appliedAction = this.action.apply(config);
if (appliedAction != this.action) {
return new MocoEventTrigger(event, appliedAction);
}
return this;
}
}