Class org.as2lib.test.mock.support.DefaultBehavior

org.as2lib.core.BasicClass
   +--org.as2lib.test.mock.support.DefaultBehavior

Implemented Interfaces

Behavior

Description

DefaultBehavior stores expected behaviors and exposes them for verification.

Method Index

new DefaultBehavior()

addMethodBehavior(), createMethodBehavior(), getLastMethodBehavior(), getMethodBehavior(), getMethodBehaviorFactory(), removeAllBehaviors(), setMethodBehaviorFactory(), verify()

Inherited from BasicClass

toString()

Constructor Detail

DefaultBehavior

public function DefaultBehavior(Void)

Constructs a new DefaultBehavior instance.

Method Detail

getMethodBehaviorFactory

public function getMethodBehaviorFactory(Void):MethodBehaviorFactory

Returns either the factory set via setMethodBehaviorFactory or the default one which returns an instance of class DefaultMethodBehavior.

Return

the currently used factory to obtain method call behaviors

setMethodBehaviorFactory

public function setMethodBehaviorFactory(methodBehaviorFactory:MethodBehaviorFactory):Void

Sets the factory used to obtain method call behaviors to store state.

If methodBehaviorFactory is null the getMethodBehaviorFactory method will return the default factory.

Parameters

methodBehaviorFactorythe new factory

addMethodBehavior

public function addMethodBehavior(methodName:String, methodBehavior:MethodBehavior):Void

Adds the given methodBehavior behavior for the passed-in methodName.

If the passed-in methodName is null or an empty string the one returned by the method behaviour's expected method call will be used. If this is also null or an empty string "[unknown]" will be used.

Throws

IllegalArgumentExceptionif the passed-in methodBehavior is null

Specified By

addMethodBehavior() in org.as2lib.test.mock.Behavior

createMethodBehavior

public function createMethodBehavior(expectedMethodCall:MethodCall):MethodBehavior

Creates a new method behavior for the passed-in expectedMethodCall.

Parameters

expectedMethodCallthe method call to create a behavior for

Return

the created method behavior

Specified By

createMethodBehavior() in org.as2lib.test.mock.Behavior

getMethodBehavior

public function getMethodBehavior(actualMethodCall:MethodCall):MethodBehavior

Returns a method behavior that matches the given actualMethodCall.

null will be returned if:

  • The passed-in actualMethodCall is null.
  • There is no matching behavior registered.

Return

a matching method behavior

Specified By

getMethodBehavior() in org.as2lib.test.mock.Behavior

getLastMethodBehavior

public function getLastMethodBehavior(Void):MethodBehavior

Returns the lastly added method behavior.

Return

the lastly added method behavior

Specified By

getLastMethodBehavior() in org.as2lib.test.mock.Behavior

removeAllBehaviors

public function removeAllBehaviors(Void):Void

Removes all added behaviors.

Specified By

removeAllBehaviors() in org.as2lib.test.mock.Behavior

verify

public function verify(Void):Void

Verifies all added behaviors.

Specified By

verify() in org.as2lib.test.mock.Behavior