All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codepoetics.fluvius.test.matchers.PropertyMismatchDescriber Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package com.codepoetics.fluvius.test.matchers;

import org.hamcrest.Description;
import org.hamcrest.Matcher;

import static com.codepoetics.fluvius.test.matchers.IndentationControl.*;

final class PropertyMismatchDescriber {

  private final Description description;
  private boolean matches = true;

  PropertyMismatchDescriber(Description description) {
    this.description = description;
  }

  public  PropertyMismatchDescriber check(String propertyName, T propertyValue, Matcher matcher) {
    if (matcher == null) {
      return this;
    }
    if (matcher.matches(propertyValue)) {
      return this;
    }

    matches = false;

    newline(description).appendText(propertyName).appendText(": ");
    indent();
    matcher.describeMismatch(propertyValue, description);
    outdent();

    return this;
  }

  public boolean result() {
    return matches;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy