BuildrDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return coordinates.getGroupId() + ":" + coordinates.getArtifactId() + ":" + coordinates.getExtension() + ":" + (coordinates.getClassifier() != null ? coordinates.getClassifier() + ":": "") + coordinates.getVersion(); }  @PostConstruct @Override void register(); @Override String getLayout(); @Override String getFormatAlias(); @Override String getDependencySnippet(ArtifactCoordinates artifactCoordinates); static final String ALIAS; }
@Test public void testBuildrDependencyGeneration() throws ProviderImplementationException { DependencySynonymFormatter formatter = compatibleDependencyFormatRegistry.getProviderImplementation(Maven2LayoutProvider.ALIAS, BuildrDependencyFormatter.ALIAS); assertThat(formatter).as("Failed to look up dependency synonym formatter!").isNotNull(); coordinates.setExtension("jar"); String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat(snippet) .as("Failed to generate dependency!") .isEqualTo("org.carlspring.strongbox:maven-snippet:jar:1.0"); }
@Test public void testBuildrDependencyGenerationWithClassifier() throws ProviderImplementationException { DependencySynonymFormatter formatter = compatibleDependencyFormatRegistry.getProviderImplementation(Maven2LayoutProvider.ALIAS, BuildrDependencyFormatter.ALIAS); assertThat(formatter).as("Failed to look up dependency synonym formatter!").isNotNull(); coordinates.setExtension("jar"); coordinates.setClassifier("jdk12"); String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat(snippet) .as("Failed to generate dependency!") .isEqualTo("org.carlspring.strongbox:maven-snippet:jar:jdk12:1.0"); }
@Test public void testBuildrDependencyGenerationWithNonStandardType() throws ProviderImplementationException { DependencySynonymFormatter formatter = compatibleDependencyFormatRegistry.getProviderImplementation(Maven2LayoutProvider.ALIAS, BuildrDependencyFormatter.ALIAS); assertThat(formatter).as("Failed to look up dependency synonym formatter!").isNotNull(); coordinates.setExtension("zip"); String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat(snippet) .as("Failed to generate dependency!") .isEqualTo("org.carlspring.strongbox:maven-snippet:zip:1.0"); }