GsonJsonSerializer { public static Gson getGson() { return gson; }  static Gson getGson();  }
@Test public void testBackupMetaData() throws Exception { BackupMetadata metadata = new BackupMetadata( BackupVersion.SNAPSHOT_BACKUP, "123", Calendar.getInstance().getTime()); String json = metadata.toString(); LOG.info(json); BackupMetadata metadata1 = GsonJsonSerializer.getGson().fromJson(json, BackupMetadata.class); LOG.info(metadata1.toString()); Assert.assertEquals(metadata.getSnapshotDate(), metadata1.getSnapshotDate()); Assert.assertEquals(metadata.getToken(), metadata1.getToken()); }
@Test public void testRestoreStatus() throws Exception { InstanceState.RestoreStatus restoreStatus = new InstanceState.RestoreStatus(); restoreStatus.setStartDateRange(LocalDateTime.now().minusDays(2).withSecond(0).withNano(0)); restoreStatus.setEndDateRange(LocalDateTime.now().minusHours(3).withSecond(0).withNano(0)); restoreStatus.setExecutionStartTime(LocalDateTime.now().withSecond(0).withNano(0)); LOG.info(restoreStatus.toString()); InstanceState.RestoreStatus restoreStatus1 = GsonJsonSerializer.getGson() .fromJson(restoreStatus.toString(), InstanceState.RestoreStatus.class); LOG.info(restoreStatus1.toString()); Assert.assertEquals( restoreStatus.getExecutionStartTime(), restoreStatus1.getExecutionStartTime()); Assert.assertEquals(restoreStatus.getStartDateRange(), restoreStatus1.getStartDateRange()); Assert.assertEquals(restoreStatus.getEndDateRange(), restoreStatus1.getEndDateRange()); }