Java 类org.hamcrest.SelfDescribing 实例源码

项目:bazel-integration-testing    文件:BazelBaseTestCaseTest.java   
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);
    }
  };
}
项目:isis-module-security    文件:ApplicationFeaturesIntegTest.java   
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);
        }
    };
}
项目:moxiemocks    文件:ExpectationImpl.java   
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(")");
    }
}
项目:jMock-Demo    文件:InvocationDispatcher.java   
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(); }
            };
        }
    };
}
项目:cortado    文件:RecordingDescription.java   
@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;
}
项目:cosmic    文件:HttpRequestMatcher.java   
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        @Override
        public void describeTo(final Description description) {
            description.appendText("(" + wanted.getClass().getSimpleName() + ") ").appendText(describe(wanted));
        }
    };
}
项目:hacking-java    文件:AbstractCompilerTest.java   
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());
}
项目:testrecorder    文件:GenericMatcher.java   
private void describe(Description description, Object value) {
    if (value instanceof SelfDescribing) {
        description.appendDescriptionOf((SelfDescribing) value);
    } else {
        description.appendValue(value);
    }
}
项目:xrayinterface    文件:XRayMatcher.java   
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;
}
项目:xrayinterface    文件:ClassUnlockableMatcher.java   
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 ;
}
项目:picklock    文件:PicklockMatcher.java   
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;
}
项目:picklock    文件:ClassUnlockableMatcher.java   
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 ;
}
项目:astor    文件:MatchersPrinter.java   
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;
}
项目:astor    文件:MatchersPrinter.java   
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;
}
项目:redsniff    文件:NotFoundNearestMatchersReducedListFilterResult.java   
public NotFoundNearestMatchersReducedListFilterResult(
        SelfDescribing baseWithoutMatchers,
        CollectionOf<E> foundElements, 
        Description mismatchDescription) {
    super(foundElements, mismatchDescription);
    this.baseWithoutCurrentMatcher = baseWithoutMatchers;
}
项目:redsniff    文件:WithinSingleContextChecker.java   
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;
}
项目:redsniff    文件:WithinEachContextChecker.java   
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;
}
项目:redsniff    文件:ObjectDescribaliser.java   
@Override
public SelfDescribing describable(final Object thing) {
    return new SelfDescribing() {
        @Override
        public void describeTo(Description description) {
            description.appendText(thing.toString());
        }
    };
}
项目:redsniff    文件:SelfDescribingDescribaliser.java   
@Override
public SelfDescribing describable(final SelfDescribing thing) {
    return new SelfDescribing() {
        @Override
        public void describeTo(Description description) {
            description.appendDescriptionOf(thing);
        }
    };
}
项目:moxiemocks    文件:ExpectationImpl.java   
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(", ");
        }
    }
}
项目:moxiemocks    文件:SimpleDescription.java   
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;
}
项目:cloudstack    文件:HttpRequestMatcher.java   
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        @Override
        public void describeTo(final Description description) {
            description.appendText("(" + wanted.getClass().getSimpleName() + ") ").appendText(describe(wanted));
        }
    };
}
项目:jMock-Demo    文件:Mockery.java   
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;
}
项目:jMock-Demo    文件:InvocationDispatcher.java   
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);
        }
    }
}
项目:atlassian-hamcrest    文件:QueueingDescription.java   
@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;
}
项目:atlassian-hamcrest    文件:IndentingDescription.java   
@Override
public Description appendList(
    String start,
    String separator,
    String end,
    Iterable<? extends SelfDescribing> values) {
    indentIfNecessary();
    description.appendList(start, separator, end, values);
    return this;
}
项目:cortado    文件:RecordingDescription.java   
@Override
public Description appendDescriptionOf(SelfDescribing value) {
    value.describeTo(this);
    return this;
}
项目:mesfavoris    文件:SWTBotForm.java   
public SWTBotForm(Form form, SelfDescribing description) throws WidgetNotFoundException {
    super(form, description);
}
项目:dsl-devkit    文件:SwtBotButton.java   
public SwtBotButton(final Button button, final SelfDescribing description) {
  super(button, description);
}
项目:delboy    文件:PropertiesMatcher.java   
private SelfDescribing mismatch(Matcher<?> matcher, Object item) {
    return d -> matcher.describeMismatch(item, d);
}
项目:delboy    文件:MatcherAssertions.java   
public static String describe(SelfDescribing selfDescribing) {
    StringDescription description = new StringDescription();
    selfDescribing.describeTo(description);
    return description.toString();
}
项目:eHMP    文件:SelfDescribingValueIterator.java   
public SelfDescribing next() {
    return new SelfDescribingValue<T>(values.next());
}
项目:astor    文件:Equals.java   
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        public void describeTo(Description description) {
            description.appendText(describe("("+ wanted.getClass().getSimpleName() +") " + wanted));
        }};
}
项目:astor    文件:TestBase.java   
protected static String describe(SelfDescribing m) {
    return StringDescription.toString(m);
}
项目:astor    文件:Equals.java   
public SelfDescribing withExtraTypeInfo() {
    return new SelfDescribing() {
        public void describeTo(Description description) {
            description.appendText(describe("("+ wanted.getClass().getSimpleName() +") " + wanted));
        }};
}
项目:astor    文件:TestBase.java   
protected static String describe(SelfDescribing m) {
    return StringDescription.toString(m);
}
项目:redsniff    文件:NoBaseFilterResult.java   
public NoBaseFilterResult(SelfDescribing baseWithoutMatchers, CollectionOf<E> foundElements) {
    super(foundElements);
    this.baseWithoutMatchers = baseWithoutMatchers;
}
项目:redsniff    文件:MFinderThatHasCondition.java   
protected MatcherFilterer<E> createMatcherFiltererFor(
        SelfDescribing baseWithoutThisMatcher,
        Matcher<? super E> matcher) {
    return new SimpleMatcherFilterer<E>(baseWithoutThisMatcher, new MatcherFilter<E>(matcher), optimized);
}
项目:redsniff    文件:MFinderThatHasCondition.java   
@Override
protected MatcherFilterer<E> createMatcherFiltererFor(
        SelfDescribing baseWithoutThisMatcher,
        Matcher<? super E> matcher) {
    return new WrappingMatcherFilterer<E>(baseWithoutThisMatcher, new MatcherFilter<E>(matcher), this.optimized);
}
项目:redsniff    文件:WrappingMatcherFilterer.java   
public WrappingMatcherFilterer(
        SelfDescribing baseWithoutMatchers,
        MatcherFilter<E> matcherFilter, boolean optimized) {
    super(baseWithoutMatchers, matcherFilter, optimized);
}