use of org.sonatype.nexus.repository.storage.ComponentMaintenance 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.ComponentMaintenance in project nexus-repository-r by sonatype-nexus-community.
the class RHostedIT method testMetadataProcessing.
@Test
public void testMetadataProcessing() throws Exception {
// Uploading package with same name and lower version that should be skipped in src metadata
uploadSinglePackage(AGRICOLAE_101_TARGZ);
Thread.sleep(METADATA_PROCESSING_WAIT_INTERVAL_MILLIS);
final String agricolae121Content = new String(Files.readAllBytes(testData.resolveFile(PACKAGES_AGRICOLAE_121_FILENAME).toPath()));
final String agricolae131Content = new String(Files.readAllBytes(testData.resolveFile(PACKAGES_AGRICOLAE_131_FILENAME).toPath()));
// Verify PACKAGES(metadata) contain appropriate content about source R package (version 1.0-1 is skipped)
final InputStream contentSrc = client.fetch(PACKAGES_SRC_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo(agricolae121Content)), contentSrc);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_SRC_GZ.fullPath), is(true));
// Verify PACKAGES(metadata) contain appropriate content about bin R package
final InputStream contentBin = client.fetch(PACKAGES_BIN_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo(agricolae131Content)), contentBin);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_BIN_GZ.fullPath), is(true));
// Verify PACKAGES(metadata) is clean if component has been deleted
ComponentMaintenance maintenanceFacet = repository.facet(ComponentMaintenance.class);
final List<Component> allComponents = RITSupport.getAllComponents(repository);
allComponents.stream().forEach(component -> maintenanceFacet.deleteComponent(component.getEntityMetadata().getId(), true));
Thread.sleep(METADATA_PROCESSING_WAIT_INTERVAL_MILLIS);
final InputStream contentSrcAfterDelete = client.fetch(PACKAGES_SRC_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo("")), contentSrcAfterDelete);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_SRC_GZ.fullPath), is(true));
final InputStream contentBinAfterDelete = client.fetch(PACKAGES_BIN_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo("")), contentBinAfterDelete);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_BIN_GZ.fullPath), is(true));
}
use of org.sonatype.nexus.repository.storage.ComponentMaintenance in project nexus-repository-r by sonatype-nexus-community.
the class RProxyIT method testDeletingComponentDeletesAllAssociatedAssets.
@Test
public void testDeletingComponentDeletesAllAssociatedAssets() throws IOException {
client.fetch(AGRICOLAE_131_TGZ.fullPath);
final Asset asset = findAsset(repository, AGRICOLAE_131_TGZ.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);
assertNull(findAsset(repository, AGRICOLAE_131_TGZ.fullPath));
assertNull(findComponentById(repository, asset.componentId()));
}
Aggregations