org.mockito.internal.debugging.LocationImpl源码实例Demo

类org.mockito.internal.debugging.LocationImpl源码实例Demo

下面列出了org.mockito.internal.debugging.LocationImpl 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: astor   文件: Reporter.java
public void incorrectUseOfAdditionalMatchers(String additionalMatcherName, int expectedSubMatchersCount, Collection<LocalizedMatcher> matcherStack) {
    throw new InvalidUseOfMatchersException(join(
            "Invalid use of argument matchers inside additional matcher " + additionalMatcherName + " !",
            new LocationImpl(),
            "",
            expectedSubMatchersCount + " sub matchers expected, " + matcherStack.size() + " recorded:",
            locationsOf(matcherStack),
            "",
            "This exception may occur if matchers are combined with raw values:",
            "    //incorrect:",
            "    someMethod(AdditionalMatchers.and(isNotNull(), \"raw String\");",
            "When using matchers, all arguments have to be provided by matchers.",
            "For example:",
            "    //correct:",
            "    someMethod(AdditionalMatchers.and(isNotNull(), eq(\"raw String\"));",
            "",
            "For more info see javadoc for Matchers and AdditionalMatchers classes.",
            ""
    ));
}
 
源代码2 项目: astor   文件: Reporter.java
public void argumentsAreDifferent(String wanted, String actual, Location actualLocation) {
    String message = join("Argument(s) are different! Wanted:",
            wanted,
            new LocationImpl(),
            "Actual invocation has different arguments:",
            actual,
            actualLocation,
            ""
    );

    if (JUnitTool.hasJUnit()) {
        throw JUnitTool.createArgumentsAreDifferentException(message, wanted, actual);
    } else {
        throw new ArgumentsAreDifferent(message);
    }
}
 
源代码3 项目: astor   文件: LocationImplTest.java
@Test
public void shouldBeSafeInCaseForSomeReasonFilteredStackTraceIsEmpty() {
    //given
    StackTraceFilter filterReturningEmptyArray = new StackTraceFilter() {
        @Override
        public StackTraceElement[] filter(StackTraceElement[] target, boolean keepTop) {
            return new StackTraceElement[0];
        }
    };

    //when
    String loc = new LocationImpl(filterReturningEmptyArray).toString();

    //then
    assertEquals("-> at <<unknown line>>", loc);
}
 
源代码4 项目: astor   文件: Reporter.java
public void incorrectUseOfApi() {
    throw new MockitoException(join(
            "Incorrect use of API detected here:",
            new LocationImpl(),
            "",
            "You probably stored a reference to OngoingStubbing returned by when() and called stubbing methods like thenReturn() on this reference more than once.",
            "Examples of correct usage:",
            "    when(mock.isOk()).thenReturn(true).thenReturn(false).thenThrow(exception);",
            "    when(mock.isOk()).thenReturn(true, false).thenThrow(exception);",
            ""
    ));
}
 
源代码5 项目: astor   文件: Reporter.java
public void reportNoSubMatchersFound(String additionalMatcherName) {
    throw new InvalidUseOfMatchersException(join(
            "No matchers found for additional matcher " + additionalMatcherName,
            new LocationImpl(),
            ""
    ));
}
 
源代码6 项目: astor   文件: Reporter.java
private String createWantedButNotInvokedMessage(DescribedInvocation wanted) {
    return join(
            "Wanted but not invoked:",
            wanted.toString(),
            new LocationImpl(),
            ""
    );
}
 
源代码7 项目: astor   文件: Reporter.java
public void wantedButNotInvokedInOrder(DescribedInvocation wanted, DescribedInvocation previous) {
    throw new VerificationInOrderFailure(join(
            "Verification in order failure",
            "Wanted but not invoked:",
            wanted.toString(),
            new LocationImpl(),
            "Wanted anywhere AFTER following interaction:",
            previous.toString(),
            previous.getLocation(),
            ""
    ));
}
 
源代码8 项目: astor   文件: Reporter.java
private String createTooManyInvocationsMessage(int wantedCount, int actualCount, DescribedInvocation wanted,
                                               Location firstUndesired) {
    return join(
            wanted.toString(),
            "Wanted " + pluralize(wantedCount) + ":",
            new LocationImpl(),
            "But was " + pluralize(actualCount) + ". Undesired invocation:",
            firstUndesired,
            ""
    );
}
 
