ConfigurationAlgorithm { static Set<FlowElement> findOrphans(final Definitions definitions) { Set<FlowElement> all = new HashSet<FlowElement>(); Set<FlowElement> canStart = new HashSet<FlowElement>(); Set<FlowElement> canEnd = new HashSet<FlowElement>(); for (final BaseElement rootElement : definitions.getRootElement()) { if (rootElement instanceof Process) { for (final FlowElement element : ((Process) rootElement).getFlowElement()) { all.add(element); if (element instanceof StartEvent) { mark(element, canStart, Direction.FORWARDS); } else if (element instanceof EndEvent) { mark(element, canEnd, Direction.BACKWARDS); } } } } canStart.retainAll(canEnd); all.removeAll(canStart); return all; }  static void configure(final Definitions definitions); static Map<BaseElement, DiagramElement> findBpmndiMap(final Definitions definitions); static Set<Gateway> findConfiguredGateways(final Definitions definitions); static Set<SequenceFlow> findAbsentSequenceFlows(final Set<Gateway> reconfiguredGatewaySet); static void main(final String[] arg);  }
@Test public final void testFindOrphans1() throws JAXBException { Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(IDResolver.class.getName(), new DefinitionsIDResolver()); Definitions definitions = (Definitions) unmarshaller.unmarshal(test1File); assertTrue(ConfigurationAlgorithm.findOrphans(definitions).isEmpty()); }
@Test public final void testFindOrphans2() throws JAXBException { Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(IDResolver.class.getName(), new DefinitionsIDResolver()); Definitions definitions = (Definitions) unmarshaller.unmarshal(trivialGatewayFile); assertTrue(ConfigurationAlgorithm.findOrphans(definitions).isEmpty()); }