@Test public void testListDateRangeNoBackups() throws Exception { String dateRange = String.format( "%s,%s", new SimpleDateFormat("yyyymmdd").format(new Date()), new SimpleDateFormat("yyyymmdd").format(new Date())); new Expectations() { { backupRestoreUtil.getLatestValidMetaPath( metaV2Proxy, new DateUtil.DateRange((Instant) any, (Instant) any)); result = Optional.empty(); } }; Response response = resource.list(dateRange); assertEquals(200, response.getStatus()); assertEquals(response.getEntity().toString(), "No valid meta found!"); }
@GET @Path("/list/{daterange}") public Response list(@PathParam("daterange") String daterange) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<AbstractBackupPath> latestValidMetaFile = BackupRestoreUtil.getLatestValidMetaPath(metaProxy, dateRange); if (!latestValidMetaFile.isPresent()) { return Response.ok("No valid meta found!").build(); } List<AbstractBackupPath> allFiles = BackupRestoreUtil.getAllFiles( latestValidMetaFile.get(), dateRange, metaProxy, pathProvider); return Response.ok( GsonJsonSerializer.getGson() .toJson( allFiles.stream() .map(AbstractBackupPath::getRemotePath) .collect(Collectors.toList()))) .build(); }
BackupServletV2 { @GET @Path("/list/{daterange}") public Response list(@PathParam("daterange") String daterange) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<AbstractBackupPath> latestValidMetaFile = BackupRestoreUtil.getLatestValidMetaPath(metaProxy, dateRange); if (!latestValidMetaFile.isPresent()) { return Response.ok("No valid meta found!").build(); } List<AbstractBackupPath> allFiles = BackupRestoreUtil.getAllFiles( latestValidMetaFile.get(), dateRange, metaProxy, pathProvider); return Response.ok( GsonJsonSerializer.getGson() .toJson( allFiles.stream() .map(AbstractBackupPath::getRemotePath) .collect(Collectors.toList()))) .build(); } }
BackupServletV2 { @GET @Path("/list/{daterange}") public Response list(@PathParam("daterange") String daterange) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<AbstractBackupPath> latestValidMetaFile = BackupRestoreUtil.getLatestValidMetaPath(metaProxy, dateRange); if (!latestValidMetaFile.isPresent()) { return Response.ok("No valid meta found!").build(); } List<AbstractBackupPath> allFiles = BackupRestoreUtil.getAllFiles( latestValidMetaFile.get(), dateRange, metaProxy, pathProvider); return Response.ok( GsonJsonSerializer.getGson() .toJson( allFiles.stream() .map(AbstractBackupPath::getRemotePath) .collect(Collectors.toList()))) .build(); } @Inject  BackupServletV2(
            IBackupStatusMgr backupStatusMgr,
            BackupVerification backupVerification,
            SnapshotMetaTask snapshotMetaService,
            BackupTTLTask backupTTLService,
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            @Named("v2") IMetaProxy metaV2Proxy,
            Provider<AbstractBackupPath> pathProvider,
            BackupV2Service backupService); }
BackupServletV2 { @GET @Path("/list/{daterange}") public Response list(@PathParam("daterange") String daterange) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<AbstractBackupPath> latestValidMetaFile = BackupRestoreUtil.getLatestValidMetaPath(metaProxy, dateRange); if (!latestValidMetaFile.isPresent()) { return Response.ok("No valid meta found!").build(); } List<AbstractBackupPath> allFiles = BackupRestoreUtil.getAllFiles( latestValidMetaFile.get(), dateRange, metaProxy, pathProvider); return Response.ok( GsonJsonSerializer.getGson() .toJson( allFiles.stream() .map(AbstractBackupPath::getRemotePath) .collect(Collectors.toList()))) .build(); } @Inject  BackupServletV2(
            IBackupStatusMgr backupStatusMgr,
            BackupVerification backupVerification,
            SnapshotMetaTask snapshotMetaService,
            BackupTTLTask backupTTLService,
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            @Named("v2") IMetaProxy metaV2Proxy,
            Provider<AbstractBackupPath> pathProvider,
            BackupV2Service backupService); @GET @Path("/do_snapshot") Response backup(); @GET @Path("/ttl") Response ttl(); @GET @Path("/clearCache") Response clearCache(); @GET @Path("/updateService") Response updateService(); @GET @Path("/info/{date}") Response info(@PathParam("date") String date); @GET @Path("/validate/{daterange}") Response validateV2SnapshotByDate(
            @PathParam("daterange") String daterange,
            @DefaultValue("false") @QueryParam("force") boolean force); @GET @Path("/list/{daterange}") Response list(@PathParam("daterange") String daterange); }
BackupServletV2 { @GET @Path("/list/{daterange}") public Response list(@PathParam("daterange") String daterange) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<AbstractBackupPath> latestValidMetaFile = BackupRestoreUtil.getLatestValidMetaPath(metaProxy, dateRange); if (!latestValidMetaFile.isPresent()) { return Response.ok("No valid meta found!").build(); } List<AbstractBackupPath> allFiles = BackupRestoreUtil.getAllFiles( latestValidMetaFile.get(), dateRange, metaProxy, pathProvider); return Response.ok( GsonJsonSerializer.getGson() .toJson( allFiles.stream() .map(AbstractBackupPath::getRemotePath) .collect(Collectors.toList()))) .build(); } @Inject  BackupServletV2(
            IBackupStatusMgr backupStatusMgr,
            BackupVerification backupVerification,
            SnapshotMetaTask snapshotMetaService,
            BackupTTLTask backupTTLService,
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            @Named("v2") IMetaProxy metaV2Proxy,
            Provider<AbstractBackupPath> pathProvider,
            BackupV2Service backupService); @GET @Path("/do_snapshot") Response backup(); @GET @Path("/ttl") Response ttl(); @GET @Path("/clearCache") Response clearCache(); @GET @Path("/updateService") Response updateService(); @GET @Path("/info/{date}") Response info(@PathParam("date") String date); @GET @Path("/validate/{daterange}") Response validateV2SnapshotByDate(
            @PathParam("daterange") String daterange,
            @DefaultValue("false") @QueryParam("force") boolean force); @GET @Path("/list/{daterange}") Response list(@PathParam("daterange") String daterange);  }