Class MultisetAssert<T>

    • Constructor Detail

      • MultisetAssert

        protected MultisetAssert​(com.google.common.collect.Multiset<? extends T> actual)
    • Method Detail

      • contains

        public MultisetAssert<T> contains​(int expectedCount,
                                          T expected)
        Verifies the actual Multiset contains the given value exactly the given number of times.

        Example :

         Multiset<String> actual = HashMultiset.create();
         actual.add("shoes", 2);
        
         // assertion succeeds
         assertThat(actual).contains(2, "shoes");
        
         // assertions fail
         assertThat(actual).contains(1, "shoes");
         assertThat(actual).contains(3, "shoes");
        Parameters:
        expectedCount - the exact number of times the given value should appear in the set
        expected - the value which to expect
        Returns:
        this MultisetAssert for fluent chaining
        Throws:
        java.lang.AssertionError - if the actual Multiset is null
        java.lang.AssertionError - if the actual Multiset contains the given value a number of times different to the given count
      • containsAtLeast

        public MultisetAssert<T> containsAtLeast​(int minimumCount,
                                                 T expected)
        Verifies the actual Multiset contains the given value at least the given number of times.

        Example :

         Multiset<String> actual = HashMultiset.create();
         actual.add("shoes", 2);
        
         // assertions succeed
         assertThat(actual).containsAtLeast(1, "shoes");
         assertThat(actual).containsAtLeast(2, "shoes");
        
         // assertion fails
         assertThat(actual).containsAtLeast(3, "shoes");
        Parameters:
        minimumCount - the minimum number of times the given value should appear in the set
        expected - the value which to expect
        Returns:
        this MultisetAssert for fluent chaining
        Throws:
        java.lang.AssertionError - if the actual Multiset is null
        java.lang.AssertionError - if the actual Multiset contains the given value fewer times than the given count
      • containsAtMost

        public MultisetAssert<T> containsAtMost​(int maximumCount,
                                                T expected)
        Verifies the actual Multiset contains the given value at most the given number of times.

        Example :

         Multiset<String> actual = HashMultiset.create();
         actual.add("shoes", 2);
        
         // assertions succeed
         assertThat(actual).containsAtMost(3, "shoes");
         assertThat(actual).containsAtMost(2, "shoes");
        
         // assertion fails
         assertThat(actual).containsAtMost(1, "shoes");
        Parameters:
        maximumCount - the maximum number of times the given value should appear in the set
        expected - the value which to expect
        Returns:
        this MultisetAssert for fluent chaining
        Throws:
        java.lang.AssertionError - if the actual Multiset is null
        java.lang.AssertionError - if the actual Multiset contains the given value more times than the given count
      • newAbstractIterableAssert

        protected MultisetAssert<T> newAbstractIterableAssert​(java.lang.Iterable<? extends T> iterable)
        Description copied from class: AbstractIterableAssert
        This methods is needed to build a new concrete instance of AbstractIterableAssert after a filtering operation is executed.

        If you create your own subclass of AbstractIterableAssert, simply returns an instance of it in this method.

        Specified by:
        newAbstractIterableAssert in class AbstractIterableAssert<MultisetAssert<T>,​com.google.common.collect.Multiset<? extends T>,​T,​ObjectAssert<T>>
        Parameters:
        iterable - the iterable used to build the concrete instance of AbstractIterableAssert
        Returns:
        concrete instance of AbstractIterableAssert