SequenceDescriptorFactory { public SequenceDescriptor create(final Document document, final Element sequenceElement, final List<DialogDescriptor> dialogDescriptors) { List<ConditionDescriptor> conditionDescriptors = conditionDescriptorNodesParser.parseNodesOfElement(document, sequenceElement); Map<String, DialogDescriptor> dialogDescriptorMap = dialogDescriptorMapper.groupByName(dialogDescriptors); List<DialogDescriptor> referencedDialogDescriptors = dialogDescriptorReferenceParser.parse(sequenceElement, dialogDescriptorMap); SequenceDescriptorAttributes attributes = sequenceDescriptorAttributesParser.parseNode(sequenceElement, document); return new SequenceDescriptor(conditionDescriptors, referencedDialogDescriptors, attributes); }  SequenceDescriptor create(final Document document, final Element sequenceElement, final List<DialogDescriptor> dialogDescriptors);  }
@Test public void testCreate() { List<ConditionDescriptor> conditionDescriptors = new ArrayList<>(); List<DialogDescriptor> sequenceDialogDescriptors = new ArrayList<>(); Map<String, DialogDescriptor> nameToDialogDescriptor = new HashMap<>(); DummySequenceHandler dummySequenceHandler = new DummySequenceHandler(); SequenceDescriptorAttributes sequenceDescriptorAttributes = new SequenceDescriptorAttributes.Builder().name("bob") .handler(dummySequenceHandler).defaultTimeout(1L).build(); given(conditionDescriptorNodesParser.parseNodesOfElement(document, sequenceElement)).willReturn(conditionDescriptors); given(dialogDescriptorMapper.groupByName(dialogDescriptors)).willReturn(nameToDialogDescriptor); given(dialogDescriptorReferenceParser.parse(sequenceElement, nameToDialogDescriptor)).willReturn(sequenceDialogDescriptors); given(sequenceDescriptorAttributesParser.parseNode(sequenceElement, document)).willReturn(sequenceDescriptorAttributes); SequenceDescriptor result = underTest.create(document, sequenceElement, dialogDescriptors); assertEquals(conditionDescriptors, result.getConditionDescriptors()); assertEquals(sequenceDialogDescriptors, result.getDialogDescriptors()); assertEquals(1L, result.getDefaultTimeout()); assertEquals(dummySequenceHandler, result.getHandler()); assertEquals("bob", result.getName()); }