Search in sources :

Example 1 with ImmutableAttributesFactory

use of org.gradle.api.internal.attributes.ImmutableAttributesFactory in project gradle by gradle.

the class DefaultResolvedDependencyTest method createResolvedArtifact.

public static DefaultResolvedArtifact createResolvedArtifact(final Mockery context, final String name, final String type, final String extension, final File file) {
    final IvyArtifactName artifactStub = context.mock(IvyArtifactName.class, "artifact" + name);
    final ImmutableAttributesFactory factory = context.mock(ImmutableAttributesFactory.class);
    final BuildOperationExecutor buildOperationExecutor = context.mock(BuildOperationExecutor.class);
    context.checking(new Expectations() {

        {
            allowing(factory).builder(ImmutableAttributes.EMPTY);
            allowing(artifactStub).getName();
            will(returnValue(name));
            allowing(artifactStub).getType();
            will(returnValue(type));
            allowing(artifactStub).getExtension();
            will(returnValue(extension));
            allowing(artifactStub).getClassifier();
            will(returnValue(null));
        }
    });
    final Factory artifactSource = context.mock(Factory.class);
    context.checking(new Expectations() {

        {
            allowing(artifactSource).create();
            will(returnValue(file));
        }
    });
    final ResolvedDependency resolvedDependency = context.mock(ResolvedDependency.class);
    final ResolvedModuleVersion version = context.mock(ResolvedModuleVersion.class);
    context.checking(new Expectations() {

        {
            allowing(resolvedDependency).getModule();
            will(returnValue(version));
            allowing(version).getId();
            will(returnValue(new DefaultModuleVersionIdentifier("group", name, "1.2")));
        }
    });
    return new DefaultResolvedArtifact(resolvedDependency.getModule().getId(), artifactStub, context.mock(ComponentArtifactIdentifier.class), context.mock(TaskDependency.class), artifactSource);
}
Also used : Expectations(org.jmock.Expectations) TaskDependency(org.gradle.api.tasks.TaskDependency) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ResolvedModuleVersion(org.gradle.api.artifacts.ResolvedModuleVersion) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) Factory(org.gradle.internal.Factory) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) BuildOperationExecutor(org.gradle.internal.progress.BuildOperationExecutor)

Aggregations

ResolvedDependency (org.gradle.api.artifacts.ResolvedDependency)1 ResolvedModuleVersion (org.gradle.api.artifacts.ResolvedModuleVersion)1 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)1 ImmutableAttributesFactory (org.gradle.api.internal.attributes.ImmutableAttributesFactory)1 TaskDependency (org.gradle.api.tasks.TaskDependency)1 Factory (org.gradle.internal.Factory)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1 BuildOperationExecutor (org.gradle.internal.progress.BuildOperationExecutor)1 Expectations (org.jmock.Expectations)1