class Expect[R] extends Expectable[R]
- Grouped
- Alphabetic
- By Inheritance
- Expect
- Expectable
- AnyRef
- Any
- by fluentToCoreExpect
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Expect(command: String, defaultValue: R)
- new Expect(command: String, defaultValue: R, config: Config)
- new Expect(command: String, defaultValue: R, settings: Settings)
- new Expect(command: Seq[String], defaultValue: R, config: Config)
- new Expect(command: Seq[String], defaultValue: R, settings: Settings = new Settings())
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Expect[R], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addExpectBlock(f: (Expect[R]) ⇒ Unit): Expect[R]
Add arbitrary
ExpectBlocks to thisExpect.Add arbitrary
ExpectBlocks to thisExpect.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
- Expect → Expectable
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collect[T](pf: PartialFunction[R, T]): core.Expect[T]
Creates a new
Expectby mapping the result of the currentExpect, if the given partial function is defined at that value.Creates a new
Expectby mapping the result of the currentExpect, if the given partial function is defined at that value.If the current
Expectcontains a value for which the partial function is defined, the newExpectwill also hold that value. Otherwise, the resultingExpectwill fail with aNoSuchElementException.- T
the type of the returned
Expect- pf
the
PartialFunctionto apply to the result of thisExpect- returns
an
Expectholding the result of application of thePartialFunctionor aNoSuchElementException
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
- val command: Seq[String]
- val defaultValue: R
- def ensuring(cond: (Expect[R]) ⇒ Boolean, msg: ⇒ Any): Expect[R]
- def ensuring(cond: (Expect[R]) ⇒ Boolean): Expect[R]
- def ensuring(cond: Boolean, msg: ⇒ Any): Expect[R]
- def ensuring(cond: Boolean): Expect[R]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(other: Any): Boolean
- Definition Classes
- Expect → AnyRef → Any
-
def
expect(from: FromInputStream): ExpectBlock[R]
Adds an empty new
ExpectBlockreading from the specifiedFromInputStream.Adds an empty new
ExpectBlockreading from the specifiedFromInputStream.- returns
the new
ExpectBlock.
- Definition Classes
- Expect → Expectable
-
def
expect: ExpectBlock[R]
Adds an empty new
ExpectBlock. -
def
expect(pattern: Timeout.type): TimeoutWhen[R]
Adds, in a new
ExpectBlock, aTimeoutWhenthat matches whenever the read from any of theFromStreamInputs times out.Adds, in a new
ExpectBlock, aTimeoutWhenthat matches whenever the read from any of theFromStreamInputs times out. This is a shortcut toexpect.when(pattern).- pattern
the pattern to be used in the
TimeoutWhen.- returns
the new
RegexWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: EndOfFile.type, readFrom: FromInputStream): EndOfFileWhen[R]
Adds, in a new
ExpectBlock, aEndOfFileWhenthat matches whenever the end of file is reached while trying to read from the specifiedFromInputStream.Adds, in a new
ExpectBlock, aEndOfFileWhenthat matches whenever the end of file is reached while trying to read from the specifiedFromInputStream. This is a shortcut toexpect.when(pattern, readFrom).- pattern
the pattern to be used in the
EndOfFileWhen.- readFrom
from which
FromInputStreamto read the output.- returns
the new
RegexWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: EndOfFile.type): EndOfFileWhen[R]
Adds, in a new
ExpectBlock, aEndOfFileWhenthat matches whenever the end of file is reached while trying to read from the StdOut output.Adds, in a new
ExpectBlock, aEndOfFileWhenthat matches whenever the end of file is reached while trying to read from the StdOut output. This is a shortcut toexpect.when(pattern).- pattern
the pattern to be used in the
EndOfFileWhen.- returns
the new
RegexWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: Regex, readFrom: FromInputStream): RegexWhen[R]
Adds, in a new
ExpectBlock, aRegexWhenthat matches whenever the regexpatternsuccessfully matches against the text read from the specifiedFromInputStream.Adds, in a new
ExpectBlock, aRegexWhenthat matches whenever the regexpatternsuccessfully matches against the text read from the specifiedFromInputStream. This is a shortcut toexpect.when(pattern, readFrom).- pattern
the pattern to be used in the
RegexWhen.- readFrom
from which
FromInputStreamto read the output.- returns
the new
RegexWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: Regex): RegexWhen[R]
Adds, in a new
ExpectBlock, aRegexWhenthat matches whenever the regexpatternsuccessfully matches against the text read from the StdOut output.Adds, in a new
ExpectBlock, aRegexWhenthat matches whenever the regexpatternsuccessfully matches against the text read from the StdOut output. This is a shortcut toexpect.when(pattern).- pattern
the pattern to be used in the
RegexWhen.- returns
the new
RegexWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: String, readFrom: FromInputStream): StringWhen[R]
Adds, in a new
ExpectBlock, aStringWhenthat matches wheneverpatternis contained in the text read from the specifiedFromInputStream.Adds, in a new
ExpectBlock, aStringWhenthat matches wheneverpatternis contained in the text read from the specifiedFromInputStream. This is a shortcut toexpect.when(pattern, readFrom).- pattern
the pattern to be used in the
StringWhen.- readFrom
from which
FromInputStreamto read the output.- returns
the new
StringWhen.
- Definition Classes
- Expectable
-
def
expect(pattern: String): StringWhen[R]
Adds, in a new
ExpectBlock, aStringWhenthat matches wheneverpatternis contained in the text read from the StdOut output.Adds, in a new
ExpectBlock, aStringWhenthat matches wheneverpatternis contained in the text read from the StdOut output. This is a shortcut toexpect.when(pattern).- pattern
the pattern to be used in the
StringWhen.- returns
the new
StringWhen.
- Definition Classes
- Expectable
-
var
expectBlocks: Seq[ExpectBlock[R]]
- Attributes
- protected
-
val
expectableParent: Expect[R]
- Attributes
- protected
- Definition Classes
- Expect → Expectable
-
def
filter(p: (R) ⇒ Boolean): core.Expect[R]
Creates a new
Expectby filtering its result with a predicate.Creates a new
Expectby filtering its result with a predicate.If the current
Expectresult satisfies the predicate, the newExpectwill also hold that result. Otherwise, the resultingExpectwill fail with aNoSuchElementException.- p
the predicate to apply to the result of this
Expect
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flatMap[T](f: (R) ⇒ core.Expect[T]): core.Expect[T]
Creates a new
Expectby applying a function to the returned result of thisExpect, and returns the result of the function as the newExpect.Creates a new
Expectby applying a function to the returned result of thisExpect, and returns the result of the function as the newExpect.- T
the type of the returned
Expect- f
the function which will be applied to the returned result of this
Expect- returns
the
Expectreturned as the result of the application of the functionf
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
flatten[T](implicit ev: <:<[R, core.Expect[T]]): core.Expect[T]
Creates a new
Expectwith one level of nesting flattened, this method is equivalent toflatMap(identity).Creates a new
Expectwith one level of nesting flattened, this method is equivalent toflatMap(identity).- T
the type of the returned
Expect- returns
an
Expectwith one level of nesting flattened
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- Expect → AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
map[T](f: (R) ⇒ T): core.Expect[T]
Creates a new
Expectby applying a function to the returned result of thisExpect.Creates a new
Expectby applying a function to the returned result of thisExpect.- T
the type of the returned
Expect- f
the function which will be applied to the returned result of this
Expect- returns
an
Expectwhich will return the result of the application of the functionf
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
newExpectBlock(block: ExpectBlock[R]): ExpectBlock[R]
- Attributes
- protected
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
run(process: RichProcess)(implicit ex: ExecutionContext): Future[R]
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
run(settings: Settings)(implicit ex: ExecutionContext): Future[R]
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
run(timeout: FiniteDuration = settings.timeout, charset: Charset = settings.charset)(implicit ex: ExecutionContext): Future[R]
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
- val settings: Settings
-
def
structurallyEquals[RR >: R](other: core.Expect[RR]): Boolean
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toCore: core.Expect[R]
- returns
the core.Expect equivalent of this fluent.Expect.
-
def
toString(): String
- Definition Classes
- Expect → AnyRef → Any
-
def
transform[T](flatMapPF: PartialFunction[R, core.Expect[T]], mapPF: PartialFunction[R, T]): core.Expect[T]
Transform this
Expectresult using the following strategy:Transform this
Expectresult using the following strategy:- if
flatMapPFisDefinedAtfor this expect result then the result is flatMapped using flatMapPF. - otherwise, if
mapPFisDefinedAtfor this expect result then the result is mapped using mapPF. - otherwise a NoSuchElementException is thrown where the result would be expected.
This function is very useful when we need to flatMap this
Expectfor some values of its result type and map thisExpectfor some other values of its result type.To ensure you don't get NoSuchElementException you should take special care in ensuring:
domain(flatMapPF) ∪ domain(mapPF) == domain(R)
Remember that in the domain of R the
defaultValueis also included.- T
the type of the returned
Expect- flatMapPF
the function that will be applied when a flatMap is needed
- mapPF
the function that will be applied when a map is needed
- returns
a new
Expectwhose result is either flatMapped or mapped according to whether flatMapPF or mapPF is defined for the given result
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
def countFilesInFolder(folder: String): Expect[Either[String, Int]] = { val e = new Expect(s"ls -1 $$folder", Left("unknownError"): Either[String, Int])( ExpectBlock( StringWhen("access denied")( Returning(Left("Access denied")) ), RegexWhen("(?s)(.*)".r)( ReturningWithRegex(_.group(1).split("\n").length) ) ) ) e } def ensureFolderIsEmpty(folder: String): Expect[Either[String, Unit]] = { countFilesInFolder(folder).transform({ case Right(numberOfFiles) => Expect(s"rm -r $$folder", Left("unknownError"): Either[String, Unit])( ExpectBlock( StringWhen("access denied")( Returning(Left("Access denied")) ), EndOfFileWhen( Returning(()) ) ) ) }, { case Left(l) => Left(l) case Right(numberOfFiles) if numberOfFiles == 0 => Right(()) }) }
Example: - if
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
withFilter(p: (R) ⇒ Boolean): core.Expect[R]
Used by for-comprehensions.
Used by for-comprehensions.
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
zip[T](that: core.Expect[T]): core.Expect[(R, T)]
Zips the results of
thisandthatExpect, and creates a newExpectholding the tuple of their results.Zips the results of
thisandthatExpect, and creates a newExpectholding the tuple of their results.- T
the type of the returned
Expect- that
the other
Expect- returns
an
Expectwith the results of bothExpects
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
-
def
zipWith[T, U](that: core.Expect[T])(f: (R, T) ⇒ U): core.Expect[U]
Zips the results of
thisandthatExpectusing a functionf, and creates a newExpectholding the result.Zips the results of
thisandthatExpectusing a functionf, and creates a newExpectholding the result.- T
the type of the other
Expect- U
the type of the resulting
Expect- that
the other
Expect- f
the function to apply to the results of
thisandthat- returns
an
Expectwith the result of the application offto the results ofthisandthat
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Definition Classes
- Expect
- def →[B](y: B): (Expect[R], B)
Shadowed Implicit Value Members
-
val
command: Seq[String]
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).command
- Definition Classes
- Expect
-
val
defaultValue: R
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).defaultValue
- Definition Classes
- Expect
-
def
equals(other: Any): Boolean
Returns whether
otheris anExpectwith the samecommand, the samedefaultValue, the samesettingsand the sameexpectsas thisExpect.Returns whether
otheris anExpectwith the samecommand, the samedefaultValue, the samesettingsand the sameexpectsas thisExpect.In the cases that
expectscontains an Action with a function, eg. Returning, this method will return false, because equality is not defined for functions.The method
structurallyEqualcan be used to test that two expects contain the same structure.- other
the other
Expectto compare thisExpectto.
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).equals(other)
- Definition Classes
- Expect → AnyRef → Any
-
val
expectBlocks: core.ExpectBlock[R]*
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).expectBlocks
- Definition Classes
- Expect
-
def
hashCode(): Int
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).hashCode()
- Definition Classes
- Expect → AnyRef → Any
-
val
settings: Settings
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).settings
- Definition Classes
- Expect
-
def
toString(): String
- Implicit
- This member is added by an implicit conversion from Expect[R] to core.Expect[R] performed by method fluentToCoreExpect in work.martins.simon.expect.fluent.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(expect: core.Expect[R]).toString()
- Definition Classes
- Expect → AnyRef → Any