当前位置: 首页>>代码示例>>Java>>正文


Java ThrowableAssert.ThrowingCallable方法代码示例

本文整理汇总了Java中org.assertj.core.api.ThrowableAssert.ThrowingCallable方法的典型用法代码示例。如果您正苦于以下问题:Java ThrowableAssert.ThrowingCallable方法的具体用法?Java ThrowableAssert.ThrowingCallable怎么用?Java ThrowableAssert.ThrowingCallable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.assertj.core.api.ThrowableAssert的用法示例。


在下文中一共展示了ThrowableAssert.ThrowingCallable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldKeepDescriptionInErrorMessage

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
@Test
public void shouldKeepDescriptionInErrorMessage() {
    //given
    final String DESCRIPTION = "minimum range closer than 100";
    //when
    ts.findNumberOfShipsInRangeByCriteria(searchCriteria);
    //then
    ThrowableAssert.ThrowingCallable verifyLambda = () -> {
        verify(ts).findNumberOfShipsInRangeByCriteria(argLambda(c -> c.getMinimumRange() < 100, DESCRIPTION));
    };
    assertThatThrownBy(verifyLambda)
            .isInstanceOf(AssertionError.class)
            .hasMessageContaining("Argument(s) are different! Wanted:\n" +
                    "ts.findNumberOfShipsInRangeByCriteria(\n" +
                    "    " + DESCRIPTION + "\n" +
                    ");")
            .hasMessageContaining("Actual invocation has different arguments:\n" +
                    "ts.findNumberOfShipsInRangeByCriteria(\n" +
                    "    ShipSearchCriteria{minimumRange=1000, numberOfPhasers=4}\n" +
                    ");");

}
 
开发者ID:szpak,项目名称:mockito-java8,代码行数:23,代码来源:LambdaMatcherTest.java

示例2: shouldHaveMeaningfulErrorMessage

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
@Test
public void shouldHaveMeaningfulErrorMessage() {
    //when
    ts.findNumberOfShipsInRangeByCriteria(searchCriteria);
    //then
    ThrowableAssert.ThrowingCallable verifyLambda = () -> {
        verify(ts).findNumberOfShipsInRangeByCriteria(assertArg(sc -> assertThat(sc.getMinimumRange()).isLessThan(50)));
    };
    assertThatThrownBy(verifyLambda)
            .isInstanceOf(AssertionError.class)
            .hasMessageContaining("Argument(s) are different! Wanted:\n" +
                    "ts.findNumberOfShipsInRangeByCriteria(\n" +
                    "    AssertionMatcher reported: \n" +
                    "Expecting:\n" +
                    " <1000>\n" +
                    "to be less than:\n" +
                    " <50> ")
            .hasMessageContaining("Actual invocation has different arguments:\n" +
                    "ts.findNumberOfShipsInRangeByCriteria(\n" +
                    "    ShipSearchCriteria{minimumRange=1000, numberOfPhasers=4}\n" +
                    ");");
}
 
开发者ID:szpak,项目名称:mockito-java8,代码行数:23,代码来源:AssertionMatcherTest.java

