class TherionImporter extends Importer {

    public static List<String> getContentsOfBeginEndBlock(List<String> lines, String tag)
            throws Exception {

        boolean foundStartBlock = false;
        boolean foundEndBlock = false;
        String endTag = "end" + tag;

        List<String> contents = new ArrayList<>();

        for (String line : lines) {
            line = line.trim();

            if (line.equals(tag)) {
                if (foundStartBlock) {
                    throw new Exception("Opening block tag " + tag + " encountered twice");
                } else {
                    foundStartBlock = true;
                    continue;
                }

            } else if (line.equals(endTag)) {
                if (foundStartBlock) {
                    foundEndBlock = true;
                    break;
                } else {
                    throw new Exception("End block tag " + endTag + " encountered before block start");
                }

            } else if (!foundStartBlock) {
                continue;
            }

            contents.add(line);
        }

        if (!foundStartBlock) {
            throw new Exception("Failed to find opening block tag " + tag);
        } else if (!foundEndBlock) {
            throw new Exception("Failed to find end block tag " + endTag);
        }

        return contents;
    }

}

class TherionImporterTest {

    private static final String FAKE_POCKETTOPO_TEXT;
    private static String FAKE_TEXT;
    private static final List<String> LINES;

    @Test(expected=Exception.class)
    public void testBlockExtractionFailsIfTwoOpeningTags() throws Exception {

        List<String> LINES = Arrays.asList("block", "blah", "block", "blah", "endblock");
        TherionImporter.getContentsOfBeginEndBlock(LINES, "block");
    }

}