Class ActionSequence


  • public final class ActionSequence
    extends Object
    Simple data holder for sequence of actions identified with String.

    Always call reset() before your test code to remove previous sequences stored in static map!

    Author:
    Martin Kouba
    • Constructor Detail

      • ActionSequence

        public ActionSequence()
      • ActionSequence

        public ActionSequence​(String name)
        Parameters:
        name -
    • Method Detail

      • getData

        public List<String> getData()
        Returns:
        read-only copy of sequence data
      • getName

        public String getName()
        Returns:
        name of sequence
      • containsAll

        public boolean containsAll​(String... actions)
        Parameters:
        actions -
        Returns:
        true if sequence data contain all of the specified actions, false otherwise
      • beginsWith

        public boolean beginsWith​(String... actions)
        Parameters:
        actions -
        Returns:
        true if sequence data begins with the specified actions, false otherwise
      • endsWith

        public boolean endsWith​(String... actions)
        Parameters:
        actions -
        Returns:
        true if sequence data ends with the specified actions, false otherwise
      • dataToCsv

        public String dataToCsv()
        Returns:
        data in simple CSV format
      • assertDataEquals

        public void assertDataEquals​(List<String> expected)
        Assert that strings stored in this sequence equal (in order!) to the expected strings.
        Parameters:
        expected -
      • assertDataEquals

        public void assertDataEquals​(String... expected)
        Assert that strings stored in this sequence equal (in order!) to the expected strings.
        Parameters:
        expected -
      • assertDataEquals

        public void assertDataEquals​(Class<?>... expected)
        Assert that strings stored in this sequence equal (in order!) to the simple class names of the expected classes.
        Parameters:
        expected -
      • assertDataContainsAll

        public void assertDataContainsAll​(Collection<String> expected)
        Assert that this sequence contains all of the expected strings. Note that this only verifies that the expected strings are a SUBSET of the actual strings stored in this sequence.
        Parameters:
        expected -
      • assertDataContainsAll

        public void assertDataContainsAll​(String... expected)
        Assert that this sequence contains all of the expected strings. Note that this only verifies that the expected strings are a SUBSET of the actual strings stored in this sequence.
        Parameters:
        expected -
      • assertDataContainsAll

        public void assertDataContainsAll​(Class<?>... expected)
        Assert that this sequence contains simple class names of all of the expected classes. Note that this only verifies that the expected classes are a SUBSET of the actual classes stored in this sequence.
        Parameters:
        expected -
      • reset

        public static void reset()
        Remove all sequences.
      • addAction

        public static boolean addAction​(String sequenceName,
                                        String actionId)
        Add actionId to specified sequence. Add new sequence if needed.
        Parameters:
        sequence -
        actionId -
        Returns:
        true if a new sequence was added, false otherwise
      • addAction

        public static boolean addAction​(String actionId)
        Add actionId to default sequence.
        Parameters:
        actionId -
        Returns:
        true if a new sequence was added, false otherwise
      • getSequence

        public static ActionSequence getSequence()
        Returns:
        default sequence or null if no such sequence exists
      • getSequence

        public static ActionSequence getSequence​(String sequenceName)
        Parameters:
        name -
        Returns:
        specified sequence or null if no such sequence exists
      • getSequenceData

        public static List<String> getSequenceData()
        Returns:
        data of default sequence or null if no such sequence exists
      • getSequenceData

        public static List<String> getSequenceData​(String sequenceName)
        Parameters:
        sequenceName -
        Returns:
        data of specified sequence or null if no such sequence exists
      • getSequenceSize

        public static int getSequenceSize()
        Returns:
        size of default sequence
      • getSequenceSize

        public static int getSequenceSize​(String sequenceName)
        Parameters:
        sequence -
        Returns:
        size of specified sequence
      • buildFromCsvData

        public static ActionSequence buildFromCsvData​(String csv)
        Parameters:
        csv -
        Returns:
      • assertSequenceDataEquals

        public static void assertSequenceDataEquals​(List<String> expected)
        Assert that strings stored in this sequence equal (in order!) to the expected strings.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence
      • assertSequenceDataEquals

        public static void assertSequenceDataEquals​(String... expected)
        Assert that strings stored in this sequence equal (in order!) to the expected strings.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence
      • assertSequenceDataEquals

        public static void assertSequenceDataEquals​(Class<?>... expected)
        Assert that strings stored in the default sequence equal (in order!) to the simple class names of expected.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence
      • assertSequenceDataContainsAll

        public static void assertSequenceDataContainsAll​(Collection<String> expected)
        Assert that this sequence contains all of the expected strings. Note that this only verifies that the expected strings are a SUBSET of the actual strings stored in this sequence.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence
      • assertSequenceDataContainsAll

        public static void assertSequenceDataContainsAll​(String... expected)
        Assert that this sequence contains all of the expected strings. Note that this only verifies that the expected strings are a SUBSET of the actual strings stored in this sequence.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence
      • assertSequenceDataContainsAll

        public static void assertSequenceDataContainsAll​(Class<?>... expected)
        Assert that the default sequence contains simple class names of all of the expected classes. Note that this only verifies that the expected classes are a SUBSET of the actual classes stored in this sequence.
        Parameters:
        expected -
        Throws:
        IllegalStateException - if there is no default sequence