Squashed commit of the following:
[ovsdb.git] / openstack / net-virt / src / test / java / org / opendaylight / ovsdb / openstack / netvirt / AbstractHandlerTest.java
1 /*
2  * Copyright (c) 2015 Inocybe 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
9 package org.opendaylight.ovsdb.openstack.netvirt;
10
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;
18
19 import java.net.HttpURLConnection;
20
21 import org.junit.*;
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;
25 /**
26  * Unit test for {@link AbstractHandler}
27  */
28 @Ignore
29 // TODO SB_MIGRATION
30 public class AbstractHandlerTest {
31
32     @Test
33     public void testAbstractHandler() {
34         Status status = mock(Status.class);
35
36         when(status.getCode())
37                 .thenReturn(StatusCode.BADREQUEST)
38                 .thenReturn(StatusCode.CONFLICT)
39                 .thenReturn(StatusCode.NOTACCEPTABLE)
40                 .thenReturn(StatusCode.NOTFOUND)
41                 .thenReturn(StatusCode.GONE);
42
43         assertEquals(
44                 "Error, getException() did not return the correct neutron API service error",
45                 HttpURLConnection.HTTP_BAD_REQUEST,
46                 AbstractHandler.getException(status));
47         assertEquals(
48                 "Error, getException() did not return the correct neutron API service error",
49                 HttpURLConnection.HTTP_CONFLICT,
50                 AbstractHandler.getException(status));
51         assertEquals(
52                 "Error, getException() did not return the correct neutron API service error",
53                 HttpURLConnection.HTTP_NOT_ACCEPTABLE,
54                 AbstractHandler.getException(status));
55         assertEquals(
56                 "Error, getException() did not return the correct neutron API service error",
57                 HttpURLConnection.HTTP_NOT_FOUND,
58                 AbstractHandler.getException(status));
59         assertEquals(
60                 "Error, getException() did not return the correct neutron API service error",
61                 HttpURLConnection.HTTP_INTERNAL_ERROR,
62                 AbstractHandler.getException(status));
63     }
64
65     @Test
66     public void testEnqueueEvent(){
67         EventDispatcher eventDispatcher = mock(EventDispatcher.class);
68
69         verifyNoMoreInteractions(eventDispatcher);
70         eventDispatcher.enqueueEvent(mock(AbstractEvent.class));
71         verify(eventDispatcher, times(1)).enqueueEvent(any(AbstractEvent.class));
72     }
73 }