5dd9bff9cf6740675c92d93bdf6015f34d578caa
[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 org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertThrows;
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     @Test
22     public void testAnswering() throws IOException {
23         Closeable mock = Mockito.mock(Closeable.class, exception());
24         String message = assertThrows(UnstubbedMethodException.class, mock::close).getMessage();
25         assertEquals("close() is not stubbed in mock of java.io.Closeable", message);
26     }
27 }