Clean up yang-xpath-impl warnings
[yangtools.git] / common / testutils / src / test / java / org / opendaylight / yangtools / testutils / mockito / tests / MockitoUnstubbedMethodExceptionAnswerTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. 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.tests;
9
10 import static com.google.common.truth.Truth.assertThat;
11 import static org.junit.Assert.fail;
12 import static org.opendaylight.yangtools.testutils.mockito.MoreAnswers.exception;
13
14 import java.io.Closeable;
15 import java.io.IOException;
16 import org.junit.Test;
17 import org.mockito.Mockito;
18 import org.opendaylight.yangtools.testutils.mockito.UnstubbedMethodException;
19
20 public class MockitoUnstubbedMethodExceptionAnswerTest {
21
22     @Test
23     public void testAnswering() throws IOException {
24         Closeable mock = Mockito.mock(Closeable.class, exception());
25         try {
26             mock.close();
27             fail();
28         } catch (UnstubbedMethodException e) {
29             assertThat(e.getMessage()).isEqualTo("close() is not stubbed in mock of java.io.Closeable");
30         }
31
32     }
33
34 }