'Validating interim calls formed in Mono

I have a class that returns a Mono type collection, something like this and I want to add a test that verifies the interim calls that mono goes through in chain: My method to test is in Test class

@Override
    public @NonNull Mono<Collection<Group>> getGroupsAsync(@NonNull String groupName,
                                                                        @NonNull String name) throws MyException {
        try {
            return inner.networkGroups().getByGroupAsync(groupName, name)
                    .filter(skipNullNsg(name, groupName))
                    .flatMap(nsg -> Mono.just(n.groups().values()));
        } catch (Exception ex) {
            throw MyException(ex);
                    
        }
    }

My test is:

@Test
    public void getGroups() throws MyException {
        
        assertNotNull(inner.networkGroups().getByGroupAsync(groupName, name).block());
       }

My question is how can I use the chain of mono to check the interim states as this is an async call.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source