Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / neutron-vpp-mapper / src / test / java / org / opendaylight / groupbasedpolicy / neutron / vpp / mapper / processors / NeutronListenerTest.java
index 3d202801336bdc927d6e005b8615ea003fc788ed..ff5d5f3d73aac6f10c3262cab50160835d6fba8c 100644 (file)
-/*\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.processors;\r
-\r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Matchers.eq;\r
-import static org.mockito.Mockito.verify;\r
-\r
-import java.util.concurrent.ExecutionException;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mockito;\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;\r
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;\r
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;\r
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.GbpByNeutronMappings;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;\r
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-\r
-public class NeutronListenerTest extends AbstractDataBrokerTest {\r
-\r
-    private DataBroker dataBroker;\r
-\r
-    private NodeId routingNode;\r
-    private Port port;\r
-    private BaseEndpointByPort bebp;\r
-    private NeutronListener neutronListener;\r
-    private PortAware baseEpByPortListener;\r
-\r
-    @Before\r
-    public void init() {\r
-        port = TestUtils.createValidVppPort();\r
-        bebp = TestUtils.createBaseEndpointByPortForPort();\r
-        dataBroker = getDataBroker();\r
-        neutronListener = new NeutronListener(dataBroker, routingNode);\r
-        neutronListener.clearDataChangeProviders();\r
-        baseEpByPortListener = Mockito.spy(new PortAware(new PortHandler(\r
-                dataBroker, routingNode), dataBroker));\r
-        neutronListener.addDataChangeProvider(baseEpByPortListener);\r
-    }\r
-\r
-    @Test\r
-    public void constructorTest() {\r
-        dataBroker = Mockito.spy(dataBroker);\r
-        NeutronListener neutronListener = new NeutronListener(dataBroker, routingNode);\r
-        verify(dataBroker).registerDataTreeChangeListener(\r
-                eq(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,\r
-                        InstanceIdentifier.builder(Neutron.class)\r
-                            .build())), any(NeutronListener.class));\r
-        verify(dataBroker).registerDataTreeChangeListener(\r
-                eq(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,\r
-                        InstanceIdentifier.builder(Mappings.class)\r
-                        .child(GbpByNeutronMappings.class)\r
-                        .child(BaseEndpointsByPorts.class)\r
-                        .child(BaseEndpointByPort.class)\r
-                        .build())), any(PortAware.class));\r
-        neutronListener.close();\r
-    }\r
-\r
-    @Test\r
-    public void testProcessCreatedNeutronDto() throws Exception {\r
-        putPortAndBaseEndpointByPort();\r
-        neutronListener.close();\r
-        verify(baseEpByPortListener).processCreatedNeutronDto(port);\r
-    }\r
-\r
-    @Test\r
-    public void testProcessUpdatedNeutronDto() throws Exception {\r
-        putPortAndBaseEndpointByPort();\r
-        Port updatedPort = new PortBuilder(port).setName("renamed").build();\r
-        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();\r
-        wTx.put(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(updatedPort.getKey()), updatedPort);\r
-        wTx.submit().get();\r
-        neutronListener.close();\r
-        verify(baseEpByPortListener).processUpdatedNeutronDto(port, updatedPort);\r
-    }\r
-\r
-    @Test\r
-    public void testProcessDeletedNeutronDto() throws Exception {\r
-        putPortAndBaseEndpointByPort();\r
-        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();\r
-        wTx.delete(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(port.getKey()));\r
-        wTx.submit().get();\r
-        verify(baseEpByPortListener).processDeletedNeutronDto(port);\r
-    }\r
-\r
-    private void putPortAndBaseEndpointByPort() throws InterruptedException, ExecutionException {\r
-        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();\r
-        wTx.put(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(port.getKey()), port);\r
-        wTx.put(LogicalDatastoreType.OPERATIONAL, TestUtils.createBaseEpByPortIid(port.getUuid()), bebp);\r
-        wTx.submit().get();\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.processors;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+import java.util.concurrent.ExecutionException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.GbpByNeutronMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class NeutronListenerTest extends AbstractDataBrokerTest {
+
+    private DataBroker dataBroker;
+
+    private NodeId routingNode;
+    private Port port;
+    private BaseEndpointByPort bebp;
+    private NeutronListener neutronListener;
+    private PortAware baseEpByPortListener;
+
+    @Before
+    public void init() {
+        port = TestUtils.createValidVppPort();
+        bebp = TestUtils.createBaseEndpointByPortForPort();
+        dataBroker = getDataBroker();
+        neutronListener = new NeutronListener(dataBroker, routingNode);
+        neutronListener.clearDataChangeProviders();
+        baseEpByPortListener = Mockito.spy(new PortAware(new PortHandler(
+                dataBroker, routingNode), dataBroker));
+        neutronListener.addDataChangeProvider(baseEpByPortListener);
+    }
+
+    @Test
+    public void constructorTest() {
+        dataBroker = Mockito.spy(dataBroker);
+        NeutronListener neutronListener = new NeutronListener(dataBroker, routingNode);
+        verify(dataBroker).registerDataTreeChangeListener(
+                eq(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+                        InstanceIdentifier.builder(Neutron.class)
+                            .build())), any(NeutronListener.class));
+        verify(dataBroker).registerDataTreeChangeListener(
+                eq(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+                        InstanceIdentifier.builder(Mappings.class)
+                        .child(GbpByNeutronMappings.class)
+                        .child(BaseEndpointsByPorts.class)
+                        .child(BaseEndpointByPort.class)
+                        .build())), any(PortAware.class));
+        neutronListener.close();
+    }
+
+    @Test
+    public void testProcessCreatedNeutronDto() throws Exception {
+        putPortAndBaseEndpointByPort();
+        neutronListener.close();
+        verify(baseEpByPortListener).processCreatedNeutronDto(port);
+    }
+
+    @Test
+    public void testProcessUpdatedNeutronDto() throws Exception {
+        putPortAndBaseEndpointByPort();
+        Port updatedPort = new PortBuilder(port).setName("renamed").build();
+        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        wTx.put(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(updatedPort.getKey()), updatedPort);
+        wTx.submit().get();
+        neutronListener.close();
+        verify(baseEpByPortListener).processUpdatedNeutronDto(port, updatedPort);
+    }
+
+    @Test
+    public void testProcessDeletedNeutronDto() throws Exception {
+        putPortAndBaseEndpointByPort();
+        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        wTx.delete(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(port.getKey()));
+        wTx.submit().get();
+        verify(baseEpByPortListener).processDeletedNeutronDto(port);
+    }
+
+    private void putPortAndBaseEndpointByPort() throws InterruptedException, ExecutionException {
+        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        wTx.put(LogicalDatastoreType.CONFIGURATION, TestUtils.createPortIid(port.getKey()), port);
+        wTx.put(LogicalDatastoreType.OPERATIONAL, TestUtils.createBaseEpByPortIid(port.getUuid()), bebp);
+        wTx.submit().get();
+    }
+}