Merge "net-virt-providers: install flow twice unnecessarily"
[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.*;
12
13 import java.net.HttpURLConnection;
14
15 import org.junit.Test;
16 import org.mockito.Mockito;
17 import org.opendaylight.ovsdb.plugin.api.Status;
18 import org.opendaylight.ovsdb.plugin.api.StatusCode;
19
20 /**
21  * Unit test for {@link AbstractHandler}
22  */
23 public class AbstractHandlerTest {
24
25     @Test
26     public void testAbstractHandler() {
27         Status status = Mockito.mock(Status.class);
28
29         Mockito.when(status.getCode())
30                 .thenReturn(StatusCode.BADREQUEST)
31                 .thenReturn(StatusCode.CONFLICT)
32                 .thenReturn(StatusCode.NOTACCEPTABLE)
33                 .thenReturn(StatusCode.NOTFOUND)
34                 .thenReturn(StatusCode.GONE);
35
36         assertEquals(
37                 "Error, getException() did not return the correct neutron API service error",
38                 HttpURLConnection.HTTP_BAD_REQUEST,
39                 AbstractHandler.getException(status));
40         assertEquals(
41                 "Error, getException() did not return the correct neutron API service error",
42                 HttpURLConnection.HTTP_CONFLICT,
43                 AbstractHandler.getException(status));
44         assertEquals(
45                 "Error, getException() did not return the correct neutron API service error",
46                 HttpURLConnection.HTTP_NOT_ACCEPTABLE,
47                 AbstractHandler.getException(status));
48         assertEquals(
49                 "Error, getException() did not return the correct neutron API service error",
50                 HttpURLConnection.HTTP_NOT_FOUND,
51                 AbstractHandler.getException(status));
52         assertEquals(
53                 "Error, getException() did not return the correct neutron API service error",
54                 HttpURLConnection.HTTP_INTERNAL_ERROR,
55                 AbstractHandler.getException(status));
56     }
57 }