Intro. new yangtools.testutils artifacts (incl. Mikito)
[yangtools.git] / common / testutils / src / main / java / org / opendaylight / yangtools / testutils / mockito / UnstubbedMethodException.java
1 /*
2  * Copyright (c) 2016 Red Hat and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.testutils.mockito;
9
10 import java.lang.reflect.Method;
11 import org.mockito.internal.util.MockUtil;
12
13 /**
14  * Exception to be thrown on unstubbed method calls.
15  *
16  * @author Michael Vorburger
17  */
18 public class UnstubbedMethodException extends UnsupportedOperationException {
19     private static final long serialVersionUID = 1L;
20
21     public UnstubbedMethodException(Method method) {
22         super(MethodExtensions.toString(method) + " is not stubbed in mock of " + method.getDeclaringClass().getName());
23     }
24
25     public UnstubbedMethodException(Method method, Object mockAbstractFakeObject) {
26         super(MethodExtensions.toString(method) + " is not implemented in "
27                 + new MockUtil().getMockName(mockAbstractFakeObject).toString());
28     }
29 }