@ExtendWith({ RepositoryManagementTestExecutionListener.class,

              ArtifactManagementTestExecutionListener.class })
@Test
public void testUpdateMetadataOnDeleteReleaseVersionDirectory(@MavenRepository(repositoryId = REPOSITORY_RELEASES_2,
                                                                               setup = MavenIndexedRepositorySetup.class)
                                                              Repository repository,
                                                              @MavenTestArtifact(repositoryId = REPOSITORY_RELEASES_2,
                                                                                 id = "org.carlspring.strongbox.delete-metadata:metadata-foo",
                                                                                 versions = { "1.2.1",
                                                                                              "1.2.2" },
                                                                                 classifiers = "javadoc")
                                                              List<Path> artifactsPaths)
        throws Exception
{
    // Given
    final String storageId = repository.getStorage().getId();
    final String repositoryId = repository.getId();
    RepositoryPath artifact1RepositoryPath = (RepositoryPath) artifactsPaths.get(0).normalize();
    String artifact1RepositoryPathStr = RepositoryFiles.relativizePath(artifact1RepositoryPath);
    String unixBasedRelativePath = FilenameUtils.separatorsToUnix(artifact1RepositoryPathStr);
    Artifact artifact1 = MavenArtifactUtils.convertPathToArtifact(unixBasedRelativePath);
    RepositoryPath artifact2RepositoryPath = (RepositoryPath) artifactsPaths.get(1).normalize();
    String artifact2RepositoryPathStr = RepositoryFiles.relativizePath(artifact2RepositoryPath);
    // When
    mavenMetadataServiceHelper.generateMavenMetadata(repository);
    client.delete(storageId, repositoryId, artifact2RepositoryPathStr);
    // Then
    assertThat(artifact1).isNotNull();
    String metadataPath = String.format("/storages/%s/%s/%s",
                                        storageId,
                                        repositoryId,
                                        getArtifactLevelMetadataPath(artifact1));
    Metadata metadata = defaultMavenArtifactDeployer.retrieveMetadata(metadataPath);
    assertThat(metadata).isNotNull();
    assertThat(metadata.getVersioning()).isNotNull();
    assertThat(metadata.getVersioning().getVersions()).isNotNull();
    assertThat(metadata.getVersioning().getVersions().contains("1.2.2")).isFalse();
}