import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.RpcResult;
public class LazyDOMRpcResultFutureTest {
private LazyDOMRpcResultFuture lazyDOMRpcResultFuture;
- private final BindingNormalizedNodeCodecRegistry codec = mock(BindingNormalizedNodeCodecRegistry.class);
- private final ListenableFuture future = mock(ListenableFuture.class);
- private final RpcResult domRpcResult = mock(RpcResult.class);
+ private final BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
+ private final ListenableFuture<RpcResult<?>> future = mock(ListenableFuture.class);
+ private final RpcResult<?> domRpcResult = mock(RpcResult.class);
@Before
public void setUp() throws Exception {
- lazyDOMRpcResultFuture = (LazyDOMRpcResultFuture) LazyDOMRpcResultFuture.create(codec, future);
+ lazyDOMRpcResultFuture = LazyDOMRpcResultFuture.create(codec, future);
reset(future);
doReturn(true).when(future).cancel(anyBoolean());
doNothing().when(future).addListener(any(), any());
verify(future).addListener(any(), any());
assertTrue(lazyDOMRpcResultFuture.isCancelled() && lazyDOMRpcResultFuture.isDone());
- assertEquals(lazyDOMRpcResultFuture.checkedGet(), lazyDOMRpcResultFuture.get(1, TimeUnit.SECONDS));
+ assertEquals(lazyDOMRpcResultFuture.get(), lazyDOMRpcResultFuture.get(1, TimeUnit.SECONDS));
final Field result = LazyDOMRpcResultFuture.class.getDeclaredField("result");
result.setAccessible(true);
result.set(lazyDOMRpcResultFuture, null);
- assertEquals(lazyDOMRpcResultFuture.checkedGet(1, TimeUnit.SECONDS), lazyDOMRpcResultFuture.get());
+ assertEquals(lazyDOMRpcResultFuture.get(1, TimeUnit.SECONDS), lazyDOMRpcResultFuture.get());
result.set(lazyDOMRpcResultFuture, null);
doReturn(new Object()).when(domRpcResult).getResult();
assertNotNull(lazyDOMRpcResultFuture.get());
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException() throws Throwable {
doThrow(InterruptedException.class).when(future).get();
try {
- lazyDOMRpcResultFuture.checkedGet();
+ lazyDOMRpcResultFuture.get();
} catch (RuntimeException e) {
throw e.getCause();
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException2() throws Throwable {
doThrow(InterruptedException.class).when(future).get(1, TimeUnit.SECONDS);
try {
- lazyDOMRpcResultFuture.checkedGet(1, TimeUnit.SECONDS);
+ lazyDOMRpcResultFuture.get(1, TimeUnit.SECONDS);
} catch (RuntimeException e) {
throw e.getCause();
}
}
-}
\ No newline at end of file
+}