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

se.fortnox.reactivewizard.test.publisher.PublisherAssertions Maven / Gradle / Ivy

There is a newer version: 24.6.0
Show newest version
package se.fortnox.reactivewizard.test.publisher;

import org.reactivestreams.Publisher;

/**
 * Entry point for assertion methods to make it more convenient to user AssertJ assertions with Publisher.
 * Each method in this class is a static factory for assertion objects.
 * 

* Examples: *


 * Flux<List<Long>< flux = Flux.just(List.of(1L, 2L));
 * FluxAssertions.assertThat(flux)
 *    .singleElement()
 *    .satisfies(listOfLongs ->
 *       Assertions.assertThat(listOfLongs)
 *          .contains(1l, 2L)
 *    );
 * 
* *

 * Flux<String< flux = Flux.just("one");
 * PublisherAssertions.assertThat(flux)
 *   .containsExactly("one");
 * 
* *

 * Flux<String< flux = Flux.just("one", "two");
 * FluxAssertions.assertThat(flux)
 *   .containsExactly("one","two");
 * 
*/ public class PublisherAssertions { private PublisherAssertions() { } /** * Creates a new instance of {@link PublisherAssert}. * * @param the type of elements emitted by the Publisher. * @param actual the Publisher under test. * @return the created assertion object. */ public static PublisherAssert assertThat(Publisher actual) { return new PublisherAssert<>(actual); } /** * Entry point to check that one onError signal with an exception of type T was received by a given Publisher, * which allows to chain assertions on the thrown exception. *

* Example: *

 assertThatExceptionOfType(IOException.class)
     *           .isThrownBy(publisher)
     *           .withMessage("boom!"); 
* * @param the exception type. * @param exceptionType the exception type class. * @return the created {@link PublisherThrowableAssert}. */ public static PublisherThrowableAssert assertThatExceptionOfType(final Class exceptionType) { return new PublisherThrowableAssert<>(exceptionType); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy