### Question:
SubroutineDefinitionParser { public SubroutineDefinition parse(final String subroutineDefinition) { if (subroutineDefinition == null) { throw new IllegalArgumentException("Subroutine definition cannot be null."); } final EtmPoint point = PointFactory.getPoint(getClass(), "parse(String)"); try { return new SubroutineDefinition(parseSubroutineName(subroutineDefinition), parseArgumentNames(subroutineDefinition)); } finally { point.collect(); } }  SubroutineDefinition parse(final String subroutineDefinition);  }### Answer:
@Test public void testParse() { final SubroutineDefinition definition = parser.parse("subroutine get_last_name(person_id, birth_dt_tm)"); assertThat(definition.getName()).isEqualTo("get_last_name"); assertThat(definition.getArgumentNames()).containsExactly("person_id", "birth_dt_tm"); }
@Test public void testParseNoClosingParenthesis() { final String subroutineDefinition = "subroutine no_closing_paren(arg1"; InvalidSubroutineException e = assertThrows(InvalidSubroutineException.class, () -> { parser.parse(subroutineDefinition); }); assertThat(e.getMessage()) .isEqualTo("Unable to find closing parenthesis after open parenthesis: " + subroutineDefinition); }
@Test public void testParseNoOpeningParenthesis() { final String subroutineDefinition = "subroutine no_open_parenthesis"; InvalidSubroutineException e = assertThrows(InvalidSubroutineException.class, () -> { parser.parse(subroutineDefinition); }); assertThat(e.getMessage()) .isEqualTo("Unable to find opening parenthesis in definition: " + subroutineDefinition); }
@Test public void testParseNoSubroutineKeyword() { final String subroutineDefinition = "no_subroutine_keyword"; InvalidSubroutineException e = assertThrows(InvalidSubroutineException.class, () -> { parser.parse(subroutineDefinition); }); assertThat(e.getMessage()) .isEqualTo("Unable to retrieve subroutine name from definition: " + subroutineDefinition); }
@Test public void testParseNullArguments() { final SubroutineDefinition definition = parser.parse("subroutine no_arguments(null)"); assertThat(definition.getName()).isEqualTo("no_arguments"); assertThat(definition.getArgumentNames()).isEmpty(); }
@Test public void testParseNullDefinition() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { parser.parse(null); }); assertThat(e.getMessage()).isEqualTo("Subroutine definition cannot be null."); }
@Test public void testParsePrecedingOpenParenthesis() { final String subroutineDefinition = "(subroutine preceding_parenthesis("; InvalidSubroutineException e = assertThrows(InvalidSubroutineException.class, () -> { parser.parse(subroutineDefinition); }); assertThat(e.getMessage()) .isEqualTo("Opening parenthesis precedes the subroutine keyword: " + subroutineDefinition); }