@Test public void testChallenges() { for (String[] challenge : challenges()) { Optional<String> result = VerificationCodeParser.parse(challenge[0]); assertTrue(result.isPresent()); assertEquals(challenge[1], result.get()); } }
public static Optional<String> parse(String messageBody) { if (messageBody == null) { return Optional.absent(); } Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody); if (!challengeMatcher.matches()) { return Optional.absent(); } return Optional.of(challengeMatcher.group(challengeMatcher.groupCount() - 1) + challengeMatcher.group(challengeMatcher.groupCount())); }
VerificationCodeParser { public static Optional<String> parse(String messageBody) { if (messageBody == null) { return Optional.absent(); } Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody); if (!challengeMatcher.matches()) { return Optional.absent(); } return Optional.of(challengeMatcher.group(challengeMatcher.groupCount() - 1) + challengeMatcher.group(challengeMatcher.groupCount())); } }
VerificationCodeParser { public static Optional<String> parse(String messageBody) { if (messageBody == null) { return Optional.absent(); } Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody); if (!challengeMatcher.matches()) { return Optional.absent(); } return Optional.of(challengeMatcher.group(challengeMatcher.groupCount() - 1) + challengeMatcher.group(challengeMatcher.groupCount())); }  }
VerificationCodeParser { public static Optional<String> parse(String messageBody) { if (messageBody == null) { return Optional.absent(); } Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody); if (!challengeMatcher.matches()) { return Optional.absent(); } return Optional.of(challengeMatcher.group(challengeMatcher.groupCount() - 1) + challengeMatcher.group(challengeMatcher.groupCount())); }  static Optional<String> parse(String messageBody); }
VerificationCodeParser { public static Optional<String> parse(String messageBody) { if (messageBody == null) { return Optional.absent(); } Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody); if (!challengeMatcher.matches()) { return Optional.absent(); } return Optional.of(challengeMatcher.group(challengeMatcher.groupCount() - 1) + challengeMatcher.group(challengeMatcher.groupCount())); }  static Optional<String> parse(String messageBody);  }