@Test public void create_a_result_when_parsing_finished() throws Exception { String result = "result"; elementCreator.onParsed(result); assertThat(elementCreator.getResult()).isEqualTo(result); }
@Test public void not_cache_result_after_a_result_is_popped() throws Exception { elementCreator.onParsed("ignore"); elementCreator.popResult(); Object actual = elementCreator.popResult(); assertThat(actual).isNull(); }
@Test public void pop_a_result_when_parsing_finished() throws Exception { String result = "result"; elementCreator.onParsed(result); Object actual = elementCreator.popResult(); assertThat(actual).isEqualTo(result); }
@Test public void get_child_elements_using_namspace_when_a_namespace_is_provided() throws Exception { String tag = "tag"; String namespace = "namespace"; elementCreator.find(mockElement, namespace, tag); verify(mockElement).getChild(namespace, tag); }
@Test public void callParser_whenCreated() { String tag = "tag"; stub(mockElement.getChild(tag)).toReturn(mockElement); elementCreator.find(mockElement, tag); verify(mockParser).parse(mockElement, elementCreator); }
@Test public void allow_null_results_when_get_result_is_popped() throws Exception { Object result = elementCreator.popResult(); assertThat(result).isNull(); }
@Test(expected = BasicElementFinder.ResultNotFoundException.class) public void throw_exception_when_result_has_not_been_parsed_or_found_and_a_result_is_popped() throws Exception { elementCreator.popResultOrThrow(); }