Class MCAssertions


  • public class MCAssertions
    extends java.lang.Object
    MCAssertions is a collection of utility methods that support asserting conditions in MontiCore tests. Unless otherwise noted, a failed assertion will throw an AssertionFailedError or a subclass thereof.
    • Constructor Summary

      Constructors 
      Constructor Description
      MCAssertions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static de.se_rwth.commons.logging.Finding assertHasFinding()
      Asserts that at least one Finding is present and removes that Finding from the Log.
      static de.se_rwth.commons.logging.Finding assertHasFinding​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
      Asserts that at least one Finding matches the predicate and removes that Finding from the Log.
      static de.se_rwth.commons.logging.Finding assertHasFinding​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)
      Asserts that at least one Finding matches the predicate and removes that Finding from the Log.
      static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
      Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log
      static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)
      Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log
      static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith​(java.lang.String expectedPrefix)
      Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log
      static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith​(java.lang.String expectedPrefix, java.lang.String message)
      Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log
      static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith​(java.lang.String expectedPrefix)
      Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log
      static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith​(java.lang.String expectedPrefix, java.lang.String message)
      Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log
      static void assertNoFindings()
      Asserts that no findings are present.
      static void assertNoFindings​(java.lang.String message)
      Asserts that no findings are present.
      static <V> V failAndPrintFindings()
      Fails a test.
      static <V> V failAndPrintFindings​(java.lang.String message)
      Fails a test with the given failure message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MCAssertions

        public MCAssertions()
    • Method Detail

      • assertHasFindingStartingWith

        public static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith​(java.lang.String expectedPrefix,
                                                                                      java.lang.String message)
        Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log
        Parameters:
        expectedPrefix - the expected prefix
        message - the message to fail with iff no finding was found
        Returns:
        returns the found Finding
        See Also:
        assertHasFinding(Predicate, String)
      • assertHasFindingStartingWith

        public static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith​(java.lang.String expectedPrefix)
        Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log
        Parameters:
        expectedPrefix - the expected prefix
        Returns:
        returns the found Finding
        See Also:
        assertHasFinding(Predicate)
      • assertHasFindingsStartingWith

        public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith​(java.lang.String expectedPrefix,
                                                                                                             java.lang.String message)
        Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log
        Parameters:
        expectedPrefix - the expected prefix
        message - the message to fail with iff no findings were found
        Returns:
        returns the list of found Findings
        See Also:
        assertHasFindings(Predicate, String)
      • assertHasFindingsStartingWith

        public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith​(java.lang.String expectedPrefix)
        Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log
        Parameters:
        expectedPrefix - the expected prefix
        Returns:
        returns the list of found Findings
        See Also:
        assertHasFinding(Predicate)
      • assertHasFinding

        public static de.se_rwth.commons.logging.Finding assertHasFinding​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate,
                                                                          java.lang.String message)
        Asserts that at least one Finding matches the predicate and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed.
        Parameters:
        predicate - the predicate
        message - the message to fail with iff no finding was found
        Returns:
        returns the found Finding
      • assertHasFinding

        public static de.se_rwth.commons.logging.Finding assertHasFinding​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
        Asserts that at least one Finding matches the predicate and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed.
        Parameters:
        predicate - the predicate
        Returns:
        returns the found Finding
      • assertHasFinding

        public static de.se_rwth.commons.logging.Finding assertHasFinding()
        Asserts that at least one Finding is present and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed. This method should NOT be used in conjunction with CoCo-Tests.
        Returns:
        returns the found Finding
      • assertHasFindings

        public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate,
                                                                                                 java.lang.String message)
        Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log
        Parameters:
        predicate - the predicate
        message - the message to fail with iff no findings were found
        Returns:
        returns the list of found Findings
      • assertHasFindings

        public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings​(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
        Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log
        Parameters:
        predicate - the predicate
        Returns:
        returns the list of found Findings
      • assertNoFindings

        public static void assertNoFindings​(java.lang.String message)
        Asserts that no findings are present.
        Parameters:
        message - the message to fail with iff findings were found
      • assertNoFindings

        public static void assertNoFindings()
        Asserts that no findings are present.
      • failAndPrintFindings

        public static <V> V failAndPrintFindings()
        Fails a test. Additionally, Lists the state of Log-Findings. See Javadoc for Assertions.fail(String, Throwable) for an explanation of this method's generic return type V.
        Returns:
        nothing
      • failAndPrintFindings

        public static <V> V failAndPrintFindings​(java.lang.String message)
        Fails a test with the given failure message. Additionally, Lists the state of Log-Findings. See Javadoc for Assertions.fail(String, Throwable) for an explanation of this method's generic return type V.
        Parameters:
        message - message to print
        Returns:
        nothing