2 * Copyright (c) 2015 Inocybe and others. All rights reserved.
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
9 package org.opendaylight.ovsdb.openstack.netvirt;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.times;
15 import static org.mockito.Mockito.verify;
16 import static org.mockito.Mockito.verifyNoMoreInteractions;
17 import static org.mockito.Mockito.when;
19 import java.net.HttpURLConnection;
22 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
23 import org.opendaylight.ovsdb.openstack.netvirt.api.Status;
24 import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode;
26 * Unit test for {@link AbstractHandler}
30 public class AbstractHandlerTest {
33 public void testAbstractHandler() {
34 Status status = mock(Status.class);
36 when(status.getCode())
37 .thenReturn(StatusCode.BADREQUEST)
38 .thenReturn(StatusCode.CONFLICT)
39 .thenReturn(StatusCode.NOTACCEPTABLE)
40 .thenReturn(StatusCode.NOTFOUND)
41 .thenReturn(StatusCode.GONE);
44 "Error, getException() did not return the correct neutron API service error",
45 HttpURLConnection.HTTP_BAD_REQUEST,
46 AbstractHandler.getException(status));
48 "Error, getException() did not return the correct neutron API service error",
49 HttpURLConnection.HTTP_CONFLICT,
50 AbstractHandler.getException(status));
52 "Error, getException() did not return the correct neutron API service error",
53 HttpURLConnection.HTTP_NOT_ACCEPTABLE,
54 AbstractHandler.getException(status));
56 "Error, getException() did not return the correct neutron API service error",
57 HttpURLConnection.HTTP_NOT_FOUND,
58 AbstractHandler.getException(status));
60 "Error, getException() did not return the correct neutron API service error",
61 HttpURLConnection.HTTP_INTERNAL_ERROR,
62 AbstractHandler.getException(status));
66 public void testEnqueueEvent(){
67 EventDispatcher eventDispatcher = mock(EventDispatcher.class);
69 verifyNoMoreInteractions(eventDispatcher);
70 eventDispatcher.enqueueEvent(mock(AbstractEvent.class));
71 verify(eventDispatcher, times(1)).enqueueEvent(any(AbstractEvent.class));