Skip to content

Commit

Permalink
fix TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Apr 2, 2024
1 parent 591300b commit 4145110
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.input.BOMInputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -149,15 +150,14 @@ private void parseScenarioOutlineExamples(Examples examples, PrintWriter out){
out.print("</table></div>");
}

private void parseHTMLScenarioPanelHead(PrintWriter out, int idx, String title) throws IOException {
protected void parseHTMLScenarioPanelHead(PrintWriter out, int idx, String title) {
out.println("<div class=\"panel panel-default\">");
out.print("<div class=\"panel-heading");
if (parameters.getHtmlPanelToggle() == HtmlPanelToggleEnum.CLOSED) out.print(" collapsed");
out.print("\" style=\"cursor: pointer;\" data-toggle=\"collapse\" data-target=\"#scenario-");
out.print(idx);
out.print("\"><h3>");
out.print(title); // @TODO: not escaped
// StringEscapeUtils.escapeHtml(out, title);
out.print(StringEscapeUtils.escapeHtml4(title));
out.print("</h3></div>");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import com.github.clagomess.pirilampo.core.dto.ParametersDto;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import java.io.*;
import java.nio.charset.StandardCharsets;
Expand All @@ -27,4 +30,23 @@ public void build() throws Exception {
new GherkinDocumentParser(parameters, featureFile).build(out);
}
}

@ParameterizedTest
@CsvSource({
"test,test",
"&lt;strong&gt;a&lt;strong&gt;,<strong>a<strong>"
})
public void parseHTMLScenarioPanelHead(String expected, String title){
val parameters = new ParametersDto();
parameters.setProjectSource(featureFile);

StringWriter sw = new StringWriter();

try (PrintWriter out = new PrintWriter(sw)){
val gdp = new GherkinDocumentParser(parameters, featureFile);
gdp.parseHTMLScenarioPanelHead(out, 1, title);
}

Assertions.assertThat(sw.toString()).contains(expected);
}
}
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down

0 comments on commit 4145110

Please sign in to comment.