@Test @ExtendWith({ RepositoryManagementTestExecutionListener.class, ArtifactManagementTestExecutionListener.class }) public void testMultiplePackagesFound(@PypiTestRepository(repositoryId = REPOSITORY_RELEASES, storageId = STORAGE_PYPI) Repository repository, @PypiTestArtifact(repositoryId = REPOSITORY_RELEASES, storageId = STORAGE_PYPI, id = "hello_world", versions = { "1.0", "2.0", "3.0", "4.0", "5.0"}) List<Path> packagePaths) throws IOException { List<Path> paths = new ArrayList<>(); String links = ""; String packageName = ""; for (Path path : packagePaths) { paths.add(path.normalize()); PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) path.normalize()); packageName = artifactCoordinates.getId(); links += "<a href=\"" + "/storages/" + repository.getStorage().getId() + "/" + repository.getId() + "/packages/" + artifactCoordinates.buildWheelPackageFileName() + "\">" + artifactCoordinates.buildWheelPackageFileName() + "</a><br>\n"; } String expectedHtmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + links + " </body>\n" + "</html>"; String htmlResponse = htmlResponseBuilder.getHtmlResponse(paths); assertThat(htmlResponse).isNotBlank().isEqualTo(expectedHtmlResponse); }
public String getHtmlResponse(List<Path> filePaths) throws IOException { String htmlResponse = ""; if (CollectionUtils.isEmpty(filePaths)) { htmlResponse = "<html>\n" + " <head>\n" + " <title>Not Found</title>\n" + " </head>\n" + " <body>\n" + " <h1>Not Found</h1>\n" + " </body>\n" + "</html>"; } else { PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) filePaths.get(0)); final String packageName = artifactCoordinates.getId(); htmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + getPackageLinks(filePaths) + " </body>\n" + "</html>"; } return htmlResponse; }
PypiBrowsePackageHtmlResponseBuilder { public String getHtmlResponse(List<Path> filePaths) throws IOException { String htmlResponse = ""; if (CollectionUtils.isEmpty(filePaths)) { htmlResponse = "<html>\n" + " <head>\n" + " <title>Not Found</title>\n" + " </head>\n" + " <body>\n" + " <h1>Not Found</h1>\n" + " </body>\n" + "</html>"; } else { PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) filePaths.get(0)); final String packageName = artifactCoordinates.getId(); htmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + getPackageLinks(filePaths) + " </body>\n" + "</html>"; } return htmlResponse; } }
PypiBrowsePackageHtmlResponseBuilder { public String getHtmlResponse(List<Path> filePaths) throws IOException { String htmlResponse = ""; if (CollectionUtils.isEmpty(filePaths)) { htmlResponse = "<html>\n" + " <head>\n" + " <title>Not Found</title>\n" + " </head>\n" + " <body>\n" + " <h1>Not Found</h1>\n" + " </body>\n" + "</html>"; } else { PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) filePaths.get(0)); final String packageName = artifactCoordinates.getId(); htmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + getPackageLinks(filePaths) + " </body>\n" + "</html>"; } return htmlResponse; }  }
PypiBrowsePackageHtmlResponseBuilder { public String getHtmlResponse(List<Path> filePaths) throws IOException { String htmlResponse = ""; if (CollectionUtils.isEmpty(filePaths)) { htmlResponse = "<html>\n" + " <head>\n" + " <title>Not Found</title>\n" + " </head>\n" + " <body>\n" + " <h1>Not Found</h1>\n" + " </body>\n" + "</html>"; } else { PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) filePaths.get(0)); final String packageName = artifactCoordinates.getId(); htmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + getPackageLinks(filePaths) + " </body>\n" + "</html>"; } return htmlResponse; }  String getHtmlResponse(List<Path> filePaths); }
PypiBrowsePackageHtmlResponseBuilder { public String getHtmlResponse(List<Path> filePaths) throws IOException { String htmlResponse = ""; if (CollectionUtils.isEmpty(filePaths)) { htmlResponse = "<html>\n" + " <head>\n" + " <title>Not Found</title>\n" + " </head>\n" + " <body>\n" + " <h1>Not Found</h1>\n" + " </body>\n" + "</html>"; } else { PypiArtifactCoordinates artifactCoordinates = (PypiArtifactCoordinates) RepositoryFiles.readCoordinates((RepositoryPath) filePaths.get(0)); final String packageName = artifactCoordinates.getId(); htmlResponse = "<html>\n" + " <head>\n" + " <title>Links for " + packageName + "</title>\n" + " </head>\n" + " <body>\n" + " <h1>Links for " + packageName + "</h1>\n" + " " + getPackageLinks(filePaths) + " </body>\n" + "</html>"; } return htmlResponse; }  String getHtmlResponse(List<Path> filePaths);  }