Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / renderers / iovisor / src / test / java / org / opendaylight / groupbasedpolicy / renderer / iovisor / sf / ActionDefinitionListenerTest.java
index daf72098880303535a956632a2d5af85da0566ac..ff5b87c9ae5a50f4d63676536e7768e1bf49c0cf 100755 (executable)
-/*\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
-package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.spy;\r
-import static org.mockito.Mockito.verify;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.util.Set;\r
-\r
-import com.google.common.collect.ImmutableSet;\r
-import com.google.common.util.concurrent.CheckedFuture;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;\r
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;\r
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;\r
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;\r
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
-import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionKey;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-\r
-public class ActionDefinitionListenerTest {\r
-\r
-    private ActionDefinitionListener listener;\r
-    private DataObjectModification<ActionDefinition> rootNode;\r
-    private Set<DataTreeModification<ActionDefinition>> changes;\r
-\r
-    private InstanceIdentifier<ActionDefinition> rootIdentifier;\r
-    private DataBroker dataProvider;\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Before\r
-    public void init() {\r
-        dataProvider = mock(DataBroker.class);\r
-\r
-        listener = spy(new ActionDefinitionListener(dataProvider));\r
-\r
-        ActionDefinitionKey key = mock(ActionDefinitionKey.class);\r
-        rootNode = mock(DataObjectModification.class);\r
-        rootIdentifier =\r
-                InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ActionDefinition.class, key).build();\r
-        DataTreeIdentifier<ActionDefinition> rootPath =\r
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, rootIdentifier);\r
-\r
-        DataTreeModification<ActionDefinition> change = mock(DataTreeModification.class);\r
-\r
-        when(change.getRootNode()).thenReturn(rootNode);\r
-        when(change.getRootPath()).thenReturn(rootPath);\r
-\r
-        changes = ImmutableSet.of(change);\r
-\r
-        ActionDefinition def = new ActionDefinitionBuilder().setId(AllowActionDefinition.ID).build();\r
-\r
-        when(rootNode.getDataBefore()).thenReturn(def);\r
-        when(rootNode.getDataAfter()).thenReturn(def);\r
-    }\r
-\r
-    @Test\r
-    public void testOnWrite() {\r
-        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);\r
-        WriteTransaction wt = resetTransaction();\r
-\r
-        listener.onDataTreeChanged(changes);\r
-\r
-        verify(listener).onSubtreeModified(rootNode, rootIdentifier);\r
-    }\r
-\r
-    @Test\r
-    public void testOnDelete() {\r
-        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);\r
-        WriteTransaction wt = resetTransaction();\r
-\r
-        listener.onDataTreeChanged(changes);\r
-\r
-        verify(listener).onDelete(rootNode, rootIdentifier);\r
-    }\r
-\r
-    @Test\r
-    public void testOnSubtreeModified() {\r
-        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);\r
-        WriteTransaction wt = resetTransaction();\r
-\r
-        listener.onDataTreeChanged(changes);\r
-\r
-        verify(listener).onSubtreeModified(rootNode, rootIdentifier);\r
-    }\r
-\r
-    private WriteTransaction resetTransaction() {\r
-        WriteTransaction wt = mock(WriteTransaction.class);\r
-        CheckedFuture checkedFuture = mock(CheckedFuture.class);\r
-        when(wt.submit()).thenReturn(checkedFuture);\r
-        when(dataProvider.newWriteOnlyTransaction()).thenReturn(wt);\r
-        return wt;\r
-    }\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.renderer.iovisor.sf;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class ActionDefinitionListenerTest {
+
+    private ActionDefinitionListener listener;
+    private DataObjectModification<ActionDefinition> rootNode;
+    private Set<DataTreeModification<ActionDefinition>> changes;
+
+    private InstanceIdentifier<ActionDefinition> rootIdentifier;
+    private DataBroker dataProvider;
+
+    @SuppressWarnings("unchecked")
+    @Before
+    public void init() {
+        dataProvider = mock(DataBroker.class);
+
+        listener = spy(new ActionDefinitionListener(dataProvider));
+
+        ActionDefinitionKey key = mock(ActionDefinitionKey.class);
+        rootNode = mock(DataObjectModification.class);
+        rootIdentifier =
+                InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ActionDefinition.class, key).build();
+        DataTreeIdentifier<ActionDefinition> rootPath =
+                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, rootIdentifier);
+
+        DataTreeModification<ActionDefinition> change = mock(DataTreeModification.class);
+
+        when(change.getRootNode()).thenReturn(rootNode);
+        when(change.getRootPath()).thenReturn(rootPath);
+
+        changes = ImmutableSet.of(change);
+
+        ActionDefinition def = new ActionDefinitionBuilder().setId(AllowActionDefinition.ID).build();
+
+        when(rootNode.getDataBefore()).thenReturn(def);
+        when(rootNode.getDataAfter()).thenReturn(def);
+    }
+
+    @Test
+    public void testOnWrite() {
+        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
+        WriteTransaction wt = resetTransaction();
+
+        listener.onDataTreeChanged(changes);
+
+        verify(listener).onSubtreeModified(rootNode, rootIdentifier);
+    }
+
+    @Test
+    public void testOnDelete() {
+        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
+        WriteTransaction wt = resetTransaction();
+
+        listener.onDataTreeChanged(changes);
+
+        verify(listener).onDelete(rootNode, rootIdentifier);
+    }
+
+    @Test
+    public void testOnSubtreeModified() {
+        when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);
+        WriteTransaction wt = resetTransaction();
+
+        listener.onDataTreeChanged(changes);
+
+        verify(listener).onSubtreeModified(rootNode, rootIdentifier);
+    }
+
+    private WriteTransaction resetTransaction() {
+        WriteTransaction wt = mock(WriteTransaction.class);
+        CheckedFuture checkedFuture = mock(CheckedFuture.class);
+        when(wt.submit()).thenReturn(checkedFuture);
+        when(dataProvider.newWriteOnlyTransaction()).thenReturn(wt);
+        return wt;
+    }
+
+}