1616// under the License.
1717package com .cloud .network .router ;
1818
19+ import com .cloud .agent .api .Command ;
1920import com .cloud .agent .api .routing .DhcpEntryCommand ;
2021import com .cloud .agent .manager .Commands ;
2122import com .cloud .dc .DataCenterVO ;
2526import com .cloud .network .dao .NetworkDetailsDao ;
2627import com .cloud .offerings .dao .NetworkOfferingDao ;
2728import com .cloud .offerings .dao .NetworkOfferingDetailsDao ;
28- import com .cloud .user .UserVmVO ;
29+ import com .cloud .vm .UserVmVO ;
2930import com .cloud .vm .NicVO ;
30- import com .cloud .vm .VirtualMachine ;
3131import com .cloud .vm .dao .NicDao ;
32- import com .cloud .vm .dao .UserVmDao ;
3332import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
3433import org .apache .cloudstack .framework .config .ConfigKey ;
3534import org .junit .Assert ;
4241import org .mockito .junit .MockitoJUnitRunner ;
4342import org .springframework .test .util .ReflectionTestUtils ;
4443
45- import static org .mockito .ArgumentMatchers .any ;
46- import static org .mockito .ArgumentMatchers .anyBoolean ;
4744import static org .mockito .ArgumentMatchers .anyLong ;
4845import static org .mockito .Mockito .when ;
4946
@@ -73,8 +70,6 @@ public class DhcpLeaseTimeoutIntegrationTest {
7370 RouterControlHelper routerControlHelper ;
7471 @ Mock
7572 DataCenterDao dcDao ;
76- @ Mock
77- UserVmDao userVmDao ;
7873
7974 private VirtualRouter mockRouter ;
8075 private UserVmVO mockVm ;
@@ -103,17 +98,16 @@ public void setUp() {
10398 when (mockRouter .getInstanceName ()).thenReturn ("r-100-VM" );
10499 when (mockRouter .getDataCenterId ()).thenReturn (1L );
105100
106- when (mockVm .getId ()).thenReturn (200L );
107101 when (mockVm .getHostName ()).thenReturn ("test-vm" );
108102
109- when (mockNic .getId ()).thenReturn (300L );
110103 when (mockNic .getMacAddress ()).thenReturn ("02:00:0a:0b:0c:0d" );
111104 when (mockNic .getIPv4Address ()).thenReturn ("10.1.1.10" );
112105 when (mockNic .getIPv6Address ()).thenReturn (null );
113106 when (mockNic .getNetworkId ()).thenReturn (400L );
114107 when (mockNic .isDefaultNic ()).thenReturn (true );
115108
116109 when (dcDao .findById (anyLong ())).thenReturn (mockDc );
110+ when (mockDc .getNetworkType ()).thenReturn (com .cloud .dc .DataCenter .NetworkType .Advanced );
117111 when (routerControlHelper .getRouterControlIp (anyLong ())).thenReturn ("10.1.1.1" );
118112 when (routerControlHelper .getRouterIpInNetwork (anyLong (), anyLong ())).thenReturn ("10.1.1.1" );
119113 when (networkModel .getExecuteInSeqNtwkElmtCmd ()).thenReturn (false );
@@ -122,14 +116,14 @@ public void setUp() {
122116 @ Test
123117 public void testDhcpEntryCommandContainsLeaseTime () {
124118 // Test that DhcpEntryCommand includes the lease time from ConfigKey
125- Commands cmds = new Commands (null );
119+ Commands cmds = new Commands (Command . OnError . Continue );
126120 commandSetupHelper .createDhcpEntryCommand (mockRouter , mockVm , mockNic , false , cmds );
127121
128122 Assert .assertEquals ("Should have one DHCP command" , 1 , cmds .size ());
129123 DhcpEntryCommand dhcpCmd = (DhcpEntryCommand ) cmds .toCommands ()[0 ];
130124 Assert .assertNotNull ("DHCP command should not be null" , dhcpCmd );
131125 Assert .assertNotNull ("Lease time should not be null" , dhcpCmd .getLeaseTime ());
132-
126+
133127 // Default value should be 0 (infinite)
134128 Assert .assertEquals ("Default lease time should be 0" , Long .valueOf (0L ), dhcpCmd .getLeaseTime ());
135129 }
@@ -140,7 +134,7 @@ public void testDhcpEntryCommandUsesZoneScopedValue() {
140134 Long zoneId = mockRouter .getDataCenterId ();
141135 Integer expectedLeaseTime = NetworkOrchestrationService .DhcpLeaseTimeout .valueIn (zoneId );
142136
143- Commands cmds = new Commands (null );
137+ Commands cmds = new Commands (Command . OnError . Continue );
144138 commandSetupHelper .createDhcpEntryCommand (mockRouter , mockVm , mockNic , false , cmds );
145139
146140 DhcpEntryCommand dhcpCmd = (DhcpEntryCommand ) cmds .toCommands ()[0 ];
@@ -154,7 +148,7 @@ public void testInfiniteLeaseWithZeroValue() {
154148 ConfigKey <Integer > configKey = NetworkOrchestrationService .DhcpLeaseTimeout ;
155149 Assert .assertEquals ("Default value should be 0 for infinite lease" , "0" , configKey .defaultValue ());
156150
157- Commands cmds = new Commands (null );
151+ Commands cmds = new Commands (Command . OnError . Continue );
158152 commandSetupHelper .createDhcpEntryCommand (mockRouter , mockVm , mockNic , false , cmds );
159153
160154 DhcpEntryCommand dhcpCmd = (DhcpEntryCommand ) cmds .toCommands ()[0 ];
@@ -166,7 +160,7 @@ public void testDhcpCommandForNonDefaultNic() {
166160 // Test DHCP command creation for non-default NIC
167161 when (mockNic .isDefaultNic ()).thenReturn (false );
168162
169- Commands cmds = new Commands (null );
163+ Commands cmds = new Commands (Command . OnError . Continue );
170164 commandSetupHelper .createDhcpEntryCommand (mockRouter , mockVm , mockNic , false , cmds );
171165
172166 DhcpEntryCommand dhcpCmd = (DhcpEntryCommand ) cmds .toCommands ()[0 ];
@@ -178,7 +172,7 @@ public void testDhcpCommandForNonDefaultNic() {
178172 @ Test
179173 public void testDhcpCommandWithRemoveFlag () {
180174 // Test DHCP command with remove flag set
181- Commands cmds = new Commands (null );
175+ Commands cmds = new Commands (Command . OnError . Continue );
182176 commandSetupHelper .createDhcpEntryCommand (mockRouter , mockVm , mockNic , true , cmds );
183177
184178 DhcpEntryCommand dhcpCmd = (DhcpEntryCommand ) cmds .toCommands ()[0 ];
0 commit comments