@@ -4,7 +4,10 @@
Loading
4 4
 */
5 5
package org.mockito;
6 6
7 +
import org.mockito.internal.stubbing.OngoingStubbingImpl;
8 +
import org.mockito.quality.Strictness;
7 9
import org.mockito.stubbing.Answer;
10 +
import org.mockito.stubbing.LenientStubber;
8 11
import org.mockito.stubbing.OngoingStubbing;
9 12
import org.mockito.stubbing.Stubber;
10 13
import org.mockito.verification.VerificationMode;
@@ -344,7 +347,7 @@
Loading
344 347
     * See original {@link Stubber}
345 348
     * @since 1.8.0
346 349
     */
347 -
    public interface BDDStubber {
350 +
    public interface BaseBDDStubber {
348 351
        /**
349 352
         * See original {@link Stubber#doAnswer(Answer)}
350 353
         * @since 1.8.0
@@ -413,7 +416,13 @@
Loading
413 416
         * @since 1.9.0
414 417
         */
415 418
        BDDStubber willCallRealMethod();
419 +
    }
416 420
421 +
    /**
422 +
     * see original {@link Stubber}
423 +
     * @since 1.8.0
424 +
     */
425 +
    public interface BDDStubber extends BaseBDDStubber {
417 426
        /**
418 427
         * See original {@link Stubber#when(Object)}
419 428
         * @since 1.8.0
@@ -481,6 +490,121 @@
Loading
481 490
        }
482 491
    }
483 492
493 +
    /**
494 +
     * see original {@link org.mockito.stubbing.LenientStubber}
495 +
     *
496 +
     * @since 1.8.0
497 +
     */
498 +
    public interface BDDLenientStubber extends BaseBDDStubber {
499 +
500 +
        /**
501 +
         * see original {@link org.mockito.stubbing.LenientStubber#when(Object)}
502 +
         *
503 +
         * @since 3.5.11
504 +
         */
505 +
        <T> BDDMyOngoingStubbing<T> given(T mock);
506 +
    }
507 +
508 +
    private static class BDDLenientStubberImpl implements BDDLenientStubber {
509 +
510 +
        private LenientStubber mockitoStubber;
511 +
512 +
        public BDDLenientStubberImpl(LenientStubber stubber) {
513 +
            this.mockitoStubber = stubber;
514 +
        }
515 +
516 +
        /**
517 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doAnswer(Answer)}
518 +
         * @since 3.5.11
519 +
         */
520 +
        public BDDStubber willAnswer(Answer<?> answer) {
521 +
            return new BDDStubberImpl(mockitoStubber.doAnswer(answer));
522 +
        }
523 +
524 +
        /**
525 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doAnswer(Answer)}
526 +
         * @since 3.5.11
527 +
         */
528 +
        public BDDStubber will(Answer<?> answer) {
529 +
            return new BDDStubberImpl(mockitoStubber.doAnswer(answer));
530 +
        }
531 +
532 +
        /**
533 +
         * @deprecated please use {@link #willDoNothing()} instead
534 +
         */
535 +
        @Deprecated
536 +
        public BDDStubber willNothing() {
537 +
            return willDoNothing();
538 +
        }
539 +
540 +
        /**
541 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doNothing()}
542 +
         * @since 3.5.11
543 +
         */
544 +
        public BDDStubber willDoNothing() {
545 +
            return new BDDStubberImpl(mockitoStubber.doNothing());
546 +
        }
547 +
548 +
        /**
549 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doAnswer(Answer)}
550 +
         * @since 3.5.11
551 +
         */
552 +
        public BDDStubber willReturn(Object toBeReturned) {
553 +
            return new BDDStubberImpl(mockitoStubber.doReturn(toBeReturned));
554 +
        }
555 +
556 +
        /**
557 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doReturn(Object, Object...)}
558 +
         * @since 3.5.11
559 +
         */
560 +
        public BDDStubber willReturn(Object toBeReturned, Object... nextToBeReturned) {
561 +
            return new BDDStubberImpl(mockitoStubber.doReturn(toBeReturned, nextToBeReturned));
562 +
        }
563 +
564 +
        /**
565 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doThrow(Throwable...)}
566 +
         * @since 3.5.11
567 +
         */
568 +
        public BDDStubber willThrow(Throwable... toBeThrown) {
569 +
            return new BDDStubberImpl(mockitoStubber.doThrow(toBeThrown));
570 +
        }
571 +
572 +
        /**
573 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doThrow(Class)}
574 +
         * @since 3.5.11
575 +
         */
576 +
        public BDDStubber willThrow(Class<? extends Throwable> toBeThrown) {
577 +
            return new BDDStubberImpl(mockitoStubber.doThrow(toBeThrown));
578 +
        }
579 +
580 +
        /**
581 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doThrow(Class, Class[])}
582 +
         * @since 3.5.11
583 +
         */
584 +
        public BDDStubber willThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>... nextToBeThrown) {
585 +
            return new BDDStubberImpl(mockitoStubber.doThrow(toBeThrown, nextToBeThrown));
586 +
        }
587 +
588 +
        /**
589 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#doCallRealMethod()}
590 +
         * @since 3.5.11
591 +
         */
592 +
        public BDDStubber willCallRealMethod() {
593 +
            return new BDDStubberImpl(mockitoStubber.doCallRealMethod());
594 +
        }
595 +
596 +
        /**
597 +
         * see original {@link org.mockito.internal.stubbing.DefaultLenientStubber#when(Object)}
598 +
         * @since 3.5.11
599 +
         */
600 +
        @Override
601 +
        public <T> BDDMyOngoingStubbing<T> given(T mock) {
602 +
            OngoingStubbingImpl<T> ongoingStubbing = (OngoingStubbingImpl) Mockito.when(mock);
603 +
            ongoingStubbing.setStrictness(Strictness.LENIENT);
604 +
            return new BDDOngoingStubbingImpl<T>(ongoingStubbing);
605 +
        }
606 +
    }
607 +
484 608
    /**
485 609
     * see original {@link Mockito#doThrow(Throwable[])}
486 610
     * @since 2.1.0
@@ -554,4 +678,12 @@
Loading
554 678
    public static BDDStubber willCallRealMethod() {
555 679
        return new BDDStubberImpl(Mockito.doCallRealMethod());
556 680
    }
681 +
682 +
    /**
683 +
     * see original {@link Mockito#lenient()}
684 +
     * @since 3.5.11
685 +
     */
686 +
    public static BDDLenientStubber lenientBDD() {
687 +
        return new BDDLenientStubberImpl(Mockito.lenient());
688 +
    }
557 689
}
Files Complexity Coverage
src/main/java/org/mockito 85.60% 84.89%
subprojects 79.06% 85.34%
Project Totals (325 files) 85.52% 84.90%
4790.1
TRAVIS_OS_NAME=linux
openjdk8=
4790.2
TRAVIS_OS_NAME=linux
openjdk8=
4790.3
openjdk11=
TRAVIS_OS_NAME=linux
4790.5
TRAVIS_OS_NAME=linux
openjdk14=
4790.6
TRAVIS_OS_NAME=linux
openjdk14=
4790.4
openjdk11=
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading