Packages

case class RegexWhen[R](parent: ExpectBlock[R], pattern: Regex, readFrom: FromInputStream = StdOut) extends When[R] with Product with Serializable

Source
Whens.scala
Linear Supertypes
Serializable, Serializable, Product, Equals, When[R], Whenable[R], Expectable[R], AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RegexWhen
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. When
  7. Whenable
  8. Expectable
  9. AnyRef
  10. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new RegexWhen(parent: ExpectBlock[R], pattern: Regex, readFrom: FromInputStream = StdOut)

Type Members

  1. type CW[+X] = core.RegexWhen[X]

    The concrete core.When type constructor which this fluent.When is a builder for.

    The concrete core.When type constructor which this fluent.When is a builder for.

    Definition Classes
    RegexWhenWhen
  2. type This[X] = RegexWhen[X]

    The concrete When type constructor to which the actions will be applied.

    The concrete When type constructor to which the actions will be applied.

    Definition Classes
    RegexWhenWhen

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to any2stringadd[RegexWhen[R]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (RegexWhen[R], B)
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to ArrowAssoc[RegexWhen[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. val actions: Seq[Action[R, CW]]
    Attributes
    protected
    Definition Classes
    When
  7. def addActions(f: (This[R]) ⇒ Unit): This[R]

    Add arbitrary Actions to this When.

    Add arbitrary Actions to this When.

    This is helpful to refactor code. For example: imagine you want to perform the same actions whenever an error occurs. You could leverage this method to do so in the following way:

    def preemtiveExit(when: When[String]): Unit {
      when
        .returning("Got some error")
        .exit()
    }
    
    def parseOutputA: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .action1
        .when(...)
          .addActions(preemtiveExit)
    }
    
    def parseOutputB: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect(...)
        .addActions(preemtiveExit)
    }
    f

    function that adds Actions.

    returns

    this When.

    Definition Classes
    When
  8. def addExpectBlock(f: (Expect[R]) ⇒ Unit): Expect[R]

    Add arbitrary ExpectBlocks to this Expect.

    Add arbitrary ExpectBlocks to this Expect.

    This is helpful to refactor code. For example: imagine you have an error case you want to add to multiple expects. You could leverage this method to do so in the following way:

    def errorCaseExpectBlock(expect: Expect[String]): Unit {
      expect.expect
        .when("Some error")
          .returning("Got some error")
    }
    
    //Then in your expects
    def parseOutputA: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect(...)
      e.expect
        .when(...)
          .action1
        .when(...)
          .action2
      e.addExpectBlock(errorCaseExpectBlock)
    }
    
    def parseOutputB: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .action1
          .action2
        .when(...)
          .action1
      e.expect(...)
        .action2
      e.addExpectBlock(errorCaseExpectBlock)
    }
    f

    function that adds ExpectBlocks.

    returns

    this Expect.

    Definition Classes
    Expectable
  9. def addWhen[W <: When[R]](f: (ExpectBlock[R]) ⇒ W): W

    Add an arbitrary When to this ExpectBlock.

    Add an arbitrary When to this ExpectBlock.

    This is helpful to refactor code. For example: imagine you have an error case you want to add to multiple ExpectBlocks. You could leverage this method to do so in the following way:

    def errorCaseWhen(expectBlock: ExpectBlock[String]): When[String] = {
      expectBlock
        .when("Some error")
          .returning("Got some error")
    }
    
    def parseOutputA: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .sendln(...)
      e.expect
        .addWhen(errorCaseWhen)
          .exit()
    }
    
    def parseOutputB: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .sendln(..)
          .returning(...)
        .addWhen(errorCaseWhen)
    }

    This function returns the added When which allows you to add further actions, see the exit action of the parseOutputA method in the above code.

    It is possible to add more than one When using this method, however this is discouraged since it will make the code somewhat more illegible because "hidden" Whens will also be added.

    If you need to add more than one When you have two options:

    e.expect
      .when(...)
         .sendln(..)
         .returning(...)
      .addWhen(errorCaseWhen)
      .addWhen(anotherWhen)
    e.expect
      .when(...)
         .sendln(..)
         .returning(...)
      .addWhens(multipleWhens)
    f

    function that adds the When.

    returns

    the added When.

    Definition Classes
    Whenable
  10. def addWhens(f: (ExpectBlock[R]) ⇒ Unit): ExpectBlock[R]

    Add arbitrary Whens to this ExpectBlock.

    Add arbitrary Whens to this ExpectBlock.

    This method is very similar to the addWhen with the following differences:

    1. f has a more relaxed type.
    2. It returns this ExpectBlock. Which effectively prohibits you from invoking When methods.
    3. Has a more semantic name when it comes to adding multiple When's.
    f

    function that adds Whens.

    returns

    this ExpectBlock.

    Definition Classes
    Whenable
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def ensuring(cond: (RegexWhen[R]) ⇒ Boolean, msg: ⇒ Any): RegexWhen[R]
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to Ensuring[RegexWhen[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (RegexWhen[R]) ⇒ Boolean): RegexWhen[R]
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to Ensuring[RegexWhen[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: ⇒ Any): RegexWhen[R]
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to Ensuring[RegexWhen[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): RegexWhen[R]
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to Ensuring[RegexWhen[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(other: Any): Boolean
    Definition Classes
    RegexWhen → Equals → AnyRef → Any
  19. def exit(): This[R]

    Terminates the current run of Expect causing it to return the last returned value.

    Terminates the current run of Expect causing it to return the last returned value. Any action or expect block added after this Exit will not be executed.

    returns

    this When.

    Definition Classes
    When
  20. def expect(pattern: Timeout.type): TimeoutWhen[R]

    Adds, in a new ExpectBlock, a TimeoutWhen that matches whenever the read from any of the FromStreamInputs times out.

    Adds, in a new ExpectBlock, a TimeoutWhen that matches whenever the read from any of the FromStreamInputs times out. This is a shortcut to expect.when(pattern).

    pattern

    the pattern to be used in the TimeoutWhen.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  21. def expect(pattern: EndOfFile.type, readFrom: FromInputStream): EndOfFileWhen[R]

    Adds, in a new ExpectBlock, a EndOfFileWhen that matches whenever the end of file is reached while trying to read from the specified FromInputStream.

    Adds, in a new ExpectBlock, a EndOfFileWhen that matches whenever the end of file is reached while trying to read from the specified FromInputStream. This is a shortcut to expect.when(pattern, readFrom).

    pattern

    the pattern to be used in the EndOfFileWhen.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  22. def expect(pattern: EndOfFile.type): EndOfFileWhen[R]

    Adds, in a new ExpectBlock, a EndOfFileWhen that matches whenever the end of file is reached while trying to read from the StdOut output.

    Adds, in a new ExpectBlock, a EndOfFileWhen that matches whenever the end of file is reached while trying to read from the StdOut output. This is a shortcut to expect.when(pattern).

    pattern

    the pattern to be used in the EndOfFileWhen.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  23. def expect(pattern: Regex, readFrom: FromInputStream): RegexWhen[R]

    Adds, in a new ExpectBlock, a RegexWhen that matches whenever the regex pattern successfully matches against the text read from the specified FromInputStream.

    Adds, in a new ExpectBlock, a RegexWhen that matches whenever the regex pattern successfully matches against the text read from the specified FromInputStream. This is a shortcut to expect.when(pattern, readFrom).

    pattern

    the pattern to be used in the RegexWhen.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  24. def expect(pattern: Regex): RegexWhen[R]

    Adds, in a new ExpectBlock, a RegexWhen that matches whenever the regex pattern successfully matches against the text read from the StdOut output.

    Adds, in a new ExpectBlock, a RegexWhen that matches whenever the regex pattern successfully matches against the text read from the StdOut output. This is a shortcut to expect.when(pattern).

    pattern

    the pattern to be used in the RegexWhen.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  25. def expect(pattern: String, readFrom: FromInputStream): StringWhen[R]

    Adds, in a new ExpectBlock, a StringWhen that matches whenever pattern is contained in the text read from the specified FromInputStream.

    Adds, in a new ExpectBlock, a StringWhen that matches whenever pattern is contained in the text read from the specified FromInputStream. This is a shortcut to expect.when(pattern, readFrom).

    pattern

    the pattern to be used in the StringWhen.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new StringWhen.

    Definition Classes
    Expectable
  26. def expect(pattern: String): StringWhen[R]

    Adds, in a new ExpectBlock, a StringWhen that matches whenever pattern is contained in the text read from the StdOut output.

    Adds, in a new ExpectBlock, a StringWhen that matches whenever pattern is contained in the text read from the StdOut output. This is a shortcut to expect.when(pattern).

    pattern

    the pattern to be used in the StringWhen.

    returns

    the new StringWhen.

    Definition Classes
    Expectable
  27. def expect(readFrom: FromInputStream): ExpectBlock[R]

    Adds an empty new ExpectBlock reading from the specified FromInputStream.

    Adds an empty new ExpectBlock reading from the specified FromInputStream.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new ExpectBlock.

    Definition Classes
    Expectable
  28. def expect: ExpectBlock[R]

    Adds an empty new ExpectBlock.

    Adds an empty new ExpectBlock.

    returns

    the new ExpectBlock.

    Definition Classes
    Expectable
  29. lazy val expectableParent: Expect[R]
    Attributes
    protected
    Definition Classes
    WhenableExpectable
  30. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  31. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to StringFormat[RegexWhen[R]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  32. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  33. def hashCode(): Int
    Definition Classes
    RegexWhen → AnyRef → Any
  34. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  35. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. def newAction(action: Action[R, CW]): This[R]
    Attributes
    protected
    Definition Classes
    When
  37. final def notify(): Unit
    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  39. val parent: ExpectBlock[R]
    Definition Classes
    RegexWhenWhen
  40. val pattern: Regex
  41. val readFrom: FromInputStream
    Definition Classes
    RegexWhenWhen
  42. def returning(result: (Match) ⇒ R): RegexWhen[R]

    Returns the result of invoking result with the Match of the regex used, when this Expect is run.

    Returns the result of invoking result with the Match of the regex used, when this Expect is run. If this method is invoked more than once only the last result will be returned. Note however that the previous returning actions will also be executed.

    returns

    this When.

  43. def returning(result: ⇒ R): This[R]

    Returns result when this Expect is run.

    Returns result when this Expect is run. If this method is invoked more than once only the last result will be returned. Note however that the previous returning actions will also be executed.

    returns

    this When.

    Definition Classes
    When
  44. def returningExpect(result: (Match) ⇒ core.Expect[R]): RegexWhen[R]
  45. def returningExpect(result: ⇒ core.Expect[R]): This[R]
    Definition Classes
    When
  46. def send(text: (Match) ⇒ String): RegexWhen[R]

    Send the result of invoking text with the Match of the regex used, to the stdIn of the underlying process.

    Send the result of invoking text with the Match of the regex used, to the stdIn of the underlying process. Send will only occur when Expect is run.

    returns

    this When.

  47. def send(text: String, sensitive: Boolean = false): This[R]

    Send text to the stdIn of the underlying process.

    Send text to the stdIn of the underlying process. Send will only occur when Expect is run.

    returns

    this When.

    Definition Classes
    When
  48. def sendln(text: (Match) ⇒ String): RegexWhen[R]

    Send the result of invoking text with the Match of the regex used with a System.lineSeparator() appended to the end, to the stdIn of the underlying process.

    Send the result of invoking text with the Match of the regex used with a System.lineSeparator() appended to the end, to the stdIn of the underlying process. Send will only occur when Expect is run.

    returns

    this When.

  49. def sendln(text: String, sensitive: Boolean = false): This[R]

    Sends text terminated with System.lineSeparator() to the stdIn of the underlying process.

    Sends text terminated with System.lineSeparator() to the stdIn of the underlying process. Send will only occur when Expect is run.

    returns

    this When.

    Definition Classes
    When
  50. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  51. val thisSubtype: This[R]
    Definition Classes
    When
  52. def toCore: core.RegexWhen[R]

    returns

    the core.When equivalent of this fluent.When.

    Definition Classes
    RegexWhenWhen
  53. def toString(): String
    Definition Classes
    RegexWhen → AnyRef → Any
  54. def toString(pattern: String): String
    Definition Classes
    When
  55. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. def when(pattern: Timeout.type): TimeoutWhen[R]

    Adds a new TimeoutWhen that matches whenever the read from any of the FromStreamInputs times out.

    Adds a new TimeoutWhen that matches whenever the read from any of the FromStreamInputs times out.

    pattern

    the pattern to match against.

    returns

    the new TimeoutWhen.

    Definition Classes
    Whenable
  59. def when(pattern: EndOfFile.type, readFrom: FromInputStream): EndOfFileWhen[R]

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in read from the specified FromInputStream.

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in read from the specified FromInputStream.

    pattern

    the pattern to match against.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new EndOfFileWhen.

    Definition Classes
    Whenable
  60. def when(pattern: EndOfFile.type): EndOfFileWhen[R]

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in read from FromInputStream specified in the parent ExpectBlock.

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in read from FromInputStream specified in the parent ExpectBlock.

    pattern

    the pattern to match against.

    returns

    the new EndOfFileWhen.

    Definition Classes
    Whenable
  61. def when(pattern: Regex, readFrom: FromInputStream): RegexWhen[R]

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the specified FromInputStream.

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the specified FromInputStream.

    pattern

    the pattern to match against.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new RegexWhen.

    Definition Classes
    Whenable
  62. def when(pattern: Regex): RegexWhen[R]

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from FromInputStream specified in the parent ExpectBlock.

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from FromInputStream specified in the parent ExpectBlock.

    pattern

    the pattern to match against.

    returns

    the new RegexWhen.

    Definition Classes
    Whenable
  63. def when(pattern: String, readFrom: FromInputStream): StringWhen[R]

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the specified FromInputStream.

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the specified FromInputStream.

    pattern

    the pattern to match against.

    readFrom

    from which FromInputStream to read the output.

    returns

    the new StringWhen.

    Definition Classes
    Whenable
  64. def when(pattern: String): StringWhen[R]

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the FromInputStream specified in the parent ExpectBlock.

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the FromInputStream specified in the parent ExpectBlock.

    pattern

    the pattern to match against.

    returns

    the new StringWhen.

    Definition Classes
    Whenable
  65. val whenableParent: ExpectBlock[R]
    Attributes
    protected
    Definition Classes
    WhenWhenable
  66. def [B](y: B): (RegexWhen[R], B)
    Implicit
    This member is added by an implicit conversion from RegexWhen[R] to ArrowAssoc[RegexWhen[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from When[R]

Inherited from Whenable[R]

Inherited from Expectable[R]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from RegexWhen[R] to any2stringadd[RegexWhen[R]]

Inherited by implicit conversion StringFormat from RegexWhen[R] to StringFormat[RegexWhen[R]]

Inherited by implicit conversion Ensuring from RegexWhen[R] to Ensuring[RegexWhen[R]]

Inherited by implicit conversion ArrowAssoc from RegexWhen[R] to ArrowAssoc[RegexWhen[R]]

Ungrouped