All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.MocoEventTrigger Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy