java类org.hamcrest.SelfDescribing的实例源码

BazelBaseTestCaseTest.java 文件源码 项目:bazel-integration-testing 阅读 31 收藏 0 点赞 0 评论 0
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);
    }
  };
}
ApplicationFeaturesIntegTest.java 文件源码 项目:isis-module-security 阅读 25 收藏 0 点赞 0 评论 0
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);
        }
    };
}
ExpectationImpl.java 文件源码 项目:moxiemocks 阅读 31 收藏 0 点赞 0 评论 0
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(")");
    }
}
InvocationDispatcher.java 文件源码 项目:jMock-Demo 阅读 35 收藏 0 点赞 0 评论 0
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(); }
            };
        }
    };
}
RecordingDescription.java 文件源码 项目:cortado 阅读 29 收藏 0 点赞 0 评论 0
@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;
}
HttpRequestMatcher.java 文件源码 项目:cosmic 阅读 32 收藏 0 点赞 0 评论 0
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        @Override
        public void describeTo(final Description description) {
            description.appendText("(" + wanted.getClass().getSimpleName() + ") ").appendText(describe(wanted));
        }
    };
}
AbstractCompilerTest.java 文件源码 项目:hacking-java 阅读 26 收藏 0 点赞 0 评论 0
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());
}
GenericMatcher.java 文件源码 项目:testrecorder 阅读 35 收藏 0 点赞 0 评论 0
private void describe(Description description, Object value) {
    if (value instanceof SelfDescribing) {
        description.appendDescriptionOf((SelfDescribing) value);
    } else {
        description.appendValue(value);
    }
}
XRayMatcher.java 文件源码 项目:xrayinterface 阅读 30 收藏 0 点赞 0 评论 0
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;
}
ClassUnlockableMatcher.java 文件源码 项目:xrayinterface 阅读 31 收藏 0 点赞 0 评论 0
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 ;
}
PicklockMatcher.java 文件源码 项目:picklock 阅读 30 收藏 0 点赞 0 评论 0
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;
}
ClassUnlockableMatcher.java 文件源码 项目:picklock 阅读 32 收藏 0 点赞 0 评论 0
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 ;
}
MatchersPrinter.java 文件源码 项目:astor 阅读 29 收藏 0 点赞 0 评论 0
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;
}
MatchersPrinter.java 文件源码 项目:astor 阅读 29 收藏 0 点赞 0 评论 0
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;
}
NotFoundNearestMatchersReducedListFilterResult.java 文件源码 项目:redsniff 阅读 34 收藏 0 点赞 0 评论 0
public NotFoundNearestMatchersReducedListFilterResult(
        SelfDescribing baseWithoutMatchers,
        CollectionOf<E> foundElements, 
        Description mismatchDescription) {
    super(foundElements, mismatchDescription);
    this.baseWithoutCurrentMatcher = baseWithoutMatchers;
}
WithinSingleContextChecker.java 文件源码 项目:redsniff 阅读 36 收藏 0 点赞 0 评论 0
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;
}
WithinEachContextChecker.java 文件源码 项目:redsniff 阅读 32 收藏 0 点赞 0 评论 0
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;
}
ObjectDescribaliser.java 文件源码 项目:redsniff 阅读 28 收藏 0 点赞 0 评论 0
@Override
public SelfDescribing describable(final Object thing) {
    return new SelfDescribing() {
        @Override
        public void describeTo(Description description) {
            description.appendText(thing.toString());
        }
    };
}
SelfDescribingDescribaliser.java 文件源码 项目:redsniff 阅读 36 收藏 0 点赞 0 评论 0
@Override
public SelfDescribing describable(final SelfDescribing thing) {
    return new SelfDescribing() {
        @Override
        public void describeTo(Description description) {
            description.appendDescriptionOf(thing);
        }
    };
}
ExpectationImpl.java 文件源码 项目:moxiemocks 阅读 36 收藏 0 点赞 0 评论 0
public void describeTo(Description description) {
    description.appendText("consecutively ");

    for (Iterator<MethodIntercept> it = handlers.iterator(); it.hasNext(); ) {
        MethodIntercept handler = it.next();
        if (handler instanceof SelfDescribing) {
            ((SelfDescribing) handler).describeTo(description);
        } else {
            description.appendValue(handler);
        }
        if (it.hasNext()) {
            description.appendText(", ");
        }
    }
}
SimpleDescription.java 文件源码 项目:moxiemocks 阅读 95 收藏 0 点赞 0 评论 0
public Description appendList(String start, String separator, String end, Iterable<? extends SelfDescribing> values) {
    stringBuilder.append(start);
    boolean first = true;
    for (SelfDescribing value : values) {
        if (!first) {
            stringBuilder.append(separator);
        }
        first = false;
        value.describeTo(this);
    }
    stringBuilder.append(end);
    return this;
}
HttpRequestMatcher.java 文件源码 项目:cloudstack 阅读 36 收藏 0 点赞 0 评论 0
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        @Override
        public void describeTo(final Description description) {
            description.appendText("(" + wanted.getClass().getSimpleName() + ") ").appendText(describe(wanted));
        }
    };
}
Mockery.java 文件源码 项目:jMock-Demo 阅读 28 收藏 0 点赞 0 评论 0
private ExpectationError mismatchDescribing(final ExpectationError e) {
    ExpectationError filledIn = new ExpectationError(e.getMessage(), new SelfDescribing() {
        public void describeTo(Description description) {
            describeMismatch(e.invocation, description);
        }
    }, e.invocation);
    filledIn.setStackTrace(e.getStackTrace());
    return filledIn;
}
InvocationDispatcher.java 文件源码 项目:jMock-Demo 阅读 32 收藏 0 点赞 0 评论 0
private void describe(Description description, Iterable<? extends SelfDescribing> selfDescribingExpectations) {
    if (expectations.isEmpty()) {
        description.appendText("no expectations specified: did you...\n"+
                               " - forget to start an expectation with a cardinality clause?\n" +
                               " - call a mocked method to specify the parameter of an expectation?");
    }
    else {
        description.appendList("expectations:\n  ", "\n  ", "", selfDescribingExpectations);
        if (!stateMachines.isEmpty()) {
            description.appendList("\nstates:\n  ", "\n  ", "", stateMachines);
        }
    }
}
QueueingDescription.java 文件源码 项目:atlassian-hamcrest 阅读 38 收藏 0 点赞 0 评论 0
@Override
public Description appendList(
    final String start, final String separator, final String end, final Iterable<? extends SelfDescribing> values) {
    enqueue(new Runnable() {
        @Override
        public void run() {
            description.appendList(start, separator, end, values);
        }
    });
    return this;
}
IndentingDescription.java 文件源码 项目:atlassian-hamcrest 阅读 28 收藏 0 点赞 0 评论 0
@Override
public Description appendList(
    String start,
    String separator,
    String end,
    Iterable<? extends SelfDescribing> values) {
    indentIfNecessary();
    description.appendList(start, separator, end, values);
    return this;
}
RecordingDescription.java 文件源码 项目:cortado 阅读 27 收藏 0 点赞 0 评论 0
@Override
public Description appendDescriptionOf(SelfDescribing value) {
    value.describeTo(this);
    return this;
}
SWTBotForm.java 文件源码 项目:mesfavoris 阅读 30 收藏 0 点赞 0 评论 0
public SWTBotForm(Form form, SelfDescribing description) throws WidgetNotFoundException {
    super(form, description);
}
SwtBotButton.java 文件源码 项目:dsl-devkit 阅读 34 收藏 0 点赞 0 评论 0
public SwtBotButton(final Button button, final SelfDescribing description) {
  super(button, description);
}
PropertiesMatcher.java 文件源码 项目:delboy 阅读 31 收藏 0 点赞 0 评论 0
private SelfDescribing mismatch(Matcher<?> matcher, Object item) {
    return d -> matcher.describeMismatch(item, d);
}


问题


面经


文章

微信
公众号

扫码关注公众号