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

New matcher is required to detect that file exists #215

Open
dgroup opened this issue Dec 31, 2020 · 5 comments
Open

New matcher is required to detect that file exists #215

dgroup opened this issue Dec 31, 2020 · 5 comments

Comments

@dgroup
Copy link
Contributor

dgroup commented Dec 31, 2020

new Assertion<>(
  "... scenario name ...",
   /* some business logic which manipulates with file */,
  new Exists("target", "sub-dir1", "sub-dir2")
).affirm();

// where Found supports
public final Exists extends MatcherEnvelope<File> {
   public Exists(final String ... path) {
      this(() -> Paths.get(path).toFile());
  }
  public Exists(final Path path) {
     this(()-> path.toFile());
  )
  public Exists(final File path) {
     this(() -> path);
  }
  public Exists(final Scalar<File> path) {
     super(...);
  }
@victornoel
Copy link
Collaborator

@dgroup could you update the description to make this a Matcher of Path instead of File. The constructors should only take Path and File imho, no need for Strings and for Scalar.

Also, let's name it Exists (or if you have a better idea, I'm open :)

@dgroup
Copy link
Contributor Author

dgroup commented Jan 28, 2021

@victornoel thanks for the idea related to Exists, but disagree with

  • removing constructor for String/Scalar (in fact we gives more options on how to build a matcher)
  • use Path instead of File, because most of the API which I'm facing returns files, not Path.

Could you please clarify more your ideas?

@victornoel
Copy link
Collaborator

@dgroup sorry for the late reply.

I just realized that there was something fishy with this Matcher: if it's a Matcher<File>, then why does it also take a file in the constructor? Shouldn't it be instead:

public final Exists implements Matcher<File> {
  public Exists() { /* ... */ }
}

new Assertion<>(
  "... scenario name ...",
   /* some business logic which returns a file */,
  new Exists()
).affirm();

Or if not, then, it shouldn't be a Matcher of File but of Proc for example... Which one did you have in mind?

@dgroup
Copy link
Contributor Author

dgroup commented Mar 15, 2021

@victornoel agree, such approach is more laconic.

@victornoel
Copy link
Collaborator

@dgroup cool, could you update the description to mirror the conclusion of this discussion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants