mardi 16 juin 2020

How to test reactor chain

I have the following class:

public class Library {

    private BookRepo repo;

    public Library(BookRepo repo) {
        repo = repo; 
    }

    public Mono<Void> deleteBook(String title) {
        return repo.deleteBookSubscriptions(title).then(repo.deleteBook(title));
    }

    class BookRepo {
        public Mono<Void> deleteBookSubscriptions(String title) {
            return Mono.empty();
        }

        public Mono<Void> deleteBook(String title) {
            return Mono.empty();
        }
    }

    class Book {}
}

and I want to test the method Library#deleteBook, that two methods executed in the same pipeline, but not in the different ones. With another words they should be executed like this:

public Mono<Void> deleteBook(String title) {
    return repo.deleteBookSubscriptions(title).then(repo.deleteBook(title));
}

But not like this:

public Mono<Void> deleteBook(String title) {
    repo.deleteBookSubscriptions(title);
    return repo.deleteBook(title);
}

Aucun commentaire:

Enregistrer un commentaire