org.opendaylight.infrautils.testutils.mockito.ThrowsMethodExceptionAnswer Maven / Gradle / Ivy
/*
* Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.infrautils.testutils.mockito;
import java.io.Serializable;
import org.mockito.Mockito;
import org.mockito.internal.stubbing.answers.ThrowsException;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Mockito Answer which for un-stubbed methods throws an
* UnstubbedMethodException (instead of Mockito's default of returning null).
*
*
* Usage:
*
*
* import static ...testutils.mockito.MoreAnswers.exception;
*
* Mockito.mock(YourInterface.class, exception())
*
*
* @see Mockito#mock(Class, Answer)
*
* @see ThrowsException
*
* @author Michael Vorburger
*/
final class ThrowsMethodExceptionAnswer implements Answer