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);
}
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()));
}
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)));
}
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)));
}
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()));
}
Aggregations