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

All modified and coverable lines are covered by tests ✅

Project coverage is 98.02%. Comparing base (be9384f) to head (cf2ab79).
Report is 189 commits behind head on master.

Additional details and impacted files
@@             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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

3 participants