Search in sources :

Example 1 with ComponentMaintenance

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()));
}
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 2 with ComponentMaintenance

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));
}
Also used : ComponentMaintenance(org.sonatype.nexus.repository.storage.ComponentMaintenance) InputStream(java.io.InputStream) Component(org.sonatype.nexus.repository.storage.Component) Test(org.junit.Test)

Example 3 with ComponentMaintenance

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

Aggregations

Test (org.junit.Test)3 Component (org.sonatype.nexus.repository.storage.Component)3 ComponentMaintenance (org.sonatype.nexus.repository.storage.ComponentMaintenance)3 Asset (org.sonatype.nexus.repository.storage.Asset)2 InputStream (java.io.InputStream)1