package Flux_sample_operators;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest;
import reactor.core.publisher.Flux;

public class FluxEmptyJustError {

    @Test
    public void FluxEmptyAndNever(){
        //empty()
        Flux.empty().
                doOnEach(sample-> System.out.println(sample.getType())).
                defaultIfEmpty("This is Empty default message").
                doOnNext(System.out::println).log().subscribe();

        //never()
        Flux.never().
                doOnEach(sample-> System.out.println(sample.getType())).
                defaultIfEmpty("This is Never default message").
                doOnNext(System.out::println).log().subscribe();
    }

    @Test
    public void FluxJustCategory(){
        //just()
        Flux.just("This","is","John","Smith").
                log().subscribe(System.out::println);
    }

    @Test
    public void FluxError(){
        //error()
        Flux.just("This","is","John","Smith",null).doOnError(throwable -> {
                    System.out.println("This is throwable error"+throwable);
                }).log().subscribe(System.out::println);

        //factory error()
        //Flux.error(new Exception("This is direct Exception")).
                //log().subscribe(System.out::println);
    }
}