Search in sources :

Example 6 with Archetype

use of org.apache.maven.archetype.catalog.Archetype in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testNoDefaultArchetype.

public void testNoDefaultArchetype() 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();
    Archetype archetype = queryer.selectArchetype(map);
    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) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with Archetype

use of org.apache.maven.archetype.catalog.Archetype in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testArchetypeFiltering.

public void testArchetypeFiltering() 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("set-artifactId");
    prompter.prompt("");
    control.setReturnValue("1");
    queryer.setPrompter(prompter);
    control.replay();
    Archetype archetype = queryer.selectArchetype(map);
    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) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) List(java.util.List) ArrayList(java.util.ArrayList)

Example 8 with Archetype

use of org.apache.maven.archetype.catalog.Archetype in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method createArchetype.

private static Archetype createArchetype(String groupId, String artifactId, String version) {
    Archetype a = new Archetype();
    a.setGroupId(groupId);
    a.setArtifactId(artifactId);
    a.setVersion(version);
    return a;
}
Also used : Archetype(org.apache.maven.archetype.catalog.Archetype)

Example 9 with Archetype

use of org.apache.maven.archetype.catalog.Archetype in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testDefaultArchetypeInMapOtherSelection.

public void testDefaultArchetypeInMapOtherSelection() throws PrompterException {
    Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
    MockControl control = MockControl.createControl(Prompter.class);
    Prompter prompter = (Prompter) control.getMock();
    prompter.prompt("", "2");
    control.setMatcher(createArgumentMatcher());
    control.setReturnValue("1");
    queryer.setPrompter(prompter);
    control.replay();
    ArchetypeDefinition defaultDefinition = new ArchetypeDefinition();
    defaultDefinition.setGroupId("default-groupId");
    defaultDefinition.setArtifactId("default-artifactId");
    defaultDefinition.setVersion("default-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 10 with Archetype

use of org.apache.maven.archetype.catalog.Archetype in project maven-archetype by apache.

the class DefaultArchetypeSelectorTest method testArchetypeNotInRequestDefaults.

public void testArchetypeNotInRequestDefaults() 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(), createDefaultArchetypeDefinition());
    control.setMatcher(createArgumentMatcher());
    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 : 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

Archetype (org.apache.maven.archetype.catalog.Archetype)30 ArchetypeCatalog (org.apache.maven.archetype.catalog.ArchetypeCatalog)12 File (java.io.File)10 List (java.util.List)10 ArrayList (java.util.ArrayList)8 ArchetypeGenerationRequest (org.apache.maven.archetype.ArchetypeGenerationRequest)8 Properties (java.util.Properties)7 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)7 MockControl (org.easymock.MockControl)7 ArchetypeCatalogXpp3Writer (org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer)6 UnknownArchetype (org.apache.maven.archetype.exception.UnknownArchetype)6 FileWriter (java.io.FileWriter)5 Writer (java.io.Writer)5 Map (java.util.Map)5 ArchetypeGenerationResult (org.apache.maven.archetype.ArchetypeGenerationResult)5 ArchetypeDefinition (org.apache.maven.archetype.ui.ArchetypeDefinition)5 Prompter (org.codehaus.plexus.components.interactivity.Prompter)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ArchetypeManager (org.apache.maven.archetype.ArchetypeManager)4