### Question:
DataStorageMapper implements EntityMapper<DataStorageDoc> { @Override public XContentBuilder map(final EntityContainer<DataStorageDoc> doc) { try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) { AbstractDataStorage storage = doc.getEntity().getStorage(); jsonBuilder .startObject() .field(DOC_TYPE_FIELD, documentType.name()) .field("id", storage.getId()) .field("parentId", storage.getParentFolderId()) .field("name", storage.getName()) .field("path", storage.getPath()) .field("createdDate", parseDataToString(storage.getCreatedDate())) .field("description", storage.getDescription()) .field("storageType", storage.getType()) .field("regionCode", doc.getEntity().getRegionName()); StoragePolicy storagePolicy = storage.getStoragePolicy(); if (storagePolicy != null) { jsonBuilder .field("storagePolicyBackupDuration", storagePolicy.getBackupDuration()) .field("storagePolicyLongTermStorageDuration", storagePolicy.getLongTermStorageDuration()) .field("storagePolicyShortTermStorageDuration", storagePolicy.getShortTermStorageDuration()) .field("storagePolicyVersioningEnabled", storagePolicy.getVersioningEnabled()); } buildUserContent(doc.getOwner(), jsonBuilder); buildMetadata(doc.getMetadata(), jsonBuilder); buildPermissions(doc.getPermissions(), jsonBuilder); jsonBuilder.endObject(); return jsonBuilder; } catch (IOException e) { throw new IllegalArgumentException("An error occurred while creating document: ", e); } }  @Override XContentBuilder map(final EntityContainer<DataStorageDoc> doc);  }### Answer:
@Test void shouldMapS3DataStorage() throws IOException { DataStorageMapper mapper = new DataStorageMapper(SearchDocumentType.S3_STORAGE); StoragePolicy policy = new StoragePolicy(); policy.setBackupDuration(DURATION); policy.setLongTermStorageDuration(DURATION); policy.setShortTermStorageDuration(DURATION); S3bucketDataStorage dataStorage = new S3bucketDataStorage(); fillStorage(dataStorage); dataStorage.setStoragePolicy(policy); DataStorageDoc doc = DataStorageDoc .builder() .regionName(TEST_REGION) .storage(dataStorage) .build(); XContentBuilder contentBuilder = mapper.map(buildContainer(doc)); verifyS3Storage(dataStorage, TEST_REGION, contentBuilder); verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder); verifyMetadata(EXPECTED_METADATA, contentBuilder); verifyPipelineUser(USER, contentBuilder); }
@Test void shouldMapNFSDataStorage() throws IOException { DataStorageMapper mapper = new DataStorageMapper(SearchDocumentType.NFS_STORAGE); NFSDataStorage dataStorage = new NFSDataStorage(); fillStorage(dataStorage); DataStorageDoc doc = DataStorageDoc .builder() .storage(dataStorage) .build(); XContentBuilder contentBuilder = mapper.map(buildContainer(doc)); verifyNFSStorage(dataStorage, contentBuilder); verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder); verifyMetadata(EXPECTED_METADATA, contentBuilder); verifyPipelineUser(USER, contentBuilder); }