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

[vividus-to-zephyr-exporter] Fix validation for zephyr.exporter.source-directory #3044

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 the original author or authors.
* Copyright 2019-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,17 +19,19 @@
import java.nio.file.Path;
import java.util.List;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import org.vividus.zephyr.model.TestCaseStatus;

@Validated
@ConfigurationProperties("zephyr.exporter")
public class ZephyrExporterProperties
{
private String jiraInstanceKey;

@NotBlank(message = "Property 'zephyr.exporter.source-directory' must not be blank")
@NotNull(message = "Property 'zephyr.exporter.source-directory' must be set")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this change fix the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helps when property is empty, but in case of a non-existent path, we are facing with NoSuchFileException (just like now)
Property is empty:
image

Non-existent path:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to see clear message, I can add try-catch:

    try
    {
        Files.walkFileTree(zephyrExporterProperties.getSourceDirectory(), crawler);
    }
    catch (IOException e)
    {
        throw new NoSuchFileException("Path to directory with test execution JSON results should be corrected: "
                + zephyrExporterProperties.getSourceDirectory());
    }

or create new annotation @FileByPathExists

private Path sourceDirectory;

private boolean updateExecutionStatusesOnly;
Expand Down