OrientMaven2BrowseNodeGenerator extends ComponentPathBrowseNodeGenerator { @Override public List<BrowsePaths> computeAssetPaths(final Asset asset, @Nullable final Component component) { checkNotNull(asset); if (component != null) { List<BrowsePaths> paths = computeComponentPaths(asset, component); String lastSegment = lastSegment(asset.name()); BrowsePaths.appendPath(paths, lastSegment); return paths; } else { return super.computeAssetPaths(asset, null); } }  @Override List<BrowsePaths> computeAssetPaths(final Asset asset, @Nullable final Component component); @Override List<BrowsePaths> computeComponentPaths(final Asset asset, final Component component);  }
@Test public void computeAssetPathForAssetWithoutComponent() { Asset asset = createAsset("com/sonatype/example/metadata.xml"); List<BrowsePaths> paths = generator.computeAssetPaths(asset, null); assertPaths(asList("com", "sonatype", "example", "metadata.xml"), paths); }
@Test public void computeAssetPathForAssetWithComponent() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("com/sonatype/example/1.0.0/example-1.0.0.jar"); Component component = new DefaultComponent(); component.group("com.sonatype"); component.name("example"); component.version(baseVersion); component.attributes(attributes); List<BrowsePaths> paths = generator.computeAssetPaths(asset, component); assertPaths(asList("com", "sonatype", "example", "1.0.0", "example-1.0.0.jar"), paths); }
@Test public void computeAssetPathForSnapshotAssetWithComponent() { String baseVersion = "1.0-SNAPSHOT"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("org/foo/bar/example/1.0-SNAPSHOT/example-1.0-20171213.212030-158.jar"); Component component = new DefaultComponent(); component.group("org.foo.bar"); component.name("example"); component.version("1.0-20171213.212030-158"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeAssetPaths(asset, component); assertSNAPSHOTPaths(asList("org", "foo", "bar", "example", "1.0-SNAPSHOT", "1.0-20171213.212030-158", "example-1.0-20171213.212030-158.jar"), paths, false); }