Interface MockUnitString

    • Method Detail

      • accumulate

        default MockUnitString accumulate​(int times,
                                          java.lang.String separator)

        Joins intermediary results by calling val() a number of times using the given separator

        Parameters:
        times - The number of times the value is joined
        separator - The string used as a separator
        Returns:
        A new MockUnitstring.
      • format

        default MockUnitString format​(StringFormatType formatType)

        Formats the results obtained from the MockUnit<String> and creates a new MockUnitString that generates formatted results.

        Currently there are 3 supported formatting types:
        • StringFormatType.UPPER_CASE
        • StringFormatType.LOWER_CASE
        • StringFormatType.CAPITALIZED
        Parameters:
        formatType - The format type that will be applied to the generated value.
        Returns:
        A new MockUnitString
      • sub

        default MockUnitString sub​(int endIndex)

        Creates a new MockUnitString by applying String.substring(0, endIndex) on the generated values.

        Note: If the initial generated value is null the resulting value is also null.

        Note: The developer is responsible to supply correct indexes for the substring operation.

        Parameters:
        endIndex - The end index.
        Returns:
        A new MockUnitString
      • sub

        default MockUnitString sub​(int beginIndex,
                                   int endIndex)

        Creates a new MockUnitString by applying String.substring(beginIndex, endIndex) on the generated values.

        Note: If the initial generated value is null the resulting value is also null.

        Note: The developer is responsible to supply correct indexes for the substring operation.

        Parameters:
        beginIndex - The begin index.
        endIndex - The end index.
        Returns:
        A new MockUnitString
      • append

        default MockUnitString append​(java.lang.String str)

        Creates a new MockUnitString

        by appending a new String on the generated value.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        str - The String to append.
        Returns:
        A new MockUnitString
      • prepend

        default MockUnitString prepend​(java.lang.String str)

        Creates a new MockUnitString by prepending a new String on the generated value.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        str - The String to prepend.
        Returns:
        A new MockUnitString
      • replace

        default MockUnitString replace​(char oldCHar,
                                       char newChar)

        Creates a new MockUnitString by replacing all the occurrences of oldChar with newChar

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        oldCHar - The char to be replaced.
        newChar - The new char replacing oldChar.
        Returns:
        A new MockUnitString
      • replace

        default MockUnitString replace​(java.lang.CharSequence target,
                                       java.lang.CharSequence replacement)

        Creates a new MockUnitString by replacing all occurrences of target with replacement.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        target - The substring to be replaced.
        replacement - The substring that replaces target.
        Returns:
        A new MockUnitString
      • replaceAll

        default MockUnitString replaceAll​(java.lang.String regex,
                                          java.lang.String replacement)

        Creates a new MockUnitString by replacing all occurrences that match regex with replacement.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        regex - The regular expression to be replaced.
        replacement - The replacement for the characters matching regex.
        Returns:
        A new MockUnitString
      • replaceFirst

        default MockUnitString replaceFirst​(java.lang.String regex,
                                            java.lang.String replacement)

        Creates a new MockUnitString by replacing the first occurrence that match regex with replacement.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        regex - The regular expression to be replaced.
        replacement - The replacement for the characters matching regex.
        Returns:
        A new MockUnitString
      • split

        default MockUnit<java.lang.String[]> split​(java.lang.String regex,
                                                   int limit)

        Creates a new MockUnit<String[]> by splitting the generated value.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        regex - The seperator regex (where the splittings are performed).
        limit - Limits the number of split operations.
        Returns:
        A new MockUnit<String>
      • split

        default MockUnit<java.lang.String[]> split​(java.lang.String regex)

        Creates a new MockUnit<String[]> by splitting the generated value.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        regex - The seperator regex (where the splittings are performed).
        Returns:
        A new MockUnit<String>
      • urlEncode

        default MockUnitString urlEncode​(java.lang.String encoding)

        Creates a new MockUnitString by applying an URL Encode on the result.

        Note: If the initial generated value is null the resulting value is also null.

        Parameters:
        encoding - Type of encoding.
        Returns:
        A new MockUnitString
      • urlEncode

        default MockUnitString urlEncode()

        Creates a new MockUnitString by applying an URL Encode on the result.

        Note: If the initial generated value is null the resulting value is also null.

        Returns:
        A new MockUnitString
      • noSpecialChars

        default MockUnitString noSpecialChars()

        Creates a new MockUnitString by stripping the result from special characters. Everything that is not " ", number or letter will be removed from the resulting string.

        Note: If the initial generated value is null the resulting value is also null.

        Returns:
        A new MockUnitString
      • escapeCsv

        default MockUnitString escapeCsv()

        Creates a new MockUnitString by CSV-escaping the generated value.

        Returns:
        A new MockUnitString
      • escapeEcmaScript

        default MockUnitString escapeEcmaScript()

        Creates a new MockUnitString by ECMA-escaping the generated value.

        Returns:
        A new MockUnitString
      • escapeHtml

        default MockUnitString escapeHtml()

        Creates a new MockUnitString by HTML-escaping the generated value.

        Returns:
        A new MockUnitString
      • escapeXml

        default MockUnitString escapeXml()

        Creates a new MockUnitString by XML-escaping the generated value.

        Returns:
        A new MockUnitString
      • array

        default MockUnit<java.lang.String[]> array​(int size)

        Transforms an existing MockUnitString into a MockUnit<String[]>.

        The array will contains values generated through the MockUnitString.

        Parameters:
        size - The size of the array.
        Returns:
        A new MockUnit<String[]>