Search in sources :

Example 1 with ArchetypeArtifactManager

use of org.apache.maven.archetype.common.ArchetypeArtifactManager in project maven-archetype by apache.

the class DefaultArchetypeGenerationConfigurator2Test method setUp.

public void setUp() throws Exception {
    super.setUp();
    configurator = (DefaultArchetypeGenerationConfigurator) lookup(ArchetypeGenerationConfigurator.ROLE);
    ProjectBuildingRequest buildingRequest = null;
    // MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
    // repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepository.getBasedir() ) );
    // buildingRequest.setRepositorySession( repositorySession );
    // request.setProjectBuildingRequest( buildingRequest );
    MockControl control = MockControl.createControl(ArchetypeArtifactManager.class);
    control.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
    ArchetypeArtifactManager manager = (ArchetypeArtifactManager) control.getMock();
    manager.exists("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(true);
    manager.isFileSetArchetype("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(true);
    manager.isOldArchetype("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(false);
    manager.getFileSetArchetypeDescriptor("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    ArchetypeDescriptor descriptor = new ArchetypeDescriptor();
    RequiredProperty groupId = new RequiredProperty();
    groupId.setKey("groupId");
    groupId.setDefaultValue("com.example.${groupName}");
    RequiredProperty artifactId = new RequiredProperty();
    artifactId.setKey("artifactId");
    artifactId.setDefaultValue("${serviceName}");
    RequiredProperty thePackage = new RequiredProperty();
    thePackage.setKey("package");
    thePackage.setDefaultValue("com.example.${groupName}");
    RequiredProperty groupName = new RequiredProperty();
    groupName.setKey("groupName");
    groupName.setDefaultValue(null);
    RequiredProperty serviceName = new RequiredProperty();
    serviceName.setKey("serviceName");
    serviceName.setDefaultValue(null);
    descriptor.addRequiredProperty(groupId);
    descriptor.addRequiredProperty(artifactId);
    descriptor.addRequiredProperty(thePackage);
    descriptor.addRequiredProperty(groupName);
    descriptor.addRequiredProperty(serviceName);
    control.setReturnValue(descriptor);
    control.replay();
    configurator.setArchetypeArtifactManager(manager);
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) MockControl(org.easymock.MockControl) RequiredProperty(org.apache.maven.archetype.metadata.RequiredProperty) ArchetypeDescriptor(org.apache.maven.archetype.metadata.ArchetypeDescriptor) ArchetypeArtifactManager(org.apache.maven.archetype.common.ArchetypeArtifactManager)

Example 2 with ArchetypeArtifactManager

use of org.apache.maven.archetype.common.ArchetypeArtifactManager in project maven-archetype by apache.

the class DefaultArchetypeGenerationConfiguratorTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    configurator = (DefaultArchetypeGenerationConfigurator) lookup(ArchetypeGenerationConfigurator.ROLE);
    ProjectBuildingRequest buildingRequest = null;
    MockControl control = MockControl.createControl(ArchetypeArtifactManager.class);
    control.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
    ArchetypeArtifactManager manager = (ArchetypeArtifactManager) control.getMock();
    manager.exists("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(true);
    manager.isFileSetArchetype("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(false);
    manager.isOldArchetype("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(true);
    manager.getOldArchetypeDescriptor("archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null, buildingRequest);
    control.setReturnValue(new ArchetypeDescriptor());
    control.replay();
    configurator.setArchetypeArtifactManager(manager);
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) MockControl(org.easymock.MockControl) ArchetypeDescriptor(org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor) ArchetypeArtifactManager(org.apache.maven.archetype.common.ArchetypeArtifactManager)

Aggregations

ArchetypeArtifactManager (org.apache.maven.archetype.common.ArchetypeArtifactManager)2 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)2 MockControl (org.easymock.MockControl)2 ArchetypeDescriptor (org.apache.maven.archetype.metadata.ArchetypeDescriptor)1 RequiredProperty (org.apache.maven.archetype.metadata.RequiredProperty)1 ArchetypeDescriptor (org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor)1