Bug 4202: Require that a producer has claimed a namespace on shard registration
[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 terms of the Eclipse
5  * Public License v1.0 which accompanies this distribution, and is available at
6  * 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 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 }