common/src/test/java/org/flowant/website/repository/ReputationRepositoryTest.java
@SuppressWarnings("unused")
    private void popularChildren(int cntPopular, int cntTotal, Function<IdCid, T> supplier, Class<?> reputationCls) {

        UUID containerId = IdMaker.randomUUID();

        Flux<T> reputations = Flux.range(1, cntTotal).map(i -> supplier.apply(IdCid.random(containerId))).cache();
        reputations.flatMap(r -> repo.save(r)).blockLast();
        cleaner.registerToBeDeleted(reputations);

        Collection<ReputationCounter> popular = RelationshipService.findPopularSubItems(cntPopular, containerId, reputationCls).block();

        List<T> expected = reputations.collectSortedList(Collections.reverseOrder(ReputationCounter::compare)).block();
        for (int i = 0; i < cntPopular; i++) {
            assertTrue(popular.contains(expected.get(i)));
        }

    }
// Do not use this function in test case, It's a heavy IO bound function.
Do not use this function in test case, It's a heavy IO bound function.
Do not use this function in test case It ' s a heavy IO bound function .
@SuppressWarnings("unused")
    private void popularChildren(int cntPopular, int cntTotal, Function<IdCid, T> supplier, Class<?> reputationCls) {
        UUID containerId = IdMaker.randomUUID();
        Flux<T> reputations = Flux.range(1, cntTotal).map(i -> supplier.apply(IdCid.random(containerId))).cache();
        reputations.flatMap(r -> repo.save(r)).blockLast();
        cleaner.registerToBeDeleted(reputations);
        Collection<ReputationCounter> popular = RelationshipService.findPopularSubItems(cntPopular, containerId, reputationCls).block();
        List<T> expected = reputations.collectSortedList(Collections.reverseOrder(ReputationCounter::compare)).block();
        for (int i = 0; i < cntPopular; i++) {
            assertTrue(popular.contains(expected.get(i)));
        }
    }
@ SuppressWarnings ( "unused" ) private void popularChildren ( int cntPopular , int cntTotal , Function < IdCid , T > supplier , Class < ? > reputationCls ) { UUID containerId = IdMaker . randomUUID ( ) ; Flux < T > reputations = Flux . range ( 1 , cntTotal ) . map ( i -> supplier . apply ( IdCid . random ( containerId ) ) ) . cache ( ) ; reputations . flatMap ( r -> repo . save ( r ) ) . blockLast ( ) ; cleaner . registerToBeDeleted ( reputations ) ; Collection < ReputationCounter > popular = RelationshipService . findPopularSubItems ( cntPopular , containerId , reputationCls ) . block ( ) ; List < T > expected = reputations . collectSortedList ( Collections . reverseOrder ( ReputationCounter :: compare ) ) . block ( ) ; for ( int i = 0 ; i < cntPopular ; i ++ ) { assertTrue ( popular . contains ( expected . get ( i ) ) ) ; } }
Do not use this function in test case, It's a heavy IO bound function.
Do not use this function in test case It ' s a heavy IO bound function .