Search in sources :

Example 16 with Asset

use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method setup.

@Before
public void setup() throws IOException {
    when(contentPermissionChecker.isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), any())).thenReturn(true);
    underTest = new RUploadHandler(new SimpleVariableResolverAdapter(), contentPermissionChecker, emptySet());
    when(repository.getName()).thenReturn(REPO_NAME);
    when(storageFacet.txSupplier()).thenReturn(() -> storageTx);
    when(repository.facet(StorageFacet.class)).thenReturn(storageFacet);
    when(repository.facet(RHostedFacet.class)).thenReturn(rHostedFacet);
    Asset asset = mockAsset(PACKAGE_PATH_FULL);
    when(rHostedFacet.upload(PACKAGE_PATH_FULL, payload)).thenReturn(asset);
}
Also used : Asset(org.sonatype.nexus.repository.storage.Asset) SimpleVariableResolverAdapter(org.sonatype.nexus.repository.security.internal.SimpleVariableResolverAdapter) Before(org.junit.Before)

Example 17 with Asset

use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.

the class RHostedIT method testDeletingComponentDeletesAllAssociatedAssets.

@Test
public void testDeletingComponentDeletesAllAssociatedAssets() {
    final Asset asset = findAsset(repository, AGRICOLAE_121_TARGZ.fullPath);
    assertNotNull(asset);
    assertNotNull(asset.componentId());
    final Component component = findComponentById(repository, asset.componentId());
    assertNotNull(component);
    ComponentMaintenance maintenanceFacet = repository.facet(ComponentMaintenance.class);
    maintenanceFacet.deleteComponent(component.getEntityMetadata().getId(), true);
    assertThat(componentAssetTestHelper.assetExists(repository, AGRICOLAE_121_TARGZ.fullPath), is(false));
    assertNull(findComponentById(repository, asset.componentId()));
}
Also used : ComponentMaintenance(org.sonatype.nexus.repository.storage.ComponentMaintenance) Asset(org.sonatype.nexus.repository.storage.Asset) Component(org.sonatype.nexus.repository.storage.Component) Test(org.junit.Test)

Example 18 with Asset

use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.

the class RProxyIT method fetchMetaData.

@Test
public void fetchMetaData() throws Exception {
    assertSuccessResponseMatches(client.fetch(PACKAGES_SRC_GZ.fullPath), PACKAGES_SRC_GZ.filename);
    final Asset assetPackagesGz = findAsset(repository, PACKAGES_SRC_GZ.fullPath);
    Assert.assertEquals(PACKAGES_SRC_GZ.fullPath, assetPackagesGz.name());
    Assert.assertThat(assetPackagesGz.contentType(), is(equalTo(PACKAGES_SRC_GZ.contentType)));
    Assert.assertThat(assetPackagesGz.format(), is(equalTo(R_FORMAT_NAME)));
    Assert.assertThat(assetPackagesGz.attributes().child(R_FORMAT_NAME).get(P_ASSET_KIND), is(equalTo(PACKAGES_KIND)));
    assertSuccessResponseMatches(client.fetch(PACKAGES_RDS.fullPath), PACKAGES_RDS.filename);
    final Asset assetPackagesRds = findAsset(repository, PACKAGES_RDS.fullPath);
    Assert.assertEquals(PACKAGES_RDS.fullPath, assetPackagesRds.name());
    Assert.assertThat(assetPackagesRds.contentType(), is(equalTo(PACKAGES_RDS.contentType)));
    Assert.assertThat(assetPackagesRds.format(), is(equalTo(R_FORMAT_NAME)));
    Assert.assertThat(assetPackagesRds.attributes().child(R_FORMAT_NAME).get(P_ASSET_KIND), is(equalTo(PACKAGES_KIND)));
    assertSuccessResponseMatches(client.fetch(ARCHIVE_RDS.fullPath), ARCHIVE_RDS.filename);
    final Asset assetArchiveRds = findAsset(repository, ARCHIVE_RDS.fullPath);
    Assert.assertEquals(ARCHIVE_RDS.fullPath, assetArchiveRds.name());
    Assert.assertThat(assetArchiveRds.contentType(), is(equalTo(ARCHIVE_RDS.contentType)));
    Assert.assertThat(assetArchiveRds.format(), is(equalTo(R_FORMAT_NAME)));
    Assert.assertThat(assetArchiveRds.attributes().child(R_FORMAT_NAME).get(P_ASSET_KIND), is(equalTo(RDS_METADATA_KIND)));
}
Also used : Asset(org.sonatype.nexus.repository.storage.Asset) Test(org.junit.Test)

Example 19 with Asset

use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.

the class RProxyIT method fetchTgzPackageFile.

@Test
public void fetchTgzPackageFile() throws Exception {
    assertSuccessResponseMatches(client.fetch(AGRICOLAE_131_TGZ.fullPath), AGRICOLAE_131_TGZ.filename);
    final Asset asset = findAsset(repository, AGRICOLAE_131_TGZ.fullPath);
    Assert.assertThat(asset.name(), is(equalTo(AGRICOLAE_131_TGZ.fullPath)));
    Assert.assertThat(asset.contentType(), is(equalTo(CONTENT_TYPE_X_TGZ)));
    Assert.assertThat(asset.format(), is(equalTo(R_FORMAT_NAME)));
}
Also used : Asset(org.sonatype.nexus.repository.storage.Asset) Test(org.junit.Test)

Example 20 with Asset

use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.

the class RProxyIT method testDeletingRemainingAssetAlsoDeletesComponent.

@Test
public void testDeletingRemainingAssetAlsoDeletesComponent() throws IOException {
    client.fetch(AGRICOLAE_131_TGZ.fullPath);
    final Asset asset = findAsset(repository, AGRICOLAE_131_TGZ.fullPath);
    assertNotNull(asset);
    assertNotNull(asset.componentId());
    componentAssetTestHelper.removeAsset(repository, AGRICOLAE_131_TGZ.fullPath);
    assertNull(findAsset(repository, AGRICOLAE_131_TGZ.fullPath));
    assertNull(findComponentById(repository, asset.componentId()));
}
Also used : Asset(org.sonatype.nexus.repository.storage.Asset) Test(org.junit.Test)

Aggregations

Asset (org.sonatype.nexus.repository.storage.Asset)35 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)17 Component (org.sonatype.nexus.repository.storage.Component)13 Test (org.junit.Test)10 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset)10 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset)8 TransactionalStoreBlob (org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)8 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.RFacetUtils.findAsset)7 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.RFacetUtils.saveAsset)7 InputStream (java.io.InputStream)6 RFacet (org.sonatype.nexus.repository.r.RFacet)6 TransactionalTouchBlob (org.sonatype.nexus.repository.transaction.TransactionalTouchBlob)6 Bucket (org.sonatype.nexus.repository.storage.Bucket)5 TransactionalTouchMetadata (org.sonatype.nexus.repository.transaction.TransactionalTouchMetadata)4 BrowsePaths (org.sonatype.nexus.repository.browse.BrowsePaths)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 Map (java.util.Map)2 NestedAttributesMap (org.sonatype.nexus.common.collect.NestedAttributesMap)2 RHostedFacet (org.sonatype.nexus.repository.r.RHostedFacet)2