Search in sources :

Example 6 with ArchetypeDefinition

use of org.apache.maven.archetype.ui.ArchetypeDefinition in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testDefaultArchetypeNotInMap.

public void testDefaultArchetypeNotInMap() throws PrompterException {
    Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
    MockControl control = MockControl.createControl(Prompter.class);
    Prompter prompter = (Prompter) control.getMock();
    prompter.prompt("");
    control.setMatcher(createArgumentMatcher());
    control.setReturnValue("1");
    queryer.setPrompter(prompter);
    control.replay();
    ArchetypeDefinition defaultDefinition = new ArchetypeDefinition();
    defaultDefinition.setGroupId("invalid-groupId");
    defaultDefinition.setArtifactId("invalid-artifactId");
    defaultDefinition.setVersion("invalid-version");
    Archetype archetype = queryer.selectArchetype(map, defaultDefinition);
    control.verify();
    assertEquals("set-groupId", archetype.getGroupId());
    assertEquals("set-artifactId", archetype.getArtifactId());
    assertEquals("set-version", archetype.getVersion());
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) ArchetypeDefinition(org.apache.maven.archetype.ui.ArchetypeDefinition) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with ArchetypeDefinition

use of org.apache.maven.archetype.ui.ArchetypeDefinition in project maven-archetype by apache.

the class DefaultArchetypeSelectorTest method createDefaultArchetypeDefinition.

private ArchetypeDefinition createDefaultArchetypeDefinition() {
    ArchetypeDefinition definition = new ArchetypeDefinition();
    definition.setGroupId(DefaultArchetypeSelector.DEFAULT_ARCHETYPE_GROUPID);
    definition.setArtifactId(DefaultArchetypeSelector.DEFAULT_ARCHETYPE_ARTIFACTID);
    definition.setVersion(DefaultArchetypeSelector.DEFAULT_ARCHETYPE_VERSION);
    return definition;
}
Also used : ArchetypeDefinition(org.apache.maven.archetype.ui.ArchetypeDefinition)

Example 8 with ArchetypeDefinition

use of org.apache.maven.archetype.ui.ArchetypeDefinition in project maven-archetype by apache.

the class DefaultArchetypeSelectorTest method testArchetypeArtifactIdNotInRequest.

public void testArchetypeArtifactIdNotInRequest() throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype, ArchetypeNotDefined {
    ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
    MockControl control = MockControl.createControl(ArchetypeSelectionQueryer.class);
    ArchetypeSelectionQueryer queryer = (ArchetypeSelectionQueryer) control.getMock();
    queryer.selectArchetype(Collections.<String, List<Archetype>>emptyMap(), new ArchetypeDefinition());
    control.setMatcher(MockControl.ALWAYS_MATCHER);
    Archetype archetype = new Archetype();
    archetype.setArtifactId("set-artifactId");
    archetype.setGroupId("set-groupId");
    archetype.setVersion("set-version");
    control.setReturnValue(archetype);
    control.replay();
    selector.setArchetypeSelectionQueryer(queryer);
    selector.selectArchetype(request, Boolean.TRUE, "");
    control.verify();
    assertEquals("set-groupId", request.getArchetypeGroupId());
    assertEquals("set-artifactId", request.getArchetypeArtifactId());
    assertEquals("set-version", request.getArchetypeVersion());
}
Also used : ArchetypeDefinition(org.apache.maven.archetype.ui.ArchetypeDefinition) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) ArchetypeGenerationRequest(org.apache.maven.archetype.ArchetypeGenerationRequest)

Aggregations

ArchetypeDefinition (org.apache.maven.archetype.ui.ArchetypeDefinition)8 Archetype (org.apache.maven.archetype.catalog.Archetype)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 MockControl (org.easymock.MockControl)4 UnknownArchetype (org.apache.maven.archetype.exception.UnknownArchetype)3 Prompter (org.codehaus.plexus.components.interactivity.Prompter)3 Properties (java.util.Properties)2 ArchetypeNotConfigured (org.apache.maven.archetype.exception.ArchetypeNotConfigured)2 ArchetypeNotDefined (org.apache.maven.archetype.exception.ArchetypeNotDefined)2 ArchetypeConfiguration (org.apache.maven.archetype.ui.ArchetypeConfiguration)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ArchetypeGenerationRequest (org.apache.maven.archetype.ArchetypeGenerationRequest)1 ArchetypeGenerationConfigurationFailure (org.apache.maven.archetype.exception.ArchetypeGenerationConfigurationFailure)1 ArchetypeSelectionFailure (org.apache.maven.archetype.exception.ArchetypeSelectionFailure)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)1 VelocityContext (org.apache.velocity.VelocityContext)1