Merge changes Ib795f077,I723e4262
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / transaction / DeviceInterfaceTest.java
diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterfaceTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterfaceTest.java
new file mode 100644 (file)
index 0000000..d0481ae
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2024 Smartoptics 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.transportpce.renderer.provisiondevice.transaction;
+
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class DeviceInterfaceTest {
+
+    @Test
+    void rollback() {
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        Assert.assertTrue(n1.rollback(delete));
+
+        Mockito.verify(delete, Mockito.times(1)).deleteInterface("ROADM-A", "DEG1");
+    }
+
+    @Test
+    void testTwoInterfacesAreEqual() {
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        DeviceInterface n2 = new DeviceInterface("ROADM-A", "DEG1");
+
+        Assert.assertTrue(n1.equals(n2));
+    }
+
+    @Test
+    void testTwoInterfacesAreNotEqual() {
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        DeviceInterface n2 = new DeviceInterface("ROADM-B", "DEG1");
+
+        Assert.assertFalse(n1.equals(n2));
+    }
+}
\ No newline at end of file