Package org.easymock
Class Capture<T>
java.lang.Object
org.easymock.Capture<T>
- Type Parameters:
T
- Type of the captured element
- All Implemented Interfaces:
Serializable
Will contain what was captured by the
capture()
matcher. Knows
if something was captured or not (allows to capture a null value).- Author:
- Henri Tremblay
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCapture()
Deprecated.Capture
(CaptureType type) Deprecated.UseEasyMock.newCapture(CaptureType)
instead -
Method Summary
Modifier and TypeMethodDescriptiongetValue()
Return captured valueReturn all captured values.boolean
static <T> Capture<T>
Create a new capture instance that will keep only the last captured valuestatic <T> Capture<T>
newInstance
(CaptureType type) Create a new capture instance with a specificCaptureType
void
reset()
Will reset capture to a "nothing captured yet" statevoid
Used internally by the EasyMock framework to add a new captured valuetoString()
-
Constructor Details
-
Capture
Deprecated.UseEasyMock.newCapture()
insteadDefault constructor. Only the last element will be captured -
Capture
Deprecated.UseEasyMock.newCapture(CaptureType)
insteadConstructor allowing to select the capture type- Parameters:
type
- capture type
-
-
Method Details
-
newInstance
Create a new capture instance that will keep only the last captured value- Type Parameters:
T
- type of the class to be captured- Returns:
- the new capture object
-
newInstance
Create a new capture instance with a specificCaptureType
- Type Parameters:
T
- type of the class to be captured- Parameters:
type
- capture type wanted- Returns:
- the new capture object
-
reset
public void reset()Will reset capture to a "nothing captured yet" state -
hasCaptured
public boolean hasCaptured()- Returns:
- true if something was captured
-
getValue
Return captured value- Returns:
- The last captured value
- Throws:
AssertionError
- if nothing was captured yet or if more than one value was captured
-
getValues
Return all captured values. It returns the actual list so you can modify it's content if needed- Returns:
- The currently captured values
-
setValue
Used internally by the EasyMock framework to add a new captured value- Parameters:
value
- Value captured
-
toString
-
EasyMock.newCapture()
instead