### Question:
SpanStrategies extends ElementStrategies<SpanType, SpanStrategy, SpanHtmlElementStrategy> { @Override public SpanStrategy getStrategy(SpanType elementType, Attributes attributes) { SpanStrategy strategy = super.getStrategy(elementType, attributes); if (elementType == SpanType.SPAN && strategy instanceof UnsupportedSpanStrategy) { SpanStrategy alternateStrategy = calculateAlternateSpanStrategy(attributes); if (alternateStrategy != null) { strategy = alternateStrategy; } } return strategy; } SpanStrategies(Set<SpanType> elementTypes, List<SpanHtmlElementStrategy> spanElementStrategies); @Override SpanStrategy getStrategy(SpanType elementType, Attributes attributes);  }### Answer:
@Test public void createEmpty() { SpanStrategies strategies = new SpanStrategies(Sets.<SpanType> newHashSet(), Collections.<SpanHtmlElementStrategy> emptyList()); assertNotNull(strategies.getStrategy(SpanType.BOLD, new Attributes())); }
@Test public void createNonEmpty() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.BOLD, SpanType.CODE), Collections.<SpanHtmlElementStrategy> emptyList()); assertSupported(strategies, SpanType.BOLD); assertSupported(strategies, SpanType.CODE); for (SpanType spanType : SpanType.values()) { assertNotNull(strategies.getStrategy(spanType, new Attributes())); } }
@Test public void alternatives() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.BOLD), Collections.<SpanHtmlElementStrategy> emptyList()); assertTrue(strategies.getStrategy(SpanType.STRONG, new Attributes()) instanceof SubstitutionSpanStrategy); }
@Test public void spanWithFontWeightToBold() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.BOLD), Collections.<SpanHtmlElementStrategy> emptyList()); SpanStrategy strategy = strategies.getStrategy(SpanType.SPAN, new Attributes(null, null, "font-weight: bold", null)); assertTrue(strategy instanceof SubstitutionWithoutCssSpanStrategy); assertEquals(SpanType.BOLD, ((SubstitutionWithoutCssSpanStrategy) strategy).getType()); }
@Test public void spanWithFontWeightToStrong() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.STRONG), Collections.<SpanHtmlElementStrategy> emptyList()); SpanStrategy strategy = strategies.getStrategy(SpanType.SPAN, new Attributes(null, null, "font-weight: bold", null)); assertTrue(strategy instanceof SubstitutionWithoutCssSpanStrategy); assertEquals(SpanType.STRONG, ((SubstitutionWithoutCssSpanStrategy) strategy).getType()); }
@Test public void spanWithTextDecorationUnderlineToUnderlined() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.UNDERLINED), Collections.<SpanHtmlElementStrategy> emptyList()); SpanStrategy strategy = strategies.getStrategy(SpanType.SPAN, new Attributes(null, null, "text-decoration: underline;", null)); assertTrue(strategy instanceof SubstitutionWithoutCssSpanStrategy); assertEquals(SpanType.UNDERLINED, ((SubstitutionWithoutCssSpanStrategy) strategy).getType()); }
@Test public void spanWithTextDecorationLinethroughToDeleted() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.DELETED), Collections.<SpanHtmlElementStrategy> emptyList()); SpanStrategy strategy = strategies.getStrategy(SpanType.SPAN, new Attributes(null, null, "text-decoration: line-through;", null)); assertTrue(strategy instanceof SubstitutionWithoutCssSpanStrategy); assertEquals(SpanType.DELETED, ((SubstitutionWithoutCssSpanStrategy) strategy).getType()); }
@Test public void spanWithUnrecognizedCssToUnsupported() { SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.BOLD), Collections.<SpanHtmlElementStrategy> emptyList()); assertTrue(strategies.getStrategy(SpanType.SPAN, new Attributes(null, null, "font-weight:unknown", null)) instanceof UnsupportedSpanStrategy); }