NpmDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { NpmArtifactCoordinates coordinates = (NpmArtifactCoordinates) artifactCoordinates; String sb = (coordinates.getScope() != null ? "\"" + coordinates.getScope() + "/" : "\"") + "" + coordinates.getName() + "\" : " + "\"" + coordinates.getVersion() + "\"\n"; return sb; }  @PostConstruct @Override void register(); @Override String getLayout(); @Override String getFormatAlias(); @Override String getDependencySnippet(ArtifactCoordinates artifactCoordinates); static final String ALIAS; }
@Test public void testNpmDependencyGenerationWithoutScope() { NpmArtifactCoordinates coordinates = new NpmArtifactCoordinates(); coordinates.setId("angular"); coordinates.setVersion("1.6.7"); String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat("\"angular\" : \"1.6.7\"\n") .as("Failed to generate dependency!") .isEqualTo(snippet); }
@Test public void testNpmDependencyGenerationWithScope() { NpmArtifactCoordinates coordinates = new NpmArtifactCoordinates(); coordinates.setId("angular"); coordinates.setVersion("1.6.7"); coordinates.setScope("@carlspring"); String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat("\"@carlspring/angular\" : \"1.6.7\"\n") .as("Failed to generate dependency!") .isEqualTo(snippet); }