mirror of https://github.com/apache/cloudstack.git
Veeam: fix incompatible types: String cannot be converted to Date
This commit is contained in:
parent
b8904f75dd
commit
54225ecd15
|
|
@ -107,7 +107,6 @@ public class VeeamClient {
|
|||
private static final String RESTORE_POINT_REFERENCE = "RestorePointReference";
|
||||
private static final String BACKUP_FILE_REFERENCE = "BackupFileReference";
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
private static final SimpleDateFormat newDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
private String veeamServerIp;
|
||||
|
|
@ -897,7 +896,7 @@ public class VeeamClient {
|
|||
continue;
|
||||
}
|
||||
String vmRestorePointId = vmRestorePoint.getUid().substring(vmRestorePoint.getUid().lastIndexOf(':') + 1);
|
||||
String created = formatDate(vmRestorePoint.getCreationTimeUtc());
|
||||
Date created = formatDate(vmRestorePoint.getCreationTimeUtc());
|
||||
String type = vmRestorePoint.getPointType();
|
||||
LOG.debug(String.format("Adding restore point %s, %s, %s", vmRestorePointId, created, type));
|
||||
vmRestorePointList.add(new Backup.RestorePoint(vmRestorePointId, created, type));
|
||||
|
|
@ -909,8 +908,8 @@ public class VeeamClient {
|
|||
return vmRestorePointList;
|
||||
}
|
||||
|
||||
private String formatDate(String date) throws ParseException {
|
||||
return newDateFormat.format(dateFormat.parse(StringUtils.substring(date, 0, 19)));
|
||||
private Date formatDate(String date) throws ParseException {
|
||||
return dateFormat.parse(StringUtils.substring(date, 0, 19));
|
||||
}
|
||||
|
||||
public Pair<Boolean, String> restoreVMToDifferentLocation(String restorePointId, String hostIp, String dataStoreUuid) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import static org.mockito.Mockito.times;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -55,6 +56,7 @@ public class VeeamClientTest {
|
|||
private String adminPassword = "password";
|
||||
private VeeamClient client;
|
||||
private VeeamClient mockClient;
|
||||
private static final SimpleDateFormat newDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Rule
|
||||
public WireMockRule wireMockRule = new WireMockRule(9399);
|
||||
|
|
@ -463,7 +465,7 @@ public class VeeamClientTest {
|
|||
|
||||
Assert.assertEquals(1, vmRestorePointList.size());
|
||||
Assert.assertEquals("f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977", vmRestorePointList.get(0).getId());
|
||||
Assert.assertEquals("2023-11-03 16:26:12", vmRestorePointList.get(0).getCreated());
|
||||
Assert.assertEquals("2023-11-03 16:26:12", newDateFormat.format(vmRestorePointList.get(0).getCreated()));
|
||||
Assert.assertEquals("Full", vmRestorePointList.get(0).getType());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue