Java Code Examples for org.sonatype.nexus.repository.storage.Component#name()
The following examples show how to use
org.sonatype.nexus.repository.storage.Component#name() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@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); }
Example 2
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@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); }
Example 3
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeComponentPathNoGroup() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("name/1.0.0/name-1.0.0.jar"); Component component = new DefaultComponent(); component.name("name"); component.version("1.0.0"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertPaths(asList(component.name(), component.version()), paths, true); }
Example 4
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeComponentPath() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("group/name/1.0.0/name-1.0.0.jar"); Component component = new DefaultComponent(); component.group("group"); component.name("name"); component.version(baseVersion); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertPaths(asList(component.group(), component.name(), component.version()), paths, true); }
Example 5
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeSnapshotComponentPath() { String baseVersion = "1.0.0-SNAPSHOT"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("group/name/1.0.0-SNAPSHOT/name-1.0.0-20171213.212030-158.jar"); Component component = new DefaultComponent(); component.group("group"); component.name("name"); component.version("1.0.0-20171213.212030-158"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertSNAPSHOTPaths(asList(component.group(), component.name(), baseVersion, component.version()), paths, true); }
Example 6
Source File: OrientBrowseNodeManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Component createComponent(final String name, final String group, final String version, final String componentId) { EntityMetadata metadata = mock(EntityMetadata.class); when(metadata.getId()).thenReturn(new DetachedEntityId(componentId)); Component component = new DefaultComponent(); component.name(name); component.group(group); component.version(version); component.setEntityMetadata(metadata); when(componentStore.read(EntityHelper.id(component))).thenReturn(component); return component; }
Example 7
Source File: ComponentComponentTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private Component makeTestComponent(final String format) { Component component = new DefaultComponent(); component.setEntityMetadata(new DetachedEntityMetadata( new DetachedEntityId("testComponentId"), new DetachedEntityVersion("1.0") )); component.format(format); component.group("testGroup"); component.name("testComponentName"); return component; }
Example 8
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void computeComponentPathNameOnly() { Asset asset = createAsset("name/name.jar"); Component component = new DefaultComponent(); component.name("name"); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertPaths(singletonList(component.name()), paths, true); }
Example 9
Source File: BrowseTestSupport.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
protected Component createComponent(final String name, final String group, final String version) { Component component = new DefaultComponent(); component.name(name); component.group(group); component.version(version); return component; }
Example 10
Source File: OrientPyPiFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override public Asset putPackage(final String path, final AssetBlob assetBlob) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(getRepository()); Asset asset = findAsset(tx, bucket, path); if (asset == null) { final String filename = extractFilenameFromPath(path); Map<String, String> attributes; try (InputStream is = assetBlob.getBlob().getInputStream()) { attributes = extractMetadata(is); } if (!attributes.containsKey(P_NAME)) { log.debug("No name found in metadata for {}, extracting from filename.", filename); attributes.put(P_NAME, normalizeName(extractNameFromFilename(filename))); } if (!attributes.containsKey(P_VERSION)) { log.debug("No version found in metadata for {}, extracting from filename.", filename); attributes.put(P_VERSION, extractVersionFromFilename(filename)); } final String name = attributes.get(P_NAME); final String version = attributes.get(P_VERSION); Component component = findComponent(tx, getRepository(), name, version); if (component == null) { component = tx.createComponent(bucket, getRepository().getFormat()); component.name(name); component.version(version); component.formatAttributes().set(P_SUMMARY, attributes.get(P_SUMMARY)); tx.saveComponent(component); } asset = tx.createAsset(bucket, component); asset.name(path); copyAttributes(asset, attributes); saveAsset(tx, asset, assetBlob, AssetKind.PACKAGE); } return asset; }