pl.allegro.tech.servicemesh.envoycontrol.assertions.AwaitAssertions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-tests Show documentation
Show all versions of envoy-control-tests Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
package pl.allegro.tech.servicemesh.envoycontrol.assertions
import org.assertj.core.api.Assertions
import org.awaitility.Awaitility
import java.time.Duration
fun untilAsserted(
poll: Duration = Duration.ofMillis(500),
wait: Duration = Duration.ofSeconds(90),
fn: () -> (T)
): T {
var lastResult: T? = null
Awaitility.await().atMost(wait)
.pollInterval(poll)
.untilAsserted { lastResult = fn() }
Assertions.assertThat(lastResult).isNotNull
return lastResult!!
}