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;
21 import org.junit.Test;
22 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
23 import org.opendaylight.ovsdb.plugin.api.Status;
24 import org.opendaylight.ovsdb.plugin.api.StatusCode;
26 * Unit test for {@link AbstractHandler}
28 public class AbstractHandlerTest {
31 public void testAbstractHandler() {
32 Status status = mock(Status.class);
34 when(status.getCode())
35 .thenReturn(StatusCode.BADREQUEST)
36 .thenReturn(StatusCode.CONFLICT)
37 .thenReturn(StatusCode.NOTACCEPTABLE)
38 .thenReturn(StatusCode.NOTFOUND)
39 .thenReturn(StatusCode.GONE);
42 "Error, getException() did not return the correct neutron API service error",
43 HttpURLConnection.HTTP_BAD_REQUEST,
44 AbstractHandler.getException(status));
46 "Error, getException() did not return the correct neutron API service error",
47 HttpURLConnection.HTTP_CONFLICT,
48 AbstractHandler.getException(status));
50 "Error, getException() did not return the correct neutron API service error",
51 HttpURLConnection.HTTP_NOT_ACCEPTABLE,
52 AbstractHandler.getException(status));
54 "Error, getException() did not return the correct neutron API service error",
55 HttpURLConnection.HTTP_NOT_FOUND,
56 AbstractHandler.getException(status));
58 "Error, getException() did not return the correct neutron API service error",
59 HttpURLConnection.HTTP_INTERNAL_ERROR,
60 AbstractHandler.getException(status));
64 public void testEnqueueEvent(){
65 EventDispatcher eventDispatcher = mock(EventDispatcher.class);
67 verifyNoMoreInteractions(eventDispatcher);
68 eventDispatcher.enqueueEvent(mock(AbstractEvent.class));
69 verify(eventDispatcher, times(1)).enqueueEvent(any(AbstractEvent.class));