org.hamcrest.Description#appendValueList ( )源码实例Demo

下面列出了org.hamcrest.Description#appendValueList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: auth0-java   文件: RecordedRequestMatcher.java
private boolean matchesQueryParameter(RecordedRequest item, Description mismatchDescription) {
    HttpUrl requestUrl = item.getRequestUrl();
    if (requestUrl.querySize() == 0) {
        mismatchDescription.appendText(" query was empty");
        return false;
    }

    String queryParamValue = requestUrl.queryParameter(first);
    if (second.equals(queryParamValue)) {
        return true;
    }

    mismatchDescription.appendValueList("Query parameters were {", ", ", "}.",
            requestUrl.query().split("&"));
    return false;
}
 
源代码2 项目: auth0-java   文件: RecordedRequestMatcher.java
private boolean hasQueryParameter(RecordedRequest item, Description mismatchDescription) {
    String path = item.getPath();
    boolean hasQuery = path.indexOf("?") > 0;
    if (!hasQuery) {
        mismatchDescription.appendText(" query was empty");
        return false;
    }

    String query = path.substring(path.indexOf("?") + 1, path.length());
    String[] parameters = query.split("&");
    for (String p : parameters) {
        if (p.startsWith(String.format("%s=", first))) {
            return true;
        }
    }
    mismatchDescription.appendValueList("Query parameters were {", ", ", "}.", parameters);
    return false;
}
 
@Override
protected boolean matchesSafely(List<String> items, Description mismatchDescriptor) {
    int count = 0;
    for (String item : items) {
        if (stringMatcher.matches(item)) {
            count++;
        }
    }
    boolean okay = count == expectedCount;
    if (!okay) {
        mismatchDescriptor.appendText("was matched " + count + " times in the following list:");
        String separator = String.format("%n") + "          ";
        mismatchDescriptor.appendValueList(separator, separator, "", items);

    }
    return okay;
}
 
public static Matcher<Git> hasTag(final String tag) {
    return new TypeSafeDiagnosingMatcher<Git>() {
        @Override
        protected boolean matchesSafely(Git repo, Description mismatchDescription) {
            try {
                mismatchDescription.appendValueList("a git repo with tags: ", ", ", "", repo.getRepository().getTags().keySet());
                return GitHelper.hasLocalTag(repo, tag);
            } catch (Exception e) {
                throw new RuntimeException("Couldn't access repo", e);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("a git repo with the tag " + tag);
        }
    };
}
 
public static Matcher<Git> hasCleanWorkingDirectory() {
    return new TypeSafeDiagnosingMatcher<Git>() {
        @Override
        protected boolean matchesSafely(Git git, Description mismatchDescription) {
            try {
                Status status = git.status().call();
                if (!status.isClean()) {
                    String start = "Uncommitted changes in ";
                    String end = " at " + git.getRepository().getWorkTree().getAbsolutePath();
                    mismatchDescription.appendValueList(start, ", ", end, status.getUncommittedChanges());
                }
                return status.isClean();
            } catch (GitAPIException e) {
                throw new RuntimeException("Error checking git status", e);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("A git directory with no staged or unstaged changes");
        }
    };
}
 
源代码6 项目: joynr   文件: ReflectionsTest.java
public <T> Matcher<Set<? super T>> are(final T... ts) {
    final Collection<?> c1 = Arrays.asList(ts);
    return new BaseMatcher<Set<? super T>>() {
        public boolean matches(Object o) {
            Collection<?> c2 = (Collection<?>) o;
            return c1.containsAll(c2) && c2.containsAll(c1);
        }

        public void describeTo(Description description) {
            description.appendText("elements: ");
            description.appendValueList("(", ",", ")", ts);
        }
    };
}
 
源代码7 项目: dremio-oss   文件: UserExceptionMatcher.java
@Override
public void describeTo(final Description description) {
  description.appendText("UserException of type: ")
    .appendValue(expectedType.toString());
  if (expectedMessage != null) {
    description.appendText(" with message that contains: \"")
      .appendText(expectedMessage)
      .appendText("\"");
  }
  if (expectedContexts != null) {
    description.appendValueList(" with contexts that contain every one of {", ",", "}", expectedContexts);
  }
}
 
源代码8 项目: dremio-oss   文件: UserExceptionMatcher.java
@Override
protected void describeMismatchSafely(final UserException e, final Description description) {
  description.appendText("UserException thrown was of type: ")
    .appendValue(e.getErrorType().toString());
  if (expectedMessage != null) {
    description.appendText(" with message: \"")
      .appendText(e.getMessage())
    .appendText("\"");
  }
  if (expectedContexts != null) {
    description.appendValueList(" with contexts {", ",", "}", e.getContextStrings());
  }
}
 
源代码9 项目: strimzi-kafka-operator   文件: HasNoneOfReasons.java
@Override
@SuppressWarnings("unchecked")
public void describeMismatch(Object item, Description description) {
    describeTo(description);
    description.appendValueList(" but actual event reasons were {", ", ", "}.",
            ((List<Event>) item).stream().map(evt -> {
                String objRef = "";
                if (evt.getInvolvedObject() != null) {
                    objRef = " involved object: " + evt.getInvolvedObject().getKind() + "/" + evt.getInvolvedObject().getName();
                }
                return evt.getReason() + " (" + evt.getType() + " " + evt.getMessage() + objRef + ")\n";
            })
                    .collect(Collectors.toList()));
}
 
private void context(String sourceCode, String methodName, Description mismatchDescription) {
    if (!sourceCode.contains(methodName)) {
        mismatchDescription.appendText("You did not appear to invoke the method at all.");
    } else {
        String[] lines = sourceCode.split("\\n");
        mismatchDescription.appendText("Actual invocations: ");
        mismatchDescription.appendValueList("[", ",", "]",
                Arrays.stream(lines).filter(l -> l.contains(methodName)).map(String::trim).collect(toList()));
    }
}
 
源代码11 项目: matchers-java   文件: HasCookieMatcher.java
@Override
protected void describeMismatchSafely(WebDriver item, Description mismatchDescription) {
    mismatchDescription.appendText("was only ");
    List<String> cookNames = new LinkedList<>();
    for (Cookie cook : item.manage().getCookies()) {
       cookNames.add(cook.getName());
    }
    mismatchDescription.appendValueList("[", ", ", "]", cookNames);
}
 
@Override
public void describeTo(Description description) {
	description.appendValueList("<[", ", ", "]>", executionStages);
}
 
源代码13 项目: styx   文件: JVMMetricsHandlerTest.java
@Override
public void describeTo(Description description) {
    description.appendValueList("[", ",", "]", this.substrings);
}
 
源代码14 项目: docker-compose-rule   文件: AvailablePortMatcher.java
@Override
protected void describeMismatchSafely(Collection<DockerPort> unavailablePorts, Description mismatchDescription) {
    mismatchDescription.appendValueList("These ports were unavailable:\n", "\n", ".", buildClosedPortsErrorMessage(unavailablePorts));
}
 
源代码15 项目: strimzi-kafka-operator   文件: HasAnyOfReasons.java
@Override
public void describeTo(Description description) {
    description.appendValueList("The resource should contain at least one the following events {", ", ", "}. ", eventReasons);
}
 
源代码16 项目: strimzi-kafka-operator   文件: HasAllOfReasons.java
@Override
public void describeTo(Description description) {
    description.appendValueList("The resource should contain all of the following events {", ", ", "}. ", eventReasons);
}
 
源代码17 项目: vespa   文件: ContainsSameElements.java
private void appendCollection(Description description, Collection<?> collection) {
    description.appendValueList("{", ", ", "}", elementsToStringSorted(collection));
}
 
源代码18 项目: p4ic4idea   文件: CollectionsMatchers.java
@Override
public void describeTo(Description description) {
    description.appendValueList("a collection which contains ", ", ", ".", items);
}
 
源代码19 项目: p4ic4idea   文件: CollectionsMatchers.java
@Override
public void describeTo(Description description) {
    description.appendValueList("a collection which contains ", ", ", ".", items);
}
 
源代码20 项目: strimzi-kafka-operator   文件: HasNoneOfReasons.java
/**
 * Generates a description of the object.  The description may be part of a
 * a description of a larger object of which this is just a component, so it
 * should be worded appropriately.
 *
 * @param description The description to be built or appended to.
 */
@Override
public void describeTo(Description description) {
    description.appendValueList("The resource should not contain no events with any of the reasons {", ", ", "}, ",
            prohibitedEvents);
}