Skip to content

Commit

Permalink
Building source and javadoc jars
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmalek committed Jul 5, 2022
1 parent eda3ce5 commit 35d9109
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 43 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugins {
id("nebula.maven-scm") version "18.4.0"
id("nebula.contacts") version "6.0.0"
id("nebula.info-scm") version "11.3.3"
id("nebula.source-jar") version "18.4.0"
id("nebula.javadoc-jar") version "18.4.0"
id("tylerthrailkill.nebula-mit-license") version "0.0.3"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"

Expand Down
57 changes: 51 additions & 6 deletions src/main/java/com/webfleet/assertj/AsyncAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,54 @@
public interface AsyncAssert
{
/**
* Awaits until all assertions are passed or timeout is exceeded.
* Awaits, until all configured assertions are passed or timeout is exceeded.
* <p>
* Assertions are configured in lambda consumer of {@link SoftAssertions} object on each check.
* The checks are executed periodically with check interval delay configured with {@link AsyncAssert#withCheckInterval} method.
* After exceeding timeout {@link AssertionError} will be thrown with failures from last assertion check.
*
* <pre><code class='java'>
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostOneSecond().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* async.assertThat(isDone()).isTrue();
* });
* </code></pre>
* }</pre>
*
* @param assertionsConfigurer lambda consumer configuring {@link SoftAssertions} object
*/
void untilAssertions(Consumer<SoftAssertions> assertionsConfigurer);

/**
* Configures assertion to use give mutex object for check interval wait logic.
*
* Configures assertion to use given mutex object for check interval wait logic.
* <p>
* In multi-thread applications, the mutex object can be used to notify the other thread about state change.
* For asynchronous assertion, the mutex object can be used to reduce the wait time between checks with {@link Object#notifyAll()} call.
* <p>
* Example usage:
* <pre>{@code
* // given
* var condition = new AtomicBoolean();
* var waitMutex = new Object();
* var executor = Executors.newSingleThreadExecutor();
*
* // when
* executor.execute(() -> {
* // ... asynchronous logic
* condition.set(true);
* // notify after done
* synchronized (waitMutex) {
* waitMutex.notifyAll();
* }
* });
*
* // then
* awaitAtMostOneSecond()
* .usingWaitMutex(waitMutex)
* .untilAssertions(async -> {
* async.assertThat(condition).isTrue();
* });
* }</pre>
*
* @param waitMutex mutex object
* @return new {@link AsyncAssert} using given wait mutex
Expand All @@ -45,6 +72,15 @@ public interface AsyncAssert
/**
* Configures the interval to be waited between assertions checks.
* The interval must be greater than zero and lower than timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostOneSecond()
* .withCheckInterval(Duration.ofMillis(500))
* .untilAssertions(async -> {
* async.assertThat(condition).isTrue();
* });
* }</pre>
*
* @param checkInterval check interval
* @return new {@link AsyncAssert} with set check interval
Expand All @@ -54,6 +90,15 @@ public interface AsyncAssert
/**
* Configures the interval to be waited between assertions checks.
* The interval must be greater than zero and lower than timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostOneSecond()
* .withCheckInterval(500, TimeUnit.MILLISECONDS)
* .untilAssertions(async -> {
* async.assertThat(condition).isTrue();
* });
* }</pre>
*
* @param checkInterval check interval
* @param timeUnit the time unit of the check interval
Expand Down
81 changes: 44 additions & 37 deletions src/main/java/com/webfleet/assertj/AsyncAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@


/**
* Entry point for asynchronous assertions.
* Entry point for building asynchronous assertions.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AsyncAssertions
{
/**
* Returns evaluator of asynchronous assertions with given timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with given timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMost(Duration.ofSeconds(5)).untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @param timeout timeout for the assertions
* @return {@link AsyncAssert}
Expand All @@ -33,16 +34,17 @@ public static AsyncAssert awaitAtMost(@NonNull final Duration timeout)
}

/**
* Returns evaluator of asynchronous assertions with given timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with given timeout value and time unit.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMost(5, SECONDS).untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @param timeout timeout value for the assertions
* @param timeout timeout value for the assertion
* @param timeUnit timeout unit
* @return {@link AsyncAssert}
*/
Expand All @@ -52,14 +54,15 @@ public static AsyncAssert awaitAtMost(final long timeout, @NonNull final TimeUni
}

/**
* Returns evaluator of asynchronous assertions with 1 second timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with 1 second timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostOneSecond().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @return {@link AsyncAssert}
*/
Expand All @@ -69,14 +72,15 @@ public static AsyncAssert awaitAtMostOneSecond()
}

/**
* Returns evaluator of asynchronous assertions with 2 seconds timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with 2 seconds timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostTwoSeconds().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @return {@link AsyncAssert}
*/
Expand All @@ -86,14 +90,15 @@ public static AsyncAssert awaitAtMostTwoSeconds()
}

/**
* Returns evaluator of asynchronous assertions with 5 seconds timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with 5 seconds timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostFiveSeconds().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @return {@link AsyncAssert}
*/
Expand All @@ -103,14 +108,15 @@ public static AsyncAssert awaitAtMostFiveSeconds()
}

/**
* Returns evaluator of asynchronous assertions with 15 seconds timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with 15 seconds timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostFifteenSeconds().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @return {@link AsyncAssert}
*/
Expand All @@ -120,14 +126,15 @@ public static AsyncAssert awaitAtMostFifteenSeconds()
}

/**
* Returns evaluator of asynchronous assertions with 30 seconds timeout.
* See {@link AsyncAssert} for more details.
*
* <pre><code class='java'>
* Builds asynchronous assertion with 30 seconds timeout.
* <p>
* Example usage:
* <pre>{@code
* awaitAtMostThirtySeconds().untilAssertions(async -> {
* async.assertThat(getValue()).isEqualTo(expected);
* });
* </code></pre>
* }</pre>
* See {@link AsyncAssert} for more details.
*
* @return {@link AsyncAssert}
*/
Expand Down

0 comments on commit 35d9109

Please sign in to comment.