Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  *  * Copyright 2010,
  *  *
  *  * Licensed under the Apache License, Version 2.0 (the "License");
  *  * you may not use this file except in compliance with the License.
  *  * You may obtain a copy of the License at
  *  *
  *  *
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
package org.unitils.mock.core;
import static org.unitils.mock.core.proxy.CloneUtil.createDeepClone;

Filip Neven
Tim Ducheyne
Kenny Claes
public class ObservedInvocation extends ProxyInvocation {
    private Object result;
    private Object resultAtInvocationTime;
    private MockBehavior mockBehavior;

Creates a observed invocation for the given prosy invocation. The argumentsAtInvocationTime should be copies (deep clones) of the arguments at the time of the invocation. This way the original values can still be used later-on even when changes occur to the original values (pass-by-value vs pass-by-reference).

proxyInvocation The proxy invocation, not null
behaviorDefiningInvocation The invocation that defined the behavior, null if there is no behavior
mockBehavior The executed behavior, not null
    public ObservedInvocation(ProxyInvocation proxyInvocationBehaviorDefiningInvocation behaviorDefiningInvocationMockBehavior mockBehavior) {
        this. = behaviorDefiningInvocation;
        this. = mockBehavior;

Sets the result of the invocation. This is set afterwards to make it possible to get the correct sequence in the report when there are nested mock invocations.

result The result of the invocation
    public void setResult(Object result) {
        this. = result;
        this. = createDeepClone(result);
    public Object getResult() {
        return ;
    public Object getResultAtInvocationTime() {
        return ;
        return ;
    public MockBehavior getMockBehavior() {
        return ;
    public boolean hasMockBehavior() {
        return  != null;
New to GrepCode? Check out our FAQ X