-
Notifications
You must be signed in to change notification settings - Fork 207
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
Updated Logstash attributes mapper to use template pattern #617
Updated Logstash attributes mapper to use template pattern #617
Conversation
Signed-off-by: Asif Sohail Mohammed <[email protected]>
8126cc3
to
293a3ba
Compare
Codecov Report
@@ Coverage Diff @@
## main #617 +/- ##
=========================================
Coverage 91.70% 91.70%
Complexity 571 571
=========================================
Files 72 72
Lines 1747 1747
Branches 145 145
=========================================
Hits 1602 1602
Misses 113 113
Partials 32 32 Continue to review full report at Codecov.
|
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.
Overall this looks like great. I made a few comments that I'd like to see addressed.
return pluginSettings; | ||
} | ||
|
||
abstract void mapCustomAttributes(List<LogstashAttribute> logstashAttributes, LogstashAttributesMappings logstashAttributesMappings, Map<String, Object> pluginSettings); |
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 method and the other abstract method should be protected
so that they are accessible to inheriting classes.
import java.util.Map; | ||
import java.util.LinkedHashMap; | ||
|
||
abstract class AbstractLogstashPluginAttributesMapper implements LogstashPluginAttributesMapper { |
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 should be public so that classes in other packages can inherit it.
import java.util.Map; | ||
import java.util.LinkedHashMap; | ||
|
||
abstract class AbstractLogstashPluginAttributesMapper implements LogstashPluginAttributesMapper { |
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 can have Javadocs for it.
import java.util.Map; | ||
import java.util.LinkedHashMap; | ||
|
||
abstract class AbstractLogstashPluginAttributesMapper implements LogstashPluginAttributesMapper { |
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 can write a unit test for this class and use Mockito spy's to verify the correct behavior.
One example: mock getCustomMappedAttributeNames
to return a field and then verify that field was not mapped. Another example: Verify that mapCustomAttributes
is called in when it there are custom attributes names and not called otherwise.
return pluginSettings; | ||
} | ||
|
||
abstract void mapCustomAttributes(List<LogstashAttribute> logstashAttributes, LogstashAttributesMappings logstashAttributesMappings, Map<String, Object> pluginSettings); |
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.
These two abstract methods should have Javadocs to explain their purpose to inheritors.
final Map<String, Object> pluginSettings = new LinkedHashMap<>(logstashAttributesMappings.getAdditionalAttributes()); | ||
final Map<String, String> mappedAttributeNames = logstashAttributesMappings.getMappedAttributeNames(); | ||
|
||
Collection<String> customMappedAttributeNames = getCustomMappedAttributeNames(); |
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.
It might be a good idea to create a new HashSet
here since the collection need not be a Set
.
Signed-off-by: Asif Sohail Mohammed <[email protected]>
…h-project#617) * Updated Logstash attributes mapper to use template pattern Signed-off-by: Asif Sohail Mohammed <[email protected]> Co-authored-by: Asif Sohail Mohammed <[email protected]>
Signed-off-by: Asif Sohail Mohammed [email protected]
Description
Added AbstractLogstashPluginAttributesMapper which leverages template pattern
Cleaned ModelConvertingLogstashVisitorTest class
Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.