DefaultTraversalStrategies implements TraversalStrategies { @Override @SuppressWarnings({"unchecked", "varargs"}) public TraversalStrategies addStrategies(final TraversalStrategy<?>... strategies) { for (final TraversalStrategy<?> addStrategy : strategies) { this.traversalStrategies.remove(addStrategy); } Collections.addAll(this.traversalStrategies, strategies); this.traversalStrategies = TraversalStrategies.sortStrategies(this.traversalStrategies); return this; }  @Override @SuppressWarnings({"unchecked", "varargs"}) TraversalStrategies addStrategies(final TraversalStrategy<?>... strategies); @Override @SuppressWarnings({"unchecked", "varargs"}) TraversalStrategies removeStrategies(final Class<? extends TraversalStrategy>... strategyClasses); @Override List<TraversalStrategy<?>> toList(); @Override Iterator<TraversalStrategy<?>> iterator(); @Override Optional<T> getStrategy(final Class<T> traversalStrategyClass); @Override DefaultTraversalStrategies clone(); @Override String toString();  }
@Test public void testCircularDependency() { TraversalStrategies s = new DefaultTraversalStrategies(); try { s.addStrategies(c, k, a, b); fail(); } catch (IllegalStateException ex) { assertTrue(ex.getMessage().toLowerCase().contains("cyclic")); } }
@Test public void testCircularDependency2() { TraversalStrategies s = new DefaultTraversalStrategies(); try { s.addStrategies(d, c, k, a, e, b); fail(); } catch (IllegalStateException ex) { assertTrue(ex.getMessage().toLowerCase().contains("cyclic")); } }