Class ScriptedIkePrompter

java.lang.Object
network.ike.plugin.support.ScriptedIkePrompter
All Implemented Interfaces:
IkePrompter

public final class ScriptedIkePrompter extends Object implements IkePrompter
Deterministic IkePrompter that replays a fixed script of answers (IKE-Network/ike-issues#385).

Primary use is unit-testing goals that prompt — construct one with the answers the test wants, inject it, and the goal runs without any real I/O. Each prompt / confirm / select call consumes the next scripted answer.

It is shipped (not test-scoped) so both plugins' test suites can share it.

  • Constructor Details

    • ScriptedIkePrompter

      public ScriptedIkePrompter(String... answers)
      Creates a prompter that replays the given answers in order.
      Parameters:
      answers - the answers each prompt call returns, in order
  • Method Details

    • isInteractive

      public boolean isInteractive()
      Description copied from interface: IkePrompter
      Whether an interactive input channel is available.

      False in genuine non-interactive contexts (Maven batch mode); a goal should then fail with a -D<param>= instruction rather than prompt.

      Specified by:
      isInteractive in interface IkePrompter
      Returns:
      true when prompting is possible
    • prompt

      public String prompt(String label)
      Description copied from interface: IkePrompter
      Prompts for a free-text line of input.
      Specified by:
      prompt in interface IkePrompter
      Parameters:
      label - the prompt label, including any trailing separator (e.g. "Commit message: ")
      Returns:
      the entered line (trimmed), or null if input was blank, end-of-stream, or not interactive
    • confirm

      public boolean confirm(String label, boolean defaultYes)
      Description copied from interface: IkePrompter
      Prompts for a yes/no confirmation.
      Specified by:
      confirm in interface IkePrompter
      Parameters:
      label - the question
      defaultYes - the answer assumed on blank input or a non-interactive context
      Returns:
      the user's choice, or defaultYes as the default
    • select

      public String select(String label, List<String> options)
      Description copied from interface: IkePrompter
      Prompts for a numbered selection from a list.
      Specified by:
      select in interface IkePrompter
      Parameters:
      label - the selection header
      options - the choices, rendered as a numbered list
      Returns:
      the chosen option, or null on invalid, blank, or non-interactive input