BackupServletV2 { @GET @Path("/info/{date}") public Response info(@PathParam("date") String date) { Instant instant = DateUtil.parseInstant(date); List<BackupMetadata> metadataList = backupStatusMgr.getLatestBackupMetadata( BackupVersion.SNAPSHOT_META_SERVICE, new DateRange( instant, instant.plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS))); return Response.ok(GsonJsonSerializer.getGson().toJson(metadataList)).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 testBackUpInfo() throws Exception { List<BackupMetadata> backupMetadataList = new ArrayList<>(); backupMetadataList.add(getBackupMetaData()); new Expectations() { { backupStatusMgr.getLatestBackupMetadata( BackupVersion.SNAPSHOT_META_SERVICE, new DateUtil.DateRange((Instant) any, (Instant) any)); result = backupMetadataList; } }; Response response = resource.info(backupDate); assertEquals(200, response.getStatus()); assertEquals( GsonJsonSerializer.getGson().toJson(backupMetadataList), response.getEntity().toString()); }
@Test public void testBackUpInfoNoBackups() { new Expectations() { { backupStatusMgr.getLatestBackupMetadata( BackupVersion.SNAPSHOT_META_SERVICE, new DateUtil.DateRange((Instant) any, (Instant) any)); result = new ArrayList<>(); } }; Response response = resource.info(backupDate); assertEquals(200, response.getStatus()); assertEquals( GsonJsonSerializer.getGson().toJson(new ArrayList<>()), response.getEntity().toString()); }