2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.testutils.mockito;
10 import org.mockito.AdditionalAnswers;
11 import org.mockito.Answers;
12 import org.mockito.stubbing.Answer;
15 * More {@link Answer} variants.
18 * @see AdditionalAnswers
20 * @author Michael Vorburger
22 @SuppressWarnings("unchecked")
23 public final class MoreAnswers {
24 private MoreAnswers() {
28 * Returns Mockito Answer (default) which forwards method calls or throws an UnstubbedMethodException.
30 * @param <T> answer type
32 * @see CallsRealOrExceptionAnswer
34 public static <T> Answer<T> realOrException() {
35 return (Answer<T>) CallsRealOrExceptionAnswer.INSTANCE;
39 * Returns Mockito Answer (default) which throws an UnstubbedMethodException.
41 * @param <T> answer type
43 * @see ThrowsMethodExceptionAnswer
45 public static <T> Answer<T> exception() {
46 return (Answer<T>) ThrowsMethodExceptionAnswer.INSTANCE;