schananas / practical-reactor

Practical Project Reactor and reactive programing workshop
MIT License
387 stars 755 forks source link

c3_Filtering_sequence - golden_middle test and solution is wrong #24

Open martincnz opened 1 year ago

martincnz commented 1 year ago

In the solution:

 /**
     * `number_service()` returns 300 numbers, but you only need 100 numbers, from the middle.
     */
    @Test
    public void golden_middle() {
        Flux<Integer> numbers = number_service()
                .skip(100) //this should be .skip(150) as 300/2 = 150
                .take(100)
                ;

        StepVerifier.create(numbers)
                    .expectNextMatches(i -> i >= 100) // this should be expectNextMatches(i -> i >= 100), as the middle number is 150
                    .expectNextCount(99)
                    .verifyComplete();
    }
marcelruland commented 6 months ago

Test and solution are correct, but the phrasing could have been clearer. The task is to take 100 numbers such that the middle of the taken interval is the middle of the entire 300 numbers. I.e. take numbers 101 to 200.