Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the visibility of the reportParser field #1216

Merged
merged 8 commits into from
Nov 16, 2024
11 changes: 9 additions & 2 deletions src/main/java/net/masterthought/cucumber/ReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public class ReportBuilder {
private static final ObjectMapper mapper = new ObjectMapper();

private ReportResult reportResult;
private final ReportParser reportParser;

private ReportParser reportParser;
private Configuration configuration;
private List<String> jsonFiles;

Expand All @@ -71,6 +70,14 @@ public ReportBuilder(List<String> jsonFiles, Configuration configuration) {
reportParser = new ReportParser(configuration);
}

public ReportParser getReportParser() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, this is what I expect o extend

return reportParser;
}

public void setReportParser(ReportParser reportParser) {
this.reportParser = reportParser;
}

/**
* Parses provided files and generates the report. When generating process fails
* report with information about error is provided.
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/net/masterthought/cucumber/ReportBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ void ReportBuilder_storesFilesAndConfiguration() {
assertThat(assignedConfiguration).isSameAs(configuration);
}

@Test
void ReportBuilder_setsAndGetsCustomReportParser(){
// given
final List<String> jsonFiles = new ArrayList<>();
final Configuration configuration = new Configuration(null, null);
final ReportParser reportParser = new ReportParser(configuration);

// when
ReportBuilder builder = new ReportBuilder(jsonFiles, configuration);
builder.setReportParser(reportParser);

// then
ReportParser assignedReportParser = Whitebox.getInternalState(builder, "reportParser");

assertThat(assignedReportParser).isSameAs(builder.getReportParser());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be just
assertThat(reportParser).isSameAs(builder.getReportParser()); and no need to use Whitebox

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duly noted Damian! Thank you.

}

@Test
void generateReports_GeneratesPages() {

Expand Down
Loading