Remove plugin dependencies
[ovsdb.git] / openstack / net-virt / src / test / java / org / opendaylight / ovsdb / openstack / netvirt / impl / SecurityServicesImplTest.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 package org.opendaylight.ovsdb.openstack.netvirt.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.mockito.Matchers.anyString;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.when;
15
16 import java.util.ArrayList;
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Map;
20
21 import org.junit.Before;
22 import org.junit.Ignore;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mock;
27 import org.mockito.runners.MockitoJUnitRunner;
28 import org.opendaylight.neutron.spi.INeutronPortCRUD;
29 import org.opendaylight.neutron.spi.NeutronPort;
30 import org.opendaylight.neutron.spi.NeutronSecurityGroup;
31 import org.opendaylight.ovsdb.lib.notation.Column;
32 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
33 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
34 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
35
36 /**
37  * Unit test for {@link SecurityServicesImpl}
38  */
39 /* TODO SB_MIGRATION */ @Ignore
40 @RunWith(MockitoJUnitRunner.class)
41 public class SecurityServicesImplTest {
42
43     @InjectMocks private SecurityServicesImpl securityServicesImpl;
44     @InjectMocks private INeutronPortCRUD neutronPortService = mock(INeutronPortCRUD.class);
45
46     @Mock Interface intf;
47
48     private List<NeutronSecurityGroup> securityGroups = new ArrayList<NeutronSecurityGroup>();
49
50     @Before
51     public void setUp(){
52         NeutronPort neutronPort = mock(NeutronPort.class);
53
54         Map<String, String> externalIds =new HashMap<String, String>();
55         externalIds.put(Constants.EXTERNAL_ID_INTERFACE_ID, "mapValue");
56         Column<GenericTableSchema, Map<String, String>> columnMock = mock(Column.class);
57
58         securityGroups.add(mock(NeutronSecurityGroup.class));
59
60         when(intf.getExternalIdsColumn()).thenReturn(columnMock);
61         when(columnMock.getData()).thenReturn(externalIds);
62
63         when(neutronPort.getSecurityGroups()).thenReturn(securityGroups);
64         when(neutronPort.getDeviceOwner()).thenReturn("deviceOwner");
65         when(neutronPortService.getPort(anyString())).thenReturn(neutronPort);
66     }
67
68     /**
69      * Test method {@link SecurityServicesImpl#isPortSecurityReady(Interface)}
70      */
71     @Test
72     public void testIsPortSecurityReady(){
73         assertTrue("Error, did not return expected boolean for isPortSecurityReady", securityServicesImpl.isPortSecurityReady(intf));
74     }
75
76     /**
77      * Test method {@link SecurityServicesImpl#getSecurityGroupInPort(Interface)}
78      */
79     @Test
80     public void testSecurityGroupInPort(){
81         assertEquals("Error, did not return the good neutronSecurityGroup of securityGroups", securityGroups.toArray()[0], securityServicesImpl.getSecurityGroupInPort(intf));
82     }
83 }