@Test
@ExtendWith({ RepositoryManagementTestExecutionListener.class,

              ArtifactManagementTestExecutionListener.class })
public void testDownloadPackage(@PypiTestRepository(repositoryId = REPOSITORY_RELEASES, storageId = REPOSITORY_STORAGE) Repository repository,
                                @PypiTestArtifact(repositoryId = REPOSITORY_RELEASES, storageId = REPOSITORY_STORAGE, id = "hello_world_pypi", versions = { "1.0",
                                                                                                                                                            "2.0",
                                                                                                                                                            "3.0",
                                                                                                                                                            "3.1",
                                                                                                                                                            "3.2",
                                                                                                                                                            "3.4",
                                                                                                                                                            "5.1" }) List<Path> packagePaths)
    throws IOException
{
    final String storageId = repository.getStorage().getId();
    final String repositoryId = repository.getId();
    final String invalidPackageName = "helloworldpypi";
    final String packageNameNotUploaded = "helloworldpypi-1.0-py3-none-any.whl";
    final String url = getContextBaseUrl() + "/storages/{storageId}/{repositoryId}/packages/{packageName}";
    // Download request for invalid artifact/package name.
    mockMvc.when()
           .get(url, storageId, repositoryId, invalidPackageName)
           .then()
           .log()
           .all()
           .statusCode(HttpStatus.BAD_REQUEST.value());
    // Download request for package not uploaded.
    mockMvc.when()
           .get(url, storageId, repositoryId, packageNameNotUploaded)
           .then()
           .log()
           .all()
           .statusCode(HttpStatus.NOT_FOUND.value());
    // Download different versions of package
    packagePaths.stream().forEach(path -> {
        // Download request for valid and uploaded package.
        long size;
        try
        {
            size = Files.size(path.normalize());
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        mockMvc.when()
               .get(url, storageId, repositoryId, path.getFileName().toString())
               .then()
               .log()
               .status()
               .log()
               .headers()
               .statusCode(HttpStatus.OK.value())
               .contentType(MediaType.APPLICATION_OCTET_STREAM_VALUE)
               .header(HttpHeaders.CONTENT_LENGTH, Matchers.equalTo(String.valueOf(size)));
    });
}