Class

work.martins.simon.expect.fluent

EndOfFileWhen

Related Doc: package fluent

Permalink

case class EndOfFileWhen[R](parent: ExpectBlock[R]) extends When[R] with Product with Serializable

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. EndOfFileWhen
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. When
  7. Whenable
  8. Expectable
  9. Runnable
  10. AnyRef
  11. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new EndOfFileWhen(parent: ExpectBlock[R])

    Permalink

Type Members

  1. type CW = core.EndOfFileWhen[R]

    Permalink
    Definition Classes
    EndOfFileWhenWhen

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. var actions: Seq[Action[CW]]

    Permalink
    Attributes
    protected
    Definition Classes
    When
  5. def addActions(f: (EndOfFileWhen.this.type) ⇒ Unit): EndOfFileWhen.this.type

    Permalink

    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[String] => Unit = { when =>
      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
  6. def addExpectBlock(f: (Expect[R]) ⇒ Unit): Expect[R]

    Permalink

    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[String] => Unit = { expect =>
      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
  7. def addWhen[W <: When[R]](f: (ExpectBlock[R]) ⇒ W): W

    Permalink

    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
  8. def addWhens(f: (ExpectBlock[R]) ⇒ Unit): ExpectBlock[R]

    Permalink

    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
  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(other: Any): Boolean

    Permalink
    Definition Classes
    EndOfFileWhen → Equals → AnyRef → Any
  13. def exit(): When[R]

    Permalink

    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
  14. def expect(pattern: EndOfFile.type): EndOfFileWhen[R]

    Permalink

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

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

    pattern

    the pattern to be used in the EndOfFileWhen.

    returns

    the new RegexWhen.

    Definition Classes
    Expectable
  15. def expect(pattern: Timeout.type): TimeoutWhen[R]

    Permalink

    Adds, in a new ExpectBlock, a TimeoutWhen that matches whenever the read from the process output (stdOut) times out.

    Adds, in a new ExpectBlock, a TimeoutWhen that matches whenever the read from the process output (stdOut) 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
  16. def expect(pattern: Regex): RegexWhen[R]

    Permalink

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

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

    pattern

    the pattern to be used in the RegexWhen.

    returns

    the new RegexWhen.

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

    Permalink

    Adds, in a new ExpectBlock, a StringWhen that matches whenever pattern is contained in the text read from the process output (stdOut).

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

    pattern

    the pattern to be used in the StringWhen.

    returns

    the new StringWhen.

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

    Permalink

    Adds an empty new ExpectBlock.

    Adds an empty new ExpectBlock.

    returns

    the new ExpectBlock.

    Definition Classes
    Expectable
  19. val expectableParent: Expectable[R]

    Permalink
    Attributes
    protected
    Definition Classes
    WhenExpectable
  20. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Permalink
    Definition Classes
    EndOfFileWhen → AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  24. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. def newAction(action: Action[CW]): When[R]

    Permalink
    Attributes
    protected
    Definition Classes
    When
  26. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. val parent: ExpectBlock[R]

    Permalink
    Definition Classes
    EndOfFileWhenWhen
  29. def returning(result: ⇒ R): When[R]

    Permalink

    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
  30. def returningExpect(result: ⇒ core.Expect[R]): When[R]

    Permalink
    Definition Classes
    When
  31. def run(timeout: FiniteDuration = settings.timeout, charset: Charset = settings.charset, bufferSize: Int = settings.bufferSize, redirectStdErrToStdOut: Boolean = settings.redirectStdErrToStdOut)(implicit ex: ExecutionContext): Future[R]

    Permalink

    Runs this Expect.

    Runs this Expect.

    timeout

    the maximum time to wait for each read.

    charset

    the charset to use when decoding/encoding the read/write text.

    bufferSize

    the size of the buffer to use when performing reads.

    redirectStdErrToStdOut

    whether to redirect the stdErr of the spawned process to the stdOut.

    ex

    the ExecutionContext upon which this Expect will be run.

    returns

    a Future with the value returned by a ReturningAction, if no ReturningAction exists defaultValue will be returned. If an exception occurred during the execution of the future then that exception will be returned in the Failure of the Future.

    Definition Classes
    Runnable
  32. val runnableParent: Runnable[R]

    Permalink
    Attributes
    protected
    Definition Classes
    WhenRunnable
  33. def send(text: String): When[R]

    Permalink

    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
  34. def sendln(text: String): When[R]

    Permalink

    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
  35. val settings: Settings

    Permalink
    Definition Classes
    WhenRunnable
  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  37. def toCore: CW

    Permalink

    returns

    the core.When equivalent of this fluent.When.

    Definition Classes
    EndOfFileWhenWhen
  38. def toString(): String

    Permalink
    Definition Classes
    EndOfFileWhen → AnyRef → Any
  39. def toString(pattern: String): String

    Permalink
    Definition Classes
    When
  40. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. def when(pattern: Timeout.type): TimeoutWhen[R]

    Permalink

    Adds a new TimeoutWhen that matches whenever a Timeout in thrown while trying to read text from the process output (stdOut).

    Adds a new TimeoutWhen that matches whenever a Timeout in thrown while trying to read text from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new TimeoutWhen.

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

    Permalink

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in the process output (stdOut) is reached.

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in the process output (stdOut) is reached.

    pattern

    the pattern to match against.

    returns

    the new EndOfFileWhen.

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

    Permalink

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the process output (stdOut).

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new RegexWhen.

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

    Permalink

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the process output (stdOut).

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new StringWhen.

    Definition Classes
    Whenable
  47. val whenableParent: Whenable[R]

    Permalink
    Attributes
    protected
    Definition Classes
    WhenWhenable

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 Runnable[R]

Inherited from AnyRef

Inherited from Any

Ungrouped