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

CDAP-15855: Updated validation API. #7

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

AntonGensitskiy
Copy link

JIRA: https://issues.cask.co/browse/CDAP-15855

In scope of this PR:

  • Was updated validation API;

@AntonGensitskiy
Copy link
Author

@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>
Copy link
Member

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?

Copy link
Author

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)) {
Copy link
Member

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);
Copy link
Member

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();
Copy link
Member

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());
Copy link
Member

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?

Copy link

@albertshau albertshau left a 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.")

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.

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