vertx.effect.mock.MockBodyResp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-effect Show documentation
Show all versions of vertx-effect Show documentation
When actors meet Functional Programming
package vertx.effect.mock;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpServerRequest;
import jsonvalues.JsObj;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.IntFunction;
public interface MockBodyResp extends IntFunction>> {
static MockBodyResp cons(final String respBody) {
return n -> body -> req -> respBody;
}
static MockBodyResp consAfter(final Duration duration, final String respBody) {
return n -> body -> req -> {
try {
TimeUnit.MILLISECONDS.sleep(duration.toMillis());
} catch (InterruptedException e) {
e.printStackTrace();
}
return respBody;
};
}
static MockBodyResp cons(final JsObj respBody) {
return n -> body -> req -> respBody.toPrettyString();
}
static MockBodyResp consAfter(final Duration duration, final JsObj respBody) {
return n -> body -> req -> {
try {
TimeUnit.MILLISECONDS.sleep(duration.toMillis());
} catch (InterruptedException e) {
e.printStackTrace();
}
return respBody.toPrettyString();
};
}
MockBodyResp EMPTY = n -> body -> req -> "";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy