Class

work.martins.simon.expect.fluent

ExpectBlock

Related Doc: package fluent

Permalink

class ExpectBlock[R] extends Whenable[R]

Linear Supertypes
Whenable[R], Expectable[R], AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ExpectBlock
  2. Whenable
  3. Expectable
  4. AnyRef
  5. 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 ExpectBlock(parent: Expect[R])

    Permalink

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to any2stringadd[ExpectBlock[R]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (ExpectBlock[R], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to ArrowAssoc[ExpectBlock[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  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: 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
  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
    ExpectBlockWhenable
  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
    ExpectBlockWhenable
  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. def containsWhens(): Boolean

    Permalink
    Attributes
    protected[work.martins.simon.expect]
  12. def ensuring(cond: (ExpectBlock[R]) ⇒ Boolean, msg: ⇒ Any): ExpectBlock[R]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to Ensuring[ExpectBlock[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: (ExpectBlock[R]) ⇒ Boolean): ExpectBlock[R]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to Ensuring[ExpectBlock[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean, msg: ⇒ Any): ExpectBlock[R]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to Ensuring[ExpectBlock[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean): ExpectBlock[R]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to Ensuring[ExpectBlock[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    ExpectBlock → AnyRef → Any
  18. 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
  19. 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
  20. 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
  21. 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
  22. def expect: ExpectBlock[R]

    Permalink

    Adds an empty new ExpectBlock.

    Adds an empty new ExpectBlock.

    returns

    the new ExpectBlock.

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

    Permalink
    Attributes
    protected
    Definition Classes
    ExpectBlockExpectable
  24. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  25. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to StringFormat[ExpectBlock[R]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  26. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    ExpectBlock → AnyRef → Any
  28. final def isInstanceOf[T0]: Boolean

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

    Permalink
    Definition Classes
    AnyRef
  30. def newWhen[W <: When[R]](when: W): W

    Permalink
    Attributes
    protected
  31. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  33. val parent: Expect[R]

    Permalink
  34. val settings: Settings

    Permalink
  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  36. def toCore: core.ExpectBlock[R]

    Permalink

    *

    *

    returns

    the core.ExpectBlock equivalent of this fluent.ExpectBlock.

  37. def toString(): String

    Permalink
    Definition Classes
    ExpectBlock → AnyRef → Any
  38. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. 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
    ExpectBlockWhenable
  42. 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
    ExpectBlockWhenable
  43. 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
    ExpectBlockWhenable
  44. 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
    ExpectBlockWhenable
  45. val whenableParent: Whenable[R]

    Permalink
    Attributes
    protected
    Definition Classes
    ExpectBlockWhenable
  46. def [B](y: B): (ExpectBlock[R], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from ExpectBlock[R] to ArrowAssoc[ExpectBlock[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Whenable[R]

Inherited from Expectable[R]

Inherited from AnyRef

Inherited from Any

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

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

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

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

Ungrouped