ImageContentExtension extends AbstractContentExtension<ImageContentExtensionController> { @Override public String buildContentString(IMarkup markup) { final StringBuilder builder = new StringBuilder(); if (this.getController().getSelectedFile() != null) { if (markup == null || "HTML".equals(markup.getCode())) { builder.append(this.buildDefaultContentString()); } else if ("TEXTILE".equals(markup.getCode())) { builder.append(this.buildTextileContentString()); } else if ("MARKDOWN".equals(markup.getCode())) { builder.append(this.buildMarkdownContentString()); } else { builder.append(this.buildDefaultContentString()); } } return builder.toString(); } ImageContentExtension(); @Override String buildContentString(IMarkup markup); @Override String buildDefaultContentString(); @Override ReadOnlyBooleanProperty areInputsValid();  }
@TestFactory @DisplayName("should generate content") Stream<DynamicTest> testingContentGeneration() { return Stream.of( new ExpectedContent(html) .withDisplayName("without dimensions in HTML") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" />"), new ExpectedContent(html) .withDisplayName("with empty dimensions in HTML") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" />") .withWidth("").withHeight(""), new ExpectedContent(html) .withDisplayName("when specifying a width in HTML") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" width=\"150px\" />") .withWidth("150px"), new ExpectedContent(html) .withDisplayName("when specifying a height in HTML") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" height=\"200px\" />") .withHeight("200px"), new ExpectedContent(html) .withDisplayName("when specifying dimensions in HTML") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" width=\"150px\" height=\"200px\" />") .withWidth("150px").withHeight("200px"), new ExpectedContent(textile) .withDisplayName("without dimensions in Textile") .withExpected("!" + file.getAbsolutePath() + "!"), new ExpectedContent(textile) .withDisplayName("with empty dimensions in Textile") .withExpected("!" + file.getAbsolutePath() + "!") .withWidth("").withHeight(""), new ExpectedContent(textile) .withDisplayName("when specifying a width in Textile") .withExpected("!{width: 150px;}" + file.getAbsolutePath() + "!") .withWidth("150px"), new ExpectedContent(textile) .withDisplayName("when specifying a height in Textile") .withExpected("!{height: 200px;}" + file.getAbsolutePath() + "!") .withHeight("200px"), new ExpectedContent(textile) .withDisplayName("when specifying dimensions in Textile") .withExpected("!{width: 150px;height: 200px;}" + file.getAbsolutePath() + "!") .withWidth("150px").withHeight("200px"), new ExpectedContent(markdown) .withDisplayName("without dimensions in Markdown") .withExpected("[](" + file.getAbsolutePath() + ")"), new ExpectedContent(markdown) .withDisplayName("with empty dimensions in Markdown") .withExpected("[](" + file.getAbsolutePath() + ")") .withWidth("").withHeight(""), new ExpectedContent(markdown) .withDisplayName("when specifying a width in Markdown") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" width=\"150px\" />") .withWidth("150px"), new ExpectedContent(markdown) .withDisplayName("when specifying a height in Markdown") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" height=\"200px\" />") .withHeight("200px"), new ExpectedContent(markdown) .withDisplayName("when specifying dimensions in Markdown") .withExpected("<img src=\"" + file.getAbsolutePath() + "\" width=\"150px\" height=\"200px\" />") .withWidth("150px").withHeight("200px") ).map(content -> { final ImageContentExtension extension = mockContentExtension(content.width, content.height); final Executable executable = () -> assertEquals(content.expected, extension.buildContentString(content.markup)); return dynamicTest(content.displayName, executable); }); }