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

Add output handler to configuration #958

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

FlorianKaemmerer
Copy link

This is just a rough idea how outputhandlers could be added.

added FilesystemOutputHandler
made OutputHandlers configurable
adapted AbstractPage to use all configured OutputHandlers
@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2020

Codecov Report

Merging #958 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #958      +/-   ##
============================================
+ Coverage     97.91%   98.02%   +0.11%     
- Complexity      555      563       +8     
============================================
  Files            54       55       +1     
  Lines          1153     1167      +14     
  Branches         99      100       +1     
============================================
+ Hits           1129     1144      +15     
+ Misses            9        7       -2     
- Partials         15       16       +1     
Impacted Files Coverage Δ Complexity Δ
...java/net/masterthought/cucumber/Configuration.java 100.00% <100.00%> (ø) 44.00 <11.00> (+4.00)
...java/net/masterthought/cucumber/ReportBuilder.java 93.97% <100.00%> (-0.15%) 21.00 <1.00> (ø)
...asterthought/cucumber/generators/AbstractPage.java 96.22% <100.00%> (-1.78%) 11.00 <1.00> (+1.00) ⬇️
...mber/json/deserializers/EmbeddingDeserializer.java 100.00% <100.00%> (+7.14%) 8.00 <2.00> (+1.00)
...cumber/outputhandlers/FilesystemOutputHandler.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be9384f...cf2ab79. Read the comment docs.

import net.masterthought.cucumber.presentation.PresentationMode;
import net.masterthought.cucumber.reducers.ReducingMethod;
import net.masterthought.cucumber.sorting.SortingMethod;
import org.apache.commons.lang.StringUtils;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.io.File;
import java.util.*;
Copy link
Owner

Choose a reason for hiding this comment

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

can you revert this change?
prefer to have full name class to import

Copy link
Author

Choose a reason for hiding this comment

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

reverted

*
* @param outputHandlerToRemove OutputHandler to be removed
*/
public void removeOutputHandler(OutputHandler outputHandlerToRemove) {
Copy link
Owner

Choose a reason for hiding this comment

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

not sure if we need it as long as this is used only by test

Copy link
Author

Choose a reason for hiding this comment

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

The Idea is that it can be used as a library, not every Method a library offers is used by itself.

Copy link
Owner

Choose a reason for hiding this comment

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

This class is not even designed that way so probably not used that way. Please apply philosophy YAGNI

/**
* Clears all OutputHandlers from the List of OutputHandlers
*/
public void clearOutputHandlers() {
Copy link
Owner

Choose a reason for hiding this comment

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

another method used only by tests

Copy link
Author

Choose a reason for hiding this comment

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

The Idea is that it can be used as a library, not every Method a library offers is used by itself.

Copy link
Owner

Choose a reason for hiding this comment

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

same

import net.masterthought.cucumber.generators.TagReportPage;
import net.masterthought.cucumber.generators.TagsOverviewPage;
import net.masterthought.cucumber.generators.TrendsOverviewPage;
import net.masterthought.cucumber.generators.*;
Copy link
Owner

Choose a reason for hiding this comment

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

same

Copy link
Author

Choose a reason for hiding this comment

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

reverted

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.*;
Copy link
Owner

Choose a reason for hiding this comment

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

same

Copy link
Author

Choose a reason for hiding this comment

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

reverted

}

@Test
public void clearOutputHandlers_shouldRemoveAllOutputHandlersFromOutputHandlersList() {
Copy link
Owner

Choose a reason for hiding this comment

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

same about convention

public void clearOutputHandlers_shouldRemoveAllOutputHandlersFromOutputHandlersList() {
//given
Configuration configuration = new Configuration(outputDirectory, projectName);
assertThat(configuration.getOutputHandlers()).hasSize(1);
Copy link
Owner

Choose a reason for hiding this comment

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

assertion should not go here
instead you can simple new handler to make sure list is not empty

Copy link
Author

Choose a reason for hiding this comment

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

removed assertion

}

@Test
public void addOutputHandler_shouldAddGivenHandlerToListOfOutputHandlers() {
Copy link
Owner

Choose a reason for hiding this comment

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

this and other method names


//then
assertThat(configuration.getOutputHandlers()).hasSize(1);
assertThat(configuration.getOutputHandlers().get(0)).isInstanceOf(FilesystemOutputHandler.class);
Copy link
Owner

Choose a reason for hiding this comment

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

you don't need to validate only class, you can validate exact reference which you have added before

Copy link
Author

Choose a reason for hiding this comment

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

updated assert

String writtenOutput = new String(Files.readAllBytes(filesystemOutputHandlerTestOutputFile.toPath()), UTF_8);
assertThat(writtenOutput).isEqualTo(expectedOutput);
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

check if already added comment is not valid for other

can you also update one integration test or even add new one with memory handlers to check whether it works or not?

Copy link
Owner

Choose a reason for hiding this comment

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

can I test this PR without second or both should be tested together?

Copy link
Author

Choose a reason for hiding this comment

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

Added Integration Test

You can Test it without the second PR, they are independend

*/
public void setTrends(File trendsFile, int limit) {
this.trendsFile = trendsFile;
this.trendsLimit = limit;
trendsLimit = limit;
Copy link
Owner

Choose a reason for hiding this comment

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

the formatter works strange :)
this line is updated but above doesn't

@@ -27,6 +17,12 @@
import org.apache.velocity.app.event.EventCartridge;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;

import java.io.*;
Copy link
Owner

@damianszczepanik damianszczepanik Oct 14, 2020

Choose a reason for hiding this comment

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

Lets separate all changes related to formatting to another PR which will be merged first and then we can reduce number of changes only to the important once.
Also be consistent :)

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import net.masterthought.cucumber.generators.OverviewReport;
import net.masterthought.cucumber.json.Feature;
import java.io.File;
Copy link
Owner

Choose a reason for hiding this comment

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

I like when SDK libs are listed first. By this approach it is not even alphabetically.

@@ -173,22 +166,6 @@ public void copyStaticResources_CopiesRequiredFiles() {
assertThat(files).hasSize(21);
}

@Test
public void createEmbeddingsDirectory_CreatesDirectory() {
Copy link
Owner

Choose a reason for hiding this comment

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

in the past I had a problem with this directory - did you remove this test forever or move it to some other class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants