-
Notifications
You must be signed in to change notification settings - Fork 2
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
CDAP-15855: Updated validation API. #7
base: develop
Are you sure you want to change the base?
CDAP-15855: Updated validation API. #7
Conversation
@albertshau could you, please, take a look |
pom.xml
Outdated
@@ -110,6 +110,12 @@ | |||
<version>${cdap.version}</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.cdap.cdap</groupId> | |||
<artifactId>cdap-etl-core</artifactId> |
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.
why is this change needed?
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 dependency was left for by mistake, it should be removed.
source.getFileSystem(new Configuration()); | ||
} catch (IOException e) { | ||
collector.addFailure("Cannot determine the file system of the source file.", null) | ||
.withConfigProperty(SOURCE_FILE_PATH).withStacktrace(e.getStackTrace()); | ||
} | ||
if (Strings.isNullOrEmpty(destFilePath)) { |
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 check can be moved up to be validated along with source path
.withConfigProperty(FILE_REGEX); | ||
} | ||
try { | ||
Charset.forName(charset); |
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 can be validated along with source path.
if (Strings.isNullOrEmpty(sourceFilePath)) { | ||
collector.addFailure("Source file or folder is required.", "Set source file or folder.") | ||
.withConfigProperty(SOURCE_FILE_PATH); | ||
collector.getOrThrowException(); |
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.
why do we need to throw exception here? This would just validate one property and throw an exception. we should validate other properties as well before throwing an exception
try { | ||
new ToUTF8Action(config).configurePipeline(configurer); | ||
} catch (ValidationException e) { | ||
assertEquals(1, e.getFailures().size()); |
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 we also add unit tests where more than 1 failures are collected?
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.
While reviewing this, I took a look at what this plugin is doing and I'm questioning the usefulness of this plugin. It is also implemented incorrectly so we shouldn't be providing it for people to use.
I'm going to see if we can remove the plugin, so not going to review the rest.
"from https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html.", e); | ||
private void validate(FailureCollector collector) throws ValidationException { | ||
if (Strings.isNullOrEmpty(sourceFilePath)) { | ||
collector.addFailure("Source file or folder is required.", "Set source file or folder.") |
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.
If the error message and the corrective action are basically the same (like here), it's better to just have the message and leave the corrective action null.
JIRA: https://issues.cask.co/browse/CDAP-15855
In scope of this PR: