BackupServletV2 { @GET @Path("/validate/{daterange}") public Response validateV2SnapshotByDate( @PathParam("daterange") String daterange, @DefaultValue("false") @QueryParam("force") boolean force) throws Exception { DateUtil.DateRange dateRange = new DateUtil.DateRange(daterange); Optional<BackupVerificationResult> result = backupVerification.verifyBackup( BackupVersion.SNAPSHOT_META_SERVICE, force, dateRange); if (!result.isPresent()) { return Response.noContent() .entity("No valid meta found for provided time range") .build(); } return Response.ok(result.get().toString()).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);  }
@Test public void testValidate() throws Exception { new Expectations() { { backupVerification.verifyBackup( BackupVersion.SNAPSHOT_META_SERVICE, anyBoolean, new DateUtil.DateRange((Instant) any, (Instant) any)); result = Optional.of(getBackupVerificationResult()); } }; Response response = resource.validateV2SnapshotByDate( new DateUtil.DateRange(Instant.now(), Instant.now()).toString(), true); assertEquals(200, response.getStatus()); assertEquals( GsonJsonSerializer.getGson().toJson(getBackupVerificationResult()), response.getEntity().toString()); }
@Test public void testValidateNoBackups() throws Exception { new Expectations() { { backupVerification.verifyBackup( BackupVersion.SNAPSHOT_META_SERVICE, anyBoolean, new DateUtil.DateRange((Instant) any, (Instant) any)); result = Optional.empty(); } }; Response response = resource.validateV2SnapshotByDate( new DateUtil.DateRange(Instant.now(), Instant.now()).toString(), true); assertEquals(204, response.getStatus()); assertEquals( response.getEntity().toString(), "No valid meta found for provided time range"); }
@Test public void testValidateV2SnapshotByDate() throws Exception { new Expectations() { { backupVerification.verifyBackup( BackupVersion.SNAPSHOT_META_SERVICE, anyBoolean, new DateUtil.DateRange((Instant) any, (Instant) any)); result = Optional.of(getBackupVerificationResult()); } }; Response response = resource.validateV2SnapshotByDate( new DateUtil.DateRange(Instant.now(), Instant.now()).toString(), true); assertEquals(200, response.getStatus()); assertEquals( GsonJsonSerializer.getGson().toJson(getBackupVerificationResult()), response.getEntity().toString()); }