StubDescriptorParser { public StubDescriptor parse(final Document document) { Element root = document.getDocumentElement(); StubDescriptorAttributes attributes = getStubDescriptorAttributes(root); List<DialogDescriptor> dialogDescriptors = getDialogDescriptors(document, root); List<InterceptorDescriptor> interceptorDescriptors = getInterceptorDescriptors(document, root); List<SequenceDescriptor> sequenceDescriptors = sequenceDescriptorParser.parse(document, root, dialogDescriptors); return new StubDescriptor(attributes, dialogDescriptors, interceptorDescriptors, sequenceDescriptors); }  StubDescriptor parse(final Document document);  }
@Test public void testParseShouldReturnStubDescriptorAttributesWithGroupname() { given(root.getAttribute("groupname")).willReturn("test"); StubDescriptor actual = underTest.parse(document); assertEquals(actual.getAttributes().getGroupName(), stubDescriptorAttributes.getGroupName()); }
@Test public void testParseShouldReturnStubDescriptorAttributesWithActiveValue() { given(root.getAttribute("active")).willReturn("false"); StubDescriptorAttributes expectedAttributes = new StubDescriptorAttributes("Default", false); StubDescriptor actual = underTest.parse(document); assertEquals(actual.getAttributes().isActive(), expectedAttributes.isActive()); }
@Test public void testParseShouldReturnStubDescriptorAttributesWithDefaultActiveValue() { given(root.getAttribute("active")).willReturn(""); StubDescriptorAttributes expectedAttributes = new StubDescriptorAttributes("Default", true); StubDescriptor actual = underTest.parse(document); assertEquals(actual.getAttributes().isActive(), expectedAttributes.isActive()); }
@Test public void testParseShouldReturnSequenceDescriptors() { parsedDialogDescriptors = new ArrayList<>(); underTest.parse(document); verify(sequenceDescriptorParser).parse(document, root, parsedDialogDescriptors); }