示例3: shouldFailOnInvalidSelectKeyword

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
@Test
public void shouldFailOnInvalidSelectKeyword() {
    // given
    String query = "selectx * from cars";

    // when
    ThrowableAssert.ThrowingCallable when = () -> sqlParser.parse(query);

    // then
    assertThatThrownBy(when).isInstanceOf(InvalidQueryException.class);
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:12,代码来源:SqlParserUT.java

示例4: verifyUnsupportedOperation

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private void verifyUnsupportedOperation(ThrowableAssert.ThrowingCallable operation) {
    // when
    Throwable ex = catchThrowable(operation);

    // then
    assertThat(ex).isInstanceOf(UnsupportedOperationException.class);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:8,代码来源:HttpServletResponseWrapperForResponseInfoTest.java

示例5: catchGAWrapperException

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
/**
 * Convenience method to catch a {@link GAWrapperException} and cast the return value to that type.
 * <b>Only use this when you're expecting the enclosed code to throw that exception.</b>
 * If the enclosed code doesn't throw the expected {@link GAWrapperException}, this method calls
 * {@link org.assertj.core.api.StrictAssertions#fail(String)} to cause the enclosing test to fail
 * and log the stack trace.
 * @param thisShouldThrow the {@link Callable} we're calling, which should throw {@link GAWrapperException}
 * @return the {@link Throwable} thrown in the execution of the {@link Callable}
 */
public static GAWrapperException catchGAWrapperException(ThrowableAssert.ThrowingCallable
                                                                 thisShouldThrow) {
    final GAWrapperException maybeAnException =
            (GAWrapperException)catchThrowable(thisShouldThrow);
    if (maybeAnException == null) {
        // we were expecting an exception and didn't get one.  log it as a failure.
        fail("Expected but did not receive GAWrapperException");
    }
    return maybeAnException;
}
 
开发者ID:ga4gh,项目名称:compliance,代码行数:20,代码来源:Utils.java

示例6: assertCodeException

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private static void assertCodeException(Code expectedCode, ThrowableAssert.ThrowingCallable call) {
    CoapCodeException ex = (CoapCodeException) catchThrowable(call);
    assertEquals(expectedCode, ex.getCode());
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:5,代码来源:BlockWiseIncomingTransactionTest.java

示例7: shouldThrowExceptionWhenSessionIsInvalidated

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private void shouldThrowExceptionWhenSessionIsInvalidated(ThrowableAssert.ThrowingCallable op) {
    when(session.isDestroyed()).thenReturn(true);
    assertThatExceptionOfType(IllegalStateException.class).isThrownBy(op);
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:5,代码来源:VertxWrappedSessionUT.java

示例8: assertThatThrownBy

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private AbstractThrowableAssert<?, ?> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return org.assertj.core.api.Assertions.assertThatThrownBy(shouldRaiseThrowable)
            .isInstanceOf(AssertionError.class);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:5,代码来源:AssertionsTest.java

示例9: assertSNSThrownBy

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private static AWSThrowableAssert assertSNSThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return assertThatThrownBy(shouldRaiseThrowable)
            .hasRequestId()
            .hasServiceName("AmazonSNS")
            .hasErrorType(Client);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:7,代码来源:AmazonSNSFakeCreateTopicTest.java

示例10: assertSNSParamThrownBy

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private static AWSThrowableAssert assertSNSParamThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return assertSNSThrownBy(shouldRaiseThrowable)
            .isInstanceOf(InvalidParameterException.class)
            .hasErrorCode("InvalidParameter")
            .hasStatusCode(400);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:7,代码来源:AmazonSNSFakePublishTest.java

示例11: assertTimeoutOccurred

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
private void assertTimeoutOccurred(ThrowableAssert.ThrowingCallable throwingCallable) {
  assertThatExceptionOfType(StoreAccessException.class)
    .isThrownBy(throwingCallable)
    .withCauseInstanceOf(TimeoutException.class);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:6,代码来源:ClusteredStoreTest.java

示例12: assertThatCode

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
/**
 * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThatCode(org.assertj.core.api.ThrowableAssert$ThrowingCallable)
 * {@link org.assertj.core.api.Assertions#assertThatCode(org.assertj.core.api.ThrowableAssert$ThrowingCallable)}
 */
default AbstractThrowableAssert<?, ? extends Throwable> assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable) {
    return Assertions.assertThatCode(shouldRaiseOrNotThrowable);
}
 
开发者ID:aro-tech,项目名称:extended-mockito,代码行数:8,代码来源:AssertJ.java

示例13: assertThatThrownBy

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
/**
 * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable)
 * {@link org.assertj.core.api.Assertions#assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable)}
 */
default AbstractThrowableAssert<?, ? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return Assertions.assertThatThrownBy(shouldRaiseThrowable);
}
 
开发者ID:aro-tech,项目名称:extended-mockito,代码行数:8,代码来源:AssertJ.java

示例14: catchThrowable

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
/**
 * Delegate call to public static java.lang.Throwable org.assertj.core.api.Assertions.catchThrowable(org.assertj.core.api.ThrowableAssert$ThrowingCallable)
 * {@link org.assertj.core.api.Assertions#catchThrowable(org.assertj.core.api.ThrowableAssert$ThrowingCallable)}
 */
default Throwable catchThrowable(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return Assertions.catchThrowable(shouldRaiseThrowable);
}
 
开发者ID:aro-tech,项目名称:extended-mockito,代码行数:8,代码来源:AssertJ.java

示例15: catchThrowableOfType

import org.assertj.core.api.ThrowableAssert; //导入方法依赖的package包/类
/**
 * Delegate call to public static <THROWABLE> THROWABLE org.assertj.core.api.Assertions.catchThrowableOfType(org.assertj.core.api.ThrowableAssert$ThrowingCallable,java.lang.Class<THROWABLE>)
 * {@link org.assertj.core.api.Assertions#catchThrowableOfType(org.assertj.core.api.ThrowableAssert$ThrowingCallable,java.lang.Class)}
 */
default <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, Class<THROWABLE> type) {
    return Assertions.catchThrowableOfType(shouldRaiseThrowable, type);
}
 
开发者ID:aro-tech,项目名称:extended-mockito,代码行数:8,代码来源:AssertJ.java


注:本文中的org.assertj.core.api.ThrowableAssert.ThrowingCallable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。