Search in sources :

Example 1 with ComponentUpload

use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method testHandleValidationExceptionWrongPath.

@Test
public void testHandleValidationExceptionWrongPath() throws IOException {
    ComponentUpload component = createComponentUpload(WRONG_PACKAGE_PATH, PACKAGE_NAME);
    checkValidationFailed(component, NOT_VALID_PATH_ERROR_MESSAGE);
}
Also used : ComponentUpload(org.sonatype.nexus.repository.upload.ComponentUpload) Test(org.junit.Test)

Example 2 with ComponentUpload

use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method testHandle.

@Test
public void testHandle() throws IOException {
    ComponentUpload component = createComponentUpload(PACKAGE_PATH, PACKAGE_NAME);
    UploadResponse uploadResponse = underTest.handle(repository, component);
    assertThat(uploadResponse.getAssetPaths(), contains(PACKAGE_PATH_FULL));
    assertThat(uploadResponse.getComponentId().getValue(), is(NU_ID));
    verify(contentPermissionChecker).isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), captor.capture());
    VariableSource source = captor.getValue();
    assertThat(source.get("format"), is(Optional.of(RFormat.NAME)));
    assertThat(source.get("path"), is(Optional.of(PACKAGE_PATH_FULL)));
}
Also used : ComponentUpload(org.sonatype.nexus.repository.upload.ComponentUpload) UploadResponse(org.sonatype.nexus.repository.upload.UploadResponse) VariableSource(org.sonatype.nexus.selector.VariableSource) Test(org.junit.Test)

Example 3 with ComponentUpload

use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method testHandle_unauthorized.

@Test
public void testHandle_unauthorized() throws IOException {
    when(contentPermissionChecker.isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), any())).thenReturn(false);
    ComponentUpload component = createComponentUpload(PACKAGE_PATH, PACKAGE_NAME);
    checkValidationFailed(component, String.format("Not authorized for requested path '%s'", PACKAGE_PATH_FULL));
}
Also used : ComponentUpload(org.sonatype.nexus.repository.upload.ComponentUpload) Test(org.junit.Test)

Example 4 with ComponentUpload

use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method createComponentUpload.

private ComponentUpload createComponentUpload(final String packagePath, final String packageName) {
    when(payload.getName()).thenReturn(packageName);
    ComponentUpload component = new ComponentUpload();
    AssetUpload asset = new AssetUpload();
    asset.setFields(Collections.singletonMap(RUploadHandler.PATH_ID, packagePath));
    asset.setPayload(payload);
    component.getAssetUploads().add(asset);
    return component;
}
Also used : ComponentUpload(org.sonatype.nexus.repository.upload.ComponentUpload) AssetUpload(org.sonatype.nexus.repository.upload.AssetUpload)

Example 5 with ComponentUpload

use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.

the class RUploadHandlerTest method testHandleValidationExceptionWrongExtension.

@Test
public void testHandleValidationExceptionWrongExtension() throws IOException {
    ComponentUpload component = createComponentUpload(PACKAGE_PATH, WRONG_PACKAGE_NAME);
    checkValidationFailed(component, NOT_VALID_EXTENSION_ERROR_MESSAGE);
}
Also used : ComponentUpload(org.sonatype.nexus.repository.upload.ComponentUpload) Test(org.junit.Test)

Aggregations

ComponentUpload (org.sonatype.nexus.repository.upload.ComponentUpload)5 Test (org.junit.Test)4 AssetUpload (org.sonatype.nexus.repository.upload.AssetUpload)1 UploadResponse (org.sonatype.nexus.repository.upload.UploadResponse)1 VariableSource (org.sonatype.nexus.selector.VariableSource)1