Fix odlparent-3.0.0 checkstyle issues
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / MockingUtilities.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, 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.mdsal.dom.broker;
9
10 import org.mockito.ArgumentCaptor;
11 import org.mockito.Mockito;
12
13 final class MockingUtilities {
14
15     private MockingUtilities() {
16         throw new UnsupportedOperationException("Utility class");
17     }
18
19     public static <T> T mock(final Class<T> type, final String toString) {
20         final T mock = Mockito.mock(type);
21         Mockito.doReturn(toString).when(mock).toString();
22         return mock;
23     }
24
25     @SuppressWarnings({"unchecked", "rawtypes"})
26     public static <T, F extends T> ArgumentCaptor<F> captorFor(final Class<T> rawClass) {
27         return (ArgumentCaptor) ArgumentCaptor.forClass(rawClass);
28     }
29 }