@Test @RunWithCustomExecutor public void isMongoDataUpdateInProgress_not_running() { VitamThreadUtils.getVitamSession().setTenantId(0); DataMigrationService dataMigrationService = Mockito.mock(DataMigrationService.class); Mockito.doReturn(false).when(dataMigrationService).isMongoDataUpdateInProgress(); MetadataMigrationAdminResource instance = new MetadataMigrationAdminResource(dataMigrationService); Response response = instance.isMigrationInProgress(); assertThat(response.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode()); }
@Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) public Response isMigrationInProgress() { try { VitamThreadUtils.getVitamSession().initIfAbsent(VitamConfiguration.getAdminTenant()); boolean started = this.dataMigrationService.isMongoDataUpdateInProgress(); if (started) { LOGGER.info("Migration still in progress"); return Response.ok(new ResponseMessage("Migration in progress")).build(); } else { LOGGER.info("No active migration"); return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessage("No active migration")) .build(); } } catch (Exception e) { LOGGER.error("An error occurred during data migration", e); return Response.serverError().entity(new ResponseMessage(e.getMessage())).build(); } }
MetadataMigrationAdminResource { @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) public Response isMigrationInProgress() { try { VitamThreadUtils.getVitamSession().initIfAbsent(VitamConfiguration.getAdminTenant()); boolean started = this.dataMigrationService.isMongoDataUpdateInProgress(); if (started) { LOGGER.info("Migration still in progress"); return Response.ok(new ResponseMessage("Migration in progress")).build(); } else { LOGGER.info("No active migration"); return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessage("No active migration")) .build(); } } catch (Exception e) { LOGGER.error("An error occurred during data migration", e); return Response.serverError().entity(new ResponseMessage(e.getMessage())).build(); } } }
MetadataMigrationAdminResource { @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) public Response isMigrationInProgress() { try { VitamThreadUtils.getVitamSession().initIfAbsent(VitamConfiguration.getAdminTenant()); boolean started = this.dataMigrationService.isMongoDataUpdateInProgress(); if (started) { LOGGER.info("Migration still in progress"); return Response.ok(new ResponseMessage("Migration in progress")).build(); } else { LOGGER.info("No active migration"); return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessage("No active migration")) .build(); } } catch (Exception e) { LOGGER.error("An error occurred during data migration", e); return Response.serverError().entity(new ResponseMessage(e.getMessage())).build(); } } MetadataMigrationAdminResource(); @VisibleForTesting  MetadataMigrationAdminResource(
        DataMigrationService dataMigrationService); }
MetadataMigrationAdminResource { @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) public Response isMigrationInProgress() { try { VitamThreadUtils.getVitamSession().initIfAbsent(VitamConfiguration.getAdminTenant()); boolean started = this.dataMigrationService.isMongoDataUpdateInProgress(); if (started) { LOGGER.info("Migration still in progress"); return Response.ok(new ResponseMessage("Migration in progress")).build(); } else { LOGGER.info("No active migration"); return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessage("No active migration")) .build(); } } catch (Exception e) { LOGGER.error("An error occurred during data migration", e); return Response.serverError().entity(new ResponseMessage(e.getMessage())).build(); } } MetadataMigrationAdminResource(); @VisibleForTesting  MetadataMigrationAdminResource(
        DataMigrationService dataMigrationService); @Path(MIGRATION_URI) @POST @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) Response startDataMigration(); @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) Response isMigrationInProgress(); }
MetadataMigrationAdminResource { @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) public Response isMigrationInProgress() { try { VitamThreadUtils.getVitamSession().initIfAbsent(VitamConfiguration.getAdminTenant()); boolean started = this.dataMigrationService.isMongoDataUpdateInProgress(); if (started) { LOGGER.info("Migration still in progress"); return Response.ok(new ResponseMessage("Migration in progress")).build(); } else { LOGGER.info("No active migration"); return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessage("No active migration")) .build(); } } catch (Exception e) { LOGGER.error("An error occurred during data migration", e); return Response.serverError().entity(new ResponseMessage(e.getMessage())).build(); } } MetadataMigrationAdminResource(); @VisibleForTesting  MetadataMigrationAdminResource(
        DataMigrationService dataMigrationService); @Path(MIGRATION_URI) @POST @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) Response startDataMigration(); @Path(MIGRATION_STATUS_URI) @GET @Produces(MediaType.APPLICATION_JSON) Response isMigrationInProgress();  }