-
Notifications
You must be signed in to change notification settings - Fork 403
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
base: master
Are you sure you want to change the base?
Add output handler to configuration #958
Conversation
added FilesystemOutputHandler made OutputHandlers configurable adapted AbstractPage to use all configured OutputHandlers
removed obsolete Test
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.*; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
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.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.*; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
This is just a rough idea how outputhandlers could be added.