Package org.mockito.internal.stubbing

Source Code of org.mockito.internal.stubbing.DontThrow

/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.stubbing;

import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

@SuppressWarnings("unchecked")
public class DontThrow extends RuntimeException {
    private static final long serialVersionUID = 1L;
    public static final DontThrow DONT_THROW = new DontThrow(null);
    private Answer answer;

    public DontThrow(Answer answer) {
        if (answer == null) {
            answer = new Answer() {
                public Object answer(InvocationOnMock invocation) throws Throwable {
                    return null;
                }
            };
        }

        this.answer = answer;
    }

    public Answer getAnswer() {
        return answer;
    }

    public boolean hasAnswer() {
        return answer != null;
    }
}
TOP

Related Classes of org.mockito.internal.stubbing.DontThrow

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.