3838import org .apache .cloudstack .backup .BackupOffering ;
3939import org .apache .cloudstack .backup .veeam .api .RestoreSession ;
4040import org .apache .http .HttpResponse ;
41- import org .apache .logging .log4j .core . Logger ;
41+ import org .apache .logging .log4j .Logger ;
4242import org .junit .Assert ;
4343import org .junit .Before ;
4444import org .junit .Rule ;
@@ -59,8 +59,6 @@ public class VeeamClientTest {
5959 private VeeamClient mockClient ;
6060 private static final SimpleDateFormat newDateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
6161
62- private VeeamClient mock = Mockito .mock (VeeamClient .class );
63-
6462 @ Rule
6563 public WireMockRule wireMockRule = new WireMockRule (9399 );
6664
@@ -177,35 +175,35 @@ public void checkIfRestoreSessionFinishedTestTimeoutException() throws IOExcepti
177175 @ Test
178176 public void getRestoreVmErrorDescriptionTestFindErrorDescription () {
179177 Pair <Boolean , String > response = new Pair <>(true , "Example of error description found in Veeam." );
180- Mockito .when (mock .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
181- Mockito .when (mock .executePowerShellCommands (Mockito .any ())).thenReturn (response );
182- String result = mock .getRestoreVmErrorDescription ("uuid" );
178+ Mockito .when (mockClient .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
179+ Mockito .when (mockClient .executePowerShellCommands (Mockito .any ())).thenReturn (response );
180+ String result = mockClient .getRestoreVmErrorDescription ("uuid" );
183181 Assert .assertEquals ("Example of error description found in Veeam." , result );
184182 }
185183
186184 @ Test
187185 public void getRestoreVmErrorDescriptionTestNotFindErrorDescription () {
188186 Pair <Boolean , String > response = new Pair <>(true , "Cannot find restore session with provided uid uuid" );
189- Mockito .when (mock .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
190- Mockito .when (mock .executePowerShellCommands (Mockito .any ())).thenReturn (response );
191- String result = mock .getRestoreVmErrorDescription ("uuid" );
187+ Mockito .when (mockClient .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
188+ Mockito .when (mockClient .executePowerShellCommands (Mockito .any ())).thenReturn (response );
189+ String result = mockClient .getRestoreVmErrorDescription ("uuid" );
192190 Assert .assertEquals ("Cannot find restore session with provided uid uuid" , result );
193191 }
194192
195193 @ Test
196194 public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsNull () {
197- Mockito .when (mock .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
198- Mockito .when (mock .executePowerShellCommands (Mockito .any ())).thenReturn (null );
199- String result = mock .getRestoreVmErrorDescription ("uuid" );
195+ Mockito .when (mockClient .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
196+ Mockito .when (mockClient .executePowerShellCommands (Mockito .any ())).thenReturn (null );
197+ String result = mockClient .getRestoreVmErrorDescription ("uuid" );
200198 Assert .assertEquals ("Failed to get the description of the failed restore session [uuid]. Please contact an administrator." , result );
201199 }
202200
203201 @ Test
204202 public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsFalse () {
205203 Pair <Boolean , String > response = new Pair <>(false , null );
206- Mockito .when (mock .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
207- Mockito .when (mock .executePowerShellCommands (Mockito .any ())).thenReturn (response );
208- String result = mock .getRestoreVmErrorDescription ("uuid" );
204+ Mockito .when (mockClient .getRestoreVmErrorDescription ("uuid" )).thenCallRealMethod ();
205+ Mockito .when (mockClient .executePowerShellCommands (Mockito .any ())).thenReturn (response );
206+ String result = mockClient .getRestoreVmErrorDescription ("uuid" );
209207 Assert .assertEquals ("Failed to get the description of the failed restore session [uuid]. Please contact an administrator." , result );
210208 }
211209
0 commit comments