Search in sources :

Example 1 with BlockStrategy

use of org.eclipse.mylyn.wikitext.html.internal.BlockStrategy in project mylyn.docs by eclipse.

the class BlockStrategiesTest method assertFallback.

protected void assertFallback(BlockType supportedType, BlockType blockType) {
    BlockStrategies strategies = new BlockStrategies(Sets.newHashSet(supportedType));
    BlockStrategy strategy = strategies.getStrategy(blockType, new Attributes());
    assertNotNull(strategy);
    assertEquals(blockType.name(), SubstitutionBlockStrategy.class, strategy.getClass());
    assertEquals(blockType.name(), supportedType, ((SubstitutionBlockStrategy) strategy).getBlockType());
}
Also used : Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BlockStrategies(org.eclipse.mylyn.wikitext.html.internal.BlockStrategies) UnsupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy) NoOpBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy) BlockStrategy(org.eclipse.mylyn.wikitext.html.internal.BlockStrategy) SupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy) SubstitutionBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy)

Example 2 with BlockStrategy

use of org.eclipse.mylyn.wikitext.html.internal.BlockStrategy in project mylyn.docs by eclipse.

the class BlockStrategiesTest method fallBackToUnsupported.

@Test
public void fallBackToUnsupported() {
    BlockStrategies strategies = new BlockStrategies(Sets.newHashSet(BlockType.PARAGRAPH));
    BlockStrategy strategy = strategies.getStrategy(BlockType.TABLE_ROW, new Attributes());
    assertNotNull(strategy);
    assertTrue(UnsupportedBlockStrategy.class.equals(strategy.getClass()));
}
Also used : UnsupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BlockStrategies(org.eclipse.mylyn.wikitext.html.internal.BlockStrategies) UnsupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy) NoOpBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy) BlockStrategy(org.eclipse.mylyn.wikitext.html.internal.BlockStrategy) SupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy) SubstitutionBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy) Test(org.junit.Test)

Example 3 with BlockStrategy

use of org.eclipse.mylyn.wikitext.html.internal.BlockStrategy in project mylyn.docs by eclipse.

the class BlockStrategiesTest method assertUnsupported.

private void assertUnsupported(BlockStrategies strategies, BlockType blockType) {
    BlockStrategy blockStrategy = strategies.getStrategy(blockType, new Attributes());
    assertNotNull(blockStrategy);
    assertFalse(blockStrategy instanceof SupportedBlockStrategy);
}
Also used : Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) UnsupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy) NoOpBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy) BlockStrategy(org.eclipse.mylyn.wikitext.html.internal.BlockStrategy) SupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy) SubstitutionBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy) SupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy)

Example 4 with BlockStrategy

use of org.eclipse.mylyn.wikitext.html.internal.BlockStrategy in project mylyn.docs by eclipse.

the class BlockStrategiesTest method fallBackToNoOp.

@Test
public void fallBackToNoOp() {
    BlockStrategies strategies = new BlockStrategies(Sets.newHashSet(BlockType.PARAGRAPH));
    List<BlockType> unsupportedBlockTypes = ImmutableList.of(BlockType.TABLE, BlockType.BULLETED_LIST, BlockType.NUMERIC_LIST, BlockType.DEFINITION_LIST);
    for (BlockType blockType : unsupportedBlockTypes) {
        BlockStrategy strategy = strategies.getStrategy(blockType, new Attributes());
        assertNotNull(strategy);
        assertTrue(NoOpBlockStrategy.class.equals(strategy.getClass()));
    }
}
Also used : NoOpBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy) BlockType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BlockStrategies(org.eclipse.mylyn.wikitext.html.internal.BlockStrategies) UnsupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy) NoOpBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy) BlockStrategy(org.eclipse.mylyn.wikitext.html.internal.BlockStrategy) SupportedBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy) SubstitutionBlockStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy) Test(org.junit.Test)

Aggregations

BlockStrategy (org.eclipse.mylyn.wikitext.html.internal.BlockStrategy)4 NoOpBlockStrategy (org.eclipse.mylyn.wikitext.html.internal.NoOpBlockStrategy)4 SubstitutionBlockStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy)4 SupportedBlockStrategy (org.eclipse.mylyn.wikitext.html.internal.SupportedBlockStrategy)4 UnsupportedBlockStrategy (org.eclipse.mylyn.wikitext.html.internal.UnsupportedBlockStrategy)4 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)4 BlockStrategies (org.eclipse.mylyn.wikitext.html.internal.BlockStrategies)3 Test (org.junit.Test)2 BlockType (org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType)1