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)));
}
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());
}
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());
}
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());
}
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));
}
Aggregations