Search in sources :

Example 1 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project unleash-maven-plugin by shillner.

the class ReleaseUtilTest method testGetReleaseVersion_Prompter.

@Test
@DataProvider({ "1-SNAPSHOT,null,4,4", "2-SNAPSHOT,8,4,8" })
public void testGetReleaseVersion_Prompter(String version, String defaultReleaseVersion, String userInput, String expected) throws Exception {
    Prompter prompter = Mockito.mock(Prompter.class);
    Mockito.when(prompter.prompt((String) Matchers.notNull(), (String) Matchers.notNull())).thenReturn(userInput);
    Assert.assertEquals(expected, ReleaseUtil.getReleaseVersion(version, Optional.fromNullable(defaultReleaseVersion), Optional.of(prompter)));
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 2 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter 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 3 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter 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 4 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter 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 5 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project unleash-maven-plugin by shillner.

the class ReleaseUtilTest method testGetNextDevelopmentVersion_Prompter.

@Test
@DataProvider({ "1-SNAPSHOT,null,4-SNAPSHOT,4-SNAPSHOT", "2-SNAPSHOT,8-SNAPSHOT,4-SNAPSHOT,8-SNAPSHOT" })
public void testGetNextDevelopmentVersion_Prompter(String version, String defaultReleaseVersion, String userInput, String expected) throws Exception {
    Prompter prompter = Mockito.mock(Prompter.class);
    Mockito.when(prompter.prompt((String) Matchers.notNull(), (String) Matchers.notNull())).thenReturn(userInput);
    Assert.assertEquals(expected, ReleaseUtil.getNextDevelopmentVersion(version, Optional.fromNullable(defaultReleaseVersion), Optional.of(prompter), VersionUpgradeStrategy.DEFAULT));
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Aggregations

Prompter (org.codehaus.plexus.components.interactivity.Prompter)9 MockControl (org.easymock.MockControl)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Archetype (org.apache.maven.archetype.catalog.Archetype)5 ArchetypeDefinition (org.apache.maven.archetype.ui.ArchetypeDefinition)3 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 Test (org.junit.Test)2 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)1 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)1 MavenProject (org.apache.maven.project.MavenProject)1