源代码9 项目: astor   文件: Reporter.java
public void neverWantedButInvoked(DescribedInvocation wanted, Location firstUndesired) {
    throw new NeverWantedButInvoked(join(
            wanted.toString(),
            "Never wanted here:",
            new LocationImpl(),
            "But invoked here:",
            firstUndesired,
            ""
    ));
}
 
源代码10 项目: astor   文件: Reporter.java
private String createTooLittleInvocationsMessage(org.mockito.internal.reporting.Discrepancy discrepancy, DescribedInvocation wanted,
                                                 Location lastActualInvocation) {
    String ending =
            (lastActualInvocation != null)? lastActualInvocation + "\n" : "\n";

    String message = join(
            wanted.toString(),
            "Wanted " + discrepancy.getPluralizedWantedCount() + ":",
            new LocationImpl(),
            "But was " + discrepancy.getPluralizedActualCount() + ":",
            ending
    );
    return message;
}
 
源代码11 项目: astor   文件: Reporter.java
public void noMoreInteractionsWanted(Invocation undesired, List<VerificationAwareInvocation> invocations) {
    ScenarioPrinter scenarioPrinter = new ScenarioPrinter();
    String scenario = scenarioPrinter.print(invocations);

    throw new NoInteractionsWanted(join(
            "No interactions wanted here:",
            new LocationImpl(),
            "But found this interaction:",
            undesired.getLocation(),
            scenario
    ));
}
 
源代码12 项目: astor   文件: Reporter.java
public void noMoreInteractionsWantedInOrder(Invocation undesired) {
    throw new VerificationInOrderFailure(join(
            "No interactions wanted here:",
            new LocationImpl(),
            "But found this interaction:",
            undesired.getLocation(),
            ""
    ));
}
 
源代码13 项目: astor   文件: Reporter.java
public void smartNullPointerException(String invocation, Location location) {
    throw new SmartNullPointerException(join(
            "You have a NullPointerException here:",
            new LocationImpl(),
            "because this method call was *not* stubbed correctly:",
            location,
            invocation,
            ""
    ));
}
 
源代码14 项目: astor   文件: InvocationImpl.java
public InvocationImpl(Object mock, MockitoMethod mockitoMethod, Object[] args, int sequenceNumber, RealMethod realMethod) {
    this.method = mockitoMethod;
    this.mock = mock;
    this.realMethod = realMethod;
    this.arguments = ArgumentsProcessor.expandVarArgs(mockitoMethod.isVarArgs(), args);
    this.rawArguments = args;
    this.sequenceNumber = sequenceNumber;
    this.location = new LocationImpl();
}
 
源代码15 项目: astor   文件: ReturnsSmartNulls.java
public Object answer(final InvocationOnMock invocation) throws Throwable {
    Object defaultReturnValue = delegate.answer(invocation);
    if (defaultReturnValue != null) {
        return defaultReturnValue;
    }
    Class<?> type = invocation.getMethod().getReturnType();
    if (!type.isPrimitive() && !Modifier.isFinal(type.getModifiers())) {
        final Location location = new LocationImpl();
        return Mockito.mock(type, new ThrowsSmartNullPointer(invocation, location));
    }
    return null;
}
 
源代码16 项目: astor   文件: LocalizedMatcher.java
public LocalizedMatcher(Matcher actualMatcher) {
    this.actualMatcher = actualMatcher;
    this.location = new LocationImpl();
}
 
源代码17 项目: astor   文件: MockingProgressImpl.java
public void stubbingStarted() {
    validateState();
    stubbingInProgress = new LocationImpl();
}
 
源代码18 项目: astor   文件: LocationImplTest.java
@Test
public void shouldLocationNotContainGetStackTraceMethod() {
    assertContains("shouldLocationNotContainGetStackTraceMethod", new LocationImpl().toString());
}
 
源代码19 项目: j2objc   文件: LocalizedMatcher.java
public LocalizedMatcher(Matcher actualMatcher) {
    this.actualMatcher = actualMatcher;
    this.location = new LocationImpl();
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法