class AuditIntegrityService {

    public AuditCheckObjectGroupResult check(AuditObjectGroup gotDetail, List<StorageStrategy> storageStrategies) throws
        ProcessingStatusException {
        AuditCheckObjectGroupResult result = new AuditCheckObjectGroupResult();
        result.setIdObjectGroup(gotDetail.getId());

        try (final StorageClient storageClient = storageClientFactory.getClient()) {
            for (AuditObject object : gotDetail.getObjects()) {
                if (PHYSICAL_MASTER.equals(object.getQualifier())) {
                    continue;
                }

                AuditCheckObjectResult auditCheckObjectResult = new AuditCheckObjectResult();
                auditCheckObjectResult.setIdObject(object.getId());
                StorageJson storageInformation = object.getStorage();
                List<String> offerIds = StorageStrategyUtils.loadOfferIds(storageInformation.getStrategyId(), storageStrategies);
                JsonNode offerToMetadata = storageClient.getInformation(storageInformation.getStrategyId(),
                        DataCategory.OBJECT, object.getId(), offerIds, true);
                for (String offerId : offerIds) {
                    JsonNode metadata = offerToMetadata.findValue(offerId);
                    if (metadata == null || object.getMessageDigest() == null || !metadata.has("digest")) {
                        auditCheckObjectResult.getOfferStatuses().put(offerId, StatusCode.KO);
                    } else {
                        String digest = metadata.get("digest").asText();
                        if (StringUtils.equals(object.getMessageDigest(), digest)) {
                            auditCheckObjectResult.getOfferStatuses().put(offerId, StatusCode.OK);
                        } else {
                            auditCheckObjectResult.getOfferStatuses().put(offerId, StatusCode.KO);
                        }
                    }
                }
                result.getObjectStatuses().add(auditCheckObjectResult);
            }
            result.setStatus(result.getObjectsGlobalStatus());
        } catch (StorageClientException | StorageStrategyNotFoundException e) {
            LOGGER.error("Storage server errors : ", e);
            throw new ProcessingStatusException(StatusCode.FATAL, String.format("Storage server errors : %s", e));
        }

        if (result.getStatus() == null) {
            result.setStatus(StatusCode.OK);
        }

        return result;
    }

    public  AuditIntegrityService();
    @VisibleForTesting public  AuditIntegrityService(StorageClientFactory storageClientFactory);

}