38
38
import org .apache .cloudstack .backup .BackupOffering ;
39
39
import org .apache .cloudstack .backup .veeam .api .RestoreSession ;
40
40
import org .apache .http .HttpResponse ;
41
- import org .apache .logging .log4j .core . Logger ;
41
+ import org .apache .logging .log4j .Logger ;
42
42
import org .junit .Assert ;
43
43
import org .junit .Before ;
44
44
import org .junit .Rule ;
@@ -59,8 +59,6 @@ public class VeeamClientTest {
59
59
private VeeamClient mockClient ;
60
60
private static final SimpleDateFormat newDateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
61
61
62
- private VeeamClient mock = Mockito .mock (VeeamClient .class );
63
-
64
62
@ Rule
65
63
public WireMockRule wireMockRule = new WireMockRule (9399 );
66
64
@@ -177,35 +175,35 @@ public void checkIfRestoreSessionFinishedTestTimeoutException() throws IOExcepti
177
175
@ Test
178
176
public void getRestoreVmErrorDescriptionTestFindErrorDescription () {
179
177
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" );
183
181
Assert .assertEquals ("Example of error description found in Veeam." , result );
184
182
}
185
183
186
184
@ Test
187
185
public void getRestoreVmErrorDescriptionTestNotFindErrorDescription () {
188
186
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" );
192
190
Assert .assertEquals ("Cannot find restore session with provided uid uuid" , result );
193
191
}
194
192
195
193
@ Test
196
194
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" );
200
198
Assert .assertEquals ("Failed to get the description of the failed restore session [uuid]. Please contact an administrator." , result );
201
199
}
202
200
203
201
@ Test
204
202
public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsFalse () {
205
203
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" );
209
207
Assert .assertEquals ("Failed to get the description of the failed restore session [uuid]. Please contact an administrator." , result );
210
208
}
211
209
0 commit comments