se.bjurr.wiremockpact.wiremockpactextensionjunit5.WireMockPactExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wiremock-pact-extension-junit5 Show documentation
Show all versions of wiremock-pact-extension-junit5 Show documentation
Transform Wiremock mappings to PACT.
The newest version!
package se.bjurr.wiremockpact.wiremockpactextensionjunit5;
import com.github.tomakehurst.wiremock.extension.Parameters;
import com.github.tomakehurst.wiremock.extension.ServeEventListener;
import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
import se.bjurr.wiremockpact.wiremockpactextensionjunit5.support.BaseSetupJunitExtension;
import se.bjurr.wiremockpact.wiremockpactlib.api.WireMockPactApi;
import se.bjurr.wiremockpact.wiremockpactlib.api.WireMockPactConfig;
public class WireMockPactExtension extends BaseSetupJunitExtension implements ServeEventListener {
private final WireMockPactApi wiremockPactApi;
public WireMockPactExtension(final WireMockPactConfig config) {
super();
this.wiremockPactApi = WireMockPactApi.create(config);
}
@Override
public String getName() {
return WireMockPactExtension.class.getSimpleName();
}
@Override
public void afterComplete(final ServeEvent serveEvent, final Parameters parameters) {
this.wiremockPactApi.addServeEvent(serveEvent);
}
@Override
public void setup() {
this.wiremockPactApi.clearAllSaved();
}
@Override
public void close() throws Throwable {
this.wiremockPactApi.saveAll();
}
}