本文整理汇总了Java中org.codehaus.plexus.components.interactivity.Prompter类的典型用法代码示例。如果您正苦于以下问题:Java Prompter类的具体用法?Java Prompter怎么用?Java Prompter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Prompter类属于org.codehaus.plexus.components.interactivity包,在下文中一共展示了Prompter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: promptForContainer
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
/**
* Lists services and prompts the user to choose one
*/
private static Container promptForContainer(List<Container> containers, Prompter prompter, Log log) throws MojoExecutionException {
log.info("");
log.info("SERVICE");
log.info("");
Map<Integer, Container> options = new HashMap<>();
Integer i = 1;
for (Container container : containers) {
options.put(i, container);
log.info(String.format("%2d", i) + " : " + container.getServiceName());
i++;
}
log.info("");
try {
String prompt = prompter.prompt("Choose a service");
return options.get(Integer.valueOf(prompt));
}
catch (PrompterException e) {
throw new MojoExecutionException("Prompter error" + e.getMessage());
}
}
开发者ID:swissquote,项目名称:carnotzet,代码行数:26,代码来源:Shell.java
示例2: getReleaseVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
/**
* Calculates the release version depending on several strategies such as prompting the user or applying a default
* version.
*
* @param version the initial version from which the release version shall be derived.
* @param defaultReleaseVersion the default release version that should be taken into account.
* @param prompter a {@link Prompter} for prompting the user for a release version.
* @return the release version derived after applying several calculation strategies.
*/
public static String getReleaseVersion(String version, Optional<String> defaultReleaseVersion,
Optional<Prompter> prompter) {
if (defaultReleaseVersion.isPresent()) {
return defaultReleaseVersion.get();
}
String releaseVersion = MavenVersionUtil.calculateReleaseVersion(version);
if (prompter.isPresent()) {
try {
releaseVersion = prompter.get().prompt("Please specify the release version", releaseVersion);
} catch (PrompterException e) {
// in case of an error the calculated version is used
}
}
return releaseVersion;
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:27,代码来源:ReleaseUtil.java
示例3: getNextDevelopmentVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
/**
* Calculates the next development version depending on several strategies such as prompting the user or applying a
* default
* version.
*
* @param version the initial version from which the development version shall be derived.
* @param defaultDevelopmentVersion the default development version that should be taken into account.
* @param prompter a {@link Prompter} for prompting the user for a version.
* @param upgradeStrategy the strategy which determines the version segment to increase.
* @return the development version derived after applying several calculation strategies.
*/
public static String getNextDevelopmentVersion(String version, Optional<String> defaultDevelopmentVersion,
Optional<Prompter> prompter, VersionUpgradeStrategy upgradeStrategy) {
if (defaultDevelopmentVersion.isPresent()) {
return defaultDevelopmentVersion.get();
}
String devVersion = MavenVersionUtil.calculateNextSnapshotVersion(version, upgradeStrategy);
if (prompter.isPresent()) {
try {
devVersion = prompter.get().prompt("Please specify the next development version", devVersion);
} catch (PrompterException e) {
// in case of an error the calculated version is used
}
}
return devVersion;
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:29,代码来源:ReleaseUtil.java
示例4: setUp
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
objectUnderTest = new UsageStatisticsManager() {
@Override
protected HttpURLConnection openUrlConnection() throws IOException {
super.openUrlConnection(); // cover this ;)
return urlConnectionMock;
}
};
MavenRuntime mavenRuntimeMock = mock(MavenRuntime.class);
when(mavenRuntimeMock.getProjectProperties(any(Class.class))).thenReturn(
new MavenProjectProperties("de.is24", "junit", "42.23"));
setVariableValueInObject(objectUnderTest, "mavenRuntime", mavenRuntimeMock);
Prompter prompterMock = mock(Prompter.class);
when(prompterMock.prompt(anyString(), anyList(), anyString())).thenReturn("N");
setVariableValueInObject(objectUnderTest, "prompter", prompterMock);
givenHttpTransferResultsIn(200);
}
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:21,代码来源:A_UsageStatisticsManager.java
示例5: execute
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
public static void execute(ContainerOrchestrationRuntime runtime, Prompter prompter, Log log, String service)
throws MojoExecutionException, MojoFailureException {
List<Container> containers = runtime.getContainers();
if (containers.isEmpty()) {
log.info("There doesn't seem to be any containers created yet for this carnotzet, please make sure the carnotzet is started");
return;
}
Container container = containers.stream().filter(c -> c.getServiceName().equals(service)).findFirst().orElse(null);
if (container == null) {
container = promptForContainer(containers, prompter, log);
}
runtime.shell(container);
}
开发者ID:swissquote,项目名称:carnotzet,代码行数:15,代码来源:Shell.java
示例6: execute
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Calculating required versions for all modules.");
for (MavenProject project : this.reactorProjects) {
this.log.info("\tVersions of module " + ProjectToString.EXCLUDE_VERSION.apply(project) + ":");
ArtifactCoordinates preReleaseCoordinates = this.metadata
.getArtifactCoordinatesByPhase(project.getGroupId(), project.getArtifactId()).get(ReleasePhase.PRE_RELEASE);
this.log.info("\t\t" + ReleasePhase.PRE_RELEASE + " = " + preReleaseCoordinates.getVersion());
Optional<Prompter> prompterToUse = this.settings.isInteractiveMode() ? Optional.of(this.prompter)
: Optional.<Prompter> absent();
String releaseVersion = calculateReleaseVersion(project.getVersion(), prompterToUse);
ArtifactCoordinates releaseCoordinates = new ArtifactCoordinates(project.getGroupId(), project.getArtifactId(),
releaseVersion, PomUtil.ARTIFACT_TYPE_POM);
this.metadata.addArtifactCoordinates(releaseCoordinates, ReleasePhase.RELEASE);
this.log.info("\t\t" + ReleasePhase.RELEASE + " = " + releaseVersion);
String nextDevVersion = calculateDevelopmentVersion(project.getVersion(), prompterToUse);
ArtifactCoordinates postReleaseCoordinates = new ArtifactCoordinates(project.getGroupId(),
project.getArtifactId(), nextDevVersion, PomUtil.ARTIFACT_TYPE_POM);
this.metadata.addArtifactCoordinates(postReleaseCoordinates, ReleasePhase.POST_RELEASE);
this.log.info("\t\t" + ReleasePhase.POST_RELEASE + " = " + nextDevVersion);
}
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:28,代码来源:CalculateVersions.java
示例7: calculateReleaseVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
private String calculateReleaseVersion(String version, Optional<Prompter> prompter) {
if (!MavenVersionUtil.isSnapshot(version) && this.preserveFixedModuleVersions) {
return version;
}
return ReleaseUtil.getReleaseVersion(version, Optional.fromNullable(this.defaultReleaseVersion), prompter);
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:8,代码来源:CalculateVersions.java
示例8: calculateDevelopmentVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
private String calculateDevelopmentVersion(String version, Optional<Prompter> prompter) {
if (!MavenVersionUtil.isSnapshot(version) && this.preserveFixedModuleVersions) {
return version;
}
return ReleaseUtil.getNextDevelopmentVersion(version, Optional.fromNullable(this.defaultDevelopmentVersion),
prompter, this.upgradeStrategy);
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:8,代码来源:CalculateVersions.java
示例9: testGetReleaseVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@Test
@DataProvider({ "1-SNAPSHOT,null,1", "1.0.0-SNAPSHOT,null,1.0.0", "3.1,null,3.1", "3.Alpha1-SNAPSHOT,null,3.Alpha1",
"2.4,3,3", "2.1-SNAPSHOT,3,3" })
public void testGetReleaseVersion(String version, String defaultReleaseVersion, String expected) {
Assert.assertEquals(expected, ReleaseUtil.getReleaseVersion(version, Optional.fromNullable(defaultReleaseVersion),
Optional.<Prompter> absent()));
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:8,代码来源:ReleaseUtilTest.java
示例10: testGetReleaseVersion_Prompter
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@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)));
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:10,代码来源:ReleaseUtilTest.java
示例11: testGetNextDevelopmentVersion
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@Test
@DataProvider({ "1-SNAPSHOT,null,2-SNAPSHOT", "1.0.0-SNAPSHOT,null,1.0.1-SNAPSHOT", "3.1,null,3.2-SNAPSHOT",
"3.Alpha1-SNAPSHOT,null,3.Alpha2-SNAPSHOT", "2.4,3-SNAPSHOT,3-SNAPSHOT",
"2.1.Alpha-SNAPSHOT,null,2.2.Alpha-SNAPSHOT" })
public void testGetNextDevelopmentVersion(String version, String defaultDevVersion, String expected) {
Assert.assertEquals(expected, ReleaseUtil.getNextDevelopmentVersion(version,
Optional.fromNullable(defaultDevVersion), Optional.<Prompter> absent(), VersionUpgradeStrategy.DEFAULT));
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:9,代码来源:ReleaseUtilTest.java
示例12: testGetNextDevelopmentVersion_Prompter
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
@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));
}
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:10,代码来源:ReleaseUtilTest.java
示例13: givenUserAgreesToSendStatistics
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
private void givenUserAgreesToSendStatistics(String comment) throws IllegalAccessException, PrompterException {
Prompter mock = mock(Prompter.class);
when(mock.prompt(anyString(), anyList(), anyString())).thenReturn("Y");
if (comment != null) {
when(mock.prompt(anyString())).thenReturn(comment);
}
setVariableValueInObject(objectUnderTest, "prompter", mock);
}
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:9,代码来源:A_UsageStatisticsManager.java
示例14: givenPrompterFails
import org.codehaus.plexus.components.interactivity.Prompter; //导入依赖的package包/类
private void givenPrompterFails() throws IllegalAccessException, PrompterException {
Prompter mock = mock(Prompter.class);
when(mock.prompt(anyString(), anyList(), anyString())).thenThrow(new PrompterException("Prompt You!"));
setVariableValueInObject(objectUnderTest, "prompter", mock);
}
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:6,代码来源:A_UsageStatisticsManager.java
注:本文中的org.codehaus.plexus.components.interactivity.Prompter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论