Question 1
Topic: Service Mapping Pattern Design
Skill tested: Designs robust pattern parsing operations for variable-format command output.
A Service Mapping implementation must identify a custom Java service on Linux hosts. Its command output contains a stable process identifier and executable path, but optional arguments and whitespace vary by release. The current pattern uses a single regular expression that captures the entire command line; recent releases cause false mismatches, and the team needs reliable values for later identification steps. The pattern must remain maintainable and should not depend on fixed column positions. Which design is most appropriate?
Capturing only stable fields with a regular expression avoids coupling the pattern to optional arguments and changing whitespace. Storing those captures as pattern variables makes them available to subsequent steps. A literal full-line match is brittle across releases, while fixed-width parsing assumes positional stability the scenario explicitly lacks. Removing arguments with a command-line transformation adds an unnecessary dependency and still leaves a fixed-string match susceptible to other formatting differences.