本文整理汇总了Java中org.hamcrest.SelfDescribing类的典型用法代码示例。如果您正苦于以下问题:Java SelfDescribing类的具体用法?Java SelfDescribing怎么用?Java SelfDescribing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelfDescribing类属于org.hamcrest包,在下文中一共展示了SelfDescribing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commandDescription
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private SelfDescribing commandDescription(final Command cmd) {
return description -> {
final String newLine = System.getProperty("line.separator");
final List<String> logContents =
logsOfInternalTests(cmd.getErrorLines()).collect(Collectors.toList());
description
.appendText("std-error:\n")
.appendValueList("", newLine, newLine, cmd.getErrorLines());
if (!logContents.isEmpty()) {
description
.appendText("Contents of internal test logs:\n")
.appendText("*******************************\n")
.appendValueList(newLine, newLine, newLine, logContents);
}
};
}
示例2: transformedBy
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
static <T,V> Matcher<? super Collection<T>> transformedBy(final Function<T, V> function, final Matcher<Collection<V>> underlying) {
return new TypeSafeMatcher<Collection<T>>() {
@Override
protected boolean matchesSafely(final Collection<T> item) {
return underlying.matches(
Lists.newArrayList(Iterables.transform(item, function)));
}
@Override
public void describeTo(Description description) {
description.appendText("transformed by ");
if(function instanceof SelfDescribing) {
SelfDescribing selfDescribingFunction = (SelfDescribing) function;
description.appendDescriptionOf(selfDescribingFunction);
} else {
description.appendText("function ");
}
description.appendDescriptionOf(underlying);
}
};
}
示例3: describeTo
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
public void describeTo(Description description) {
description.appendText("expected ");
cardinality.describeExpected(description);
description.appendText(", invoked ");
cardinality.describeCount(description);
description.appendText(": ");
description.appendText(invocable.getName());
description.appendList("(", ", ", ")", argMatchers);
if (exceptionMatcher != null) {
description.appendText(", expected to throw ");
exceptionMatcher.describeTo(description);
} else if (returnValueMatcher != null) {
description.appendText(", expected to return ");
returnValueMatcher.describeTo(description);
}
if (handler instanceof SelfDescribing) {
description.appendText(" (will ");
((SelfDescribing) handler).describeTo(description);
description.appendText(")");
} else if (handler != null) {
description.appendText(" (handled by ");
description.appendValue(handler);
description.appendText(")");
}
}
示例4: describedWith
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private Iterable<SelfDescribing> describedWith(List<Expectation> expectations, final Invocation invocation) {
final Iterator<Expectation> iterator = expectations.iterator();
return new Iterable<SelfDescribing>() {
public Iterator<SelfDescribing> iterator() {
return new Iterator<SelfDescribing>() {
public boolean hasNext() { return iterator.hasNext(); }
public SelfDescribing next() {
return new SelfDescribing() {
public void describeTo(Description description) {
iterator.next().describeMismatch(invocation, description);
}
};
}
public void remove() { iterator.remove(); }
};
}
};
}
示例5: appendList
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
@Override
public Description appendList(String start, String separator, String end, Iterable<? extends SelfDescribing> values) {
append(start);
boolean first = true;
for (SelfDescribing selfDescribing : values) {
if (!first) {
append(separator);
} else {
first = false;
}
selfDescribing.describeTo(this);
}
append(end);
return this;
}
示例6: withExtraTypeInfo
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
public SelfDescribing withExtraTypeInfo() {
return new SelfDescribing() {
@Override
public void describeTo(final Description description) {
description.appendText("(" + wanted.getClass().getSimpleName() + ") ").appendText(describe(wanted));
}
};
}
示例7: convertErrors
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private Iterable<SelfDescribing> convertErrors(final List<String> errors) {
return errors.stream().map((it) -> {
return new SelfDescribing() {
@Override public void describeTo(final Description description) {
description.appendText(it);
}
};
}).collect(Collectors.toList());
}
示例8: describe
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private void describe(Description description, Object value) {
if (value instanceof SelfDescribing) {
description.appendDescriptionOf((SelfDescribing) value);
} else {
description.appendValue(value);
}
}
示例9: describe
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private List<SelfDescribing> describe(List<Method> conflicts) {
List<SelfDescribing> descriptions = new ArrayList<SelfDescribing>(conflicts.size());
for (Method conflict : conflicts) {
descriptions.add(new Signature(methodSignature(conflict.getName(), conflict.getReturnType(), conflict.getParameterTypes(), conflict.getExceptionTypes())));
}
return descriptions;
}
示例10: describe
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private List<SelfDescribing> describe(List<Method> conflicts) {
List<SelfDescribing> descriptions = new ArrayList<SelfDescribing>(conflicts.size());
for (Method conflict : conflicts) {
StringBuilder buffer = new StringBuilder();
buffer.append(conflict.getReturnType().getSimpleName());
buffer.append(' ');
buffer.append(conflict.getName());
buffer.append('(');
Class<?>[] parameterTypes = conflict.getParameterTypes();
if (parameterTypes.length > 0) {
buffer.append(parameterTypes[0].getSimpleName());
}
for (int i = 1; i < parameterTypes.length; i++) {
buffer.append(", ");
buffer.append(parameterTypes[i].getSimpleName());
}
buffer.append(')');
Class<?>[] exceptionTypes = conflict.getExceptionTypes();
if (exceptionTypes.length > 0) {
buffer.append(" throws ");
buffer.append(exceptionTypes[0].getSimpleName());
for (int i = 1; i < exceptionTypes.length; i++) {
buffer.append(", ");
buffer.append(exceptionTypes[i].getSimpleName());
}
}
descriptions.add(new Signature(buffer.toString()));
}
return descriptions ;
}
示例11: applyPrintSettings
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
private List<SelfDescribing> applyPrintSettings(List<Matcher> matchers, PrintSettings printSettings) {
List<SelfDescribing> withPrintSettings = new LinkedList<SelfDescribing>();
int i = 0;
for (final Matcher matcher : matchers) {
if (matcher instanceof ContainsExtraTypeInformation && printSettings.extraTypeInfoFor(i)) {
withPrintSettings.add(((ContainsExtraTypeInformation) matcher).withExtraTypeInfo());
} else {
withPrintSettings.add(matcher);
}
i++;
}
return withPrintSettings;
}
示例12: NotFoundNearestMatchersReducedListFilterResult
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
public NotFoundNearestMatchersReducedListFilterResult(
SelfDescribing baseWithoutMatchers,
CollectionOf<E> foundElements,
Description mismatchDescription) {
super(foundElements, mismatchDescription);
this.baseWithoutCurrentMatcher = baseWithoutMatchers;
}
示例13: WithinSingleContextChecker
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
public WithinSingleContextChecker(ExpectationChecker<C0> parentChecker,
SFinder<E0, C0> contextFinder, SelfDescribing parentContextDescription, String eachString) {
super(null);
this.contextFinder = contextFinder;
this.parentContextDescription = parentContextDescription;
this.eachString = eachString;
this.parentChecker = parentChecker;
}
示例14: WithinEachContextChecker
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
public WithinEachContextChecker(CollectionOf<C0> parentContexts,
MFinder<E0, C0> contextFinder, SelfDescribing parentContextDescription, String eachString) {
super(null);
this.parentContexts = parentContexts;
this.contextFinder = contextFinder;
this.parentContextDescription = parentContextDescription;
this.eachString = eachString;
}
示例15: describable
import org.hamcrest.SelfDescribing; //导入依赖的package包/类
@Override
public SelfDescribing describable(final Object thing) {
return new SelfDescribing() {
@Override
public void describeTo(Description description) {
description.appendText(thing.toString());
}
};
}