Maven2BrowseNodeGenerator extends ComponentPathBrowseNodeGenerator { @Override public List<BrowsePath> computeAssetPaths(final Asset asset) { checkNotNull(asset); return asset.component().map(component -> { List<BrowsePath> assetPaths = computeComponentPaths(asset); appendPath(assetPaths, lastSegment(asset.path()), asset.path()); return assetPaths; }).orElseGet(() -> super.computeAssetPaths(asset)); }  @Override List<BrowsePath> computeAssetPaths(final Asset asset); @Override List<BrowsePath> computeComponentPaths(final Asset asset);  }
@Test public void should_build_paths_to_base_versioned_asset_which_has_a_component() { AssetData asset = new AssetData(); asset.setPath("/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"); asset.setComponent(aReleaseVersionedComponent()); List<BrowsePath> browsePaths = underTest.computeAssetPaths(asset); assertThat(browsePaths.size(), is(5)); assertThat(browsePaths, containsInAnyOrder( new BrowsePath("org", "/org/"), new BrowsePath("hamcrest", "/org/hamcrest/"), new BrowsePath("hamcrest-core", "/org/hamcrest/hamcrest-core/"), new BrowsePath(BASE_VERSION, "/org/hamcrest/hamcrest-core/1.3/"), new BrowsePath("hamcrest-core-1.3.jar", asset.path()))); }
@Test public void should_build_paths_to_timestamped_versioned_asset_which_has_a_component() { AssetData asset = new AssetData(); asset.setPath("/org/hamcrest/hamcrest-core/1.3-SNAPSHOT/hamcrest-core-1.3-20200717.093520-1.jar"); asset.setComponent(aSnapshotVersionedComponent()); List<BrowsePath> browsePaths = underTest.computeAssetPaths(asset); assertThat(browsePaths.size(), is(6)); assertThat(browsePaths, containsInAnyOrder( new BrowsePath("org", "/org/"), new BrowsePath("hamcrest", "/org/hamcrest/"), new BrowsePath("hamcrest-core", "/org/hamcrest/hamcrest-core/"), new BrowsePath(SNAPSHOT_VERSION, "/org/hamcrest/hamcrest-core/1.3-SNAPSHOT/"), new BrowsePath(TIMESTAMPED_VERSION, "/org/hamcrest/hamcrest-core/1.3-SNAPSHOT/1.3-20200717.093520-1/"), new BrowsePath("hamcrest-core-1.3-20200717.093520-1.jar", asset.path()))); }
@Test public void should_build_paths_for_asset_without_a_component() { AssetData asset = new AssetData(); asset.setPath("/com/sonatype/example/metadata.xml"); List<BrowsePath> browsePaths = underTest.computeAssetPaths(asset); assertThat(browsePaths.size(), is(4)); assertThat(browsePaths, containsInAnyOrder( new BrowsePath("com", "/com/"), new BrowsePath("sonatype", "/com/sonatype/"), new BrowsePath("example", "/com/sonatype/example/"), new BrowsePath("metadata.xml", asset.path()))); }