New Package dealing with device rollback
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / transaction / DeviceInterfaceTest.java
1 /*
2  * Copyright © 2024 Smartoptics 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.transportpce.renderer.provisiondevice.transaction;
10
11 import org.junit.Assert;
12 import org.junit.jupiter.api.Test;
13 import org.mockito.Mockito;
14 import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
15
16 class DeviceInterfaceTest {
17
18     @Test
19     void rollback() {
20         Delete delete = Mockito.mock(Delete.class);
21         Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
22
23         DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
24         Assert.assertTrue(n1.rollback(delete));
25
26         Mockito.verify(delete, Mockito.times(1)).deleteInterface("ROADM-A", "DEG1");
27     }
28
29     @Test
30     void testTwoInterfacesAreEqual() {
31         DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
32         DeviceInterface n2 = new DeviceInterface("ROADM-A", "DEG1");
33
34         Assert.assertTrue(n1.equals(n2));
35     }
36
37     @Test
38     void testTwoInterfacesAreNotEqual() {
39         DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
40         DeviceInterface n2 = new DeviceInterface("ROADM-B", "DEG1");
41
42         Assert.assertFalse(n1.equals(n2));
43     }
44 }