Java Code Examples for org.assertj.core.api.ThrowableAssert#ThrowingCallable
The following examples show how to use
org.assertj.core.api.ThrowableAssert#ThrowingCallable .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BesuPluginContextImplTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void lifecycleExceptions() throws Throwable { final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); final ThrowableAssert.ThrowingCallable registerPlugins = () -> contextImpl.registerPlugins(new File(".").toPath()); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::startPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins); registerPlugins.call(); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(registerPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins); contextImpl.startPlugins(); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(registerPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::startPlugins); contextImpl.stopPlugins(); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(registerPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::startPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins); }
Example 2
Source File: HeaderBasedPlaceholderSubstitutionAlgorithmTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
private void assertUnknownPlaceholderExceptionIsThrown(final String expectedPlaceholderKey, final ThrowableAssert.ThrowingCallable throwingCallable) { final String expectedMessage = "The placeholder '" + expectedPlaceholderKey + "' is unknown."; final String expectedDescription = "Please use one of the supported placeholders: '" + REPLACER_KEY_1 + "', '" + REPLACER_KEY_2 + "', '" + LEGACY_REPLACER_KEY + "'."; assertGatewayPlaceholderNotResolvableExceptionIsThrown(expectedMessage, expectedDescription, throwingCallable); }
Example 3
Source File: Java9CollectionFactoryMethodsTest.java From hellokoding-courses with MIT License | 5 votes |
@Test public void initNullWithListOfAndSetOf() { String s = null; ThrowableAssert.ThrowingCallable c = () -> new HashSet<>(List.of(s)); assertThatThrownBy(c).isInstanceOf(NullPointerException.class); }
Example 4
Source File: ArrayListSortingTest.java From hellokoding-courses with MIT License | 5 votes |
@Test public void sortNullObject() { List<Integer> lst = new ArrayList<>(Arrays.asList(3, 1, null)); ThrowableAssert.ThrowingCallable c = () -> lst.sort(Comparator.naturalOrder()); assertThatThrownBy(c).isInstanceOf(NullPointerException.class); }
Example 5
Source File: HeaderBasedPlaceholderSubstitutionAlgorithmTest.java From ditto with Eclipse Public License 2.0 | 4 votes |
private void assertUnresolvedPlaceholdersRemainExceptionIsThrown(final String notResolvableInput, final ThrowableAssert.ThrowingCallable throwingCallable) { final String expectedMessage = "The input contains not resolvable placeholders: '" + notResolvableInput + "'."; assertGatewayPlaceholderNotResolvableExceptionIsThrown(expectedMessage, GatewayPlaceholderNotResolvableException.NOT_RESOLVABLE_DESCRIPTION, throwingCallable); }
Example 6
Source File: AsyncApiCallAttemptsTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Override protected Consumer<ThrowableAssert.ThrowingCallable> timeoutExceptionAssertion() { return c -> assertThatThrownBy(c).hasCauseInstanceOf(ApiCallAttemptTimeoutException.class); }
Example 7
Source File: SyncApiCallAttemptTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Override protected Consumer<ThrowableAssert.ThrowingCallable> serviceExceptionAssertion() { return c -> assertThatThrownBy(c).isInstanceOf(ProtocolRestJsonException.class); }
Example 8
Source File: SyncApiCallAttemptTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Override protected Consumer<ThrowableAssert.ThrowingCallable> timeoutExceptionAssertion() { return c -> assertThatThrownBy(c).isInstanceOf(ApiCallAttemptTimeoutException.class); }
Example 9
Source File: AsyncApiCallTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Override protected Consumer<ThrowableAssert.ThrowingCallable> timeoutExceptionAssertion() { return c -> assertThatThrownBy(c).hasCauseInstanceOf(ApiCallTimeoutException.class); }
Example 10
Source File: SyncApiCallTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Override protected Consumer<ThrowableAssert.ThrowingCallable> timeoutExceptionAssertion() { return c -> assertThatThrownBy(c).isInstanceOf(ApiCallTimeoutException.class); }
Example 11
Source File: VertxWrappedSessionUT.java From vertx-vaadin with MIT License | 4 votes |
private void shouldThrowExceptionWhenSessionIsInvalidated(ThrowableAssert.ThrowingCallable op) { when(session.isDestroyed()).thenReturn(true); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(op); }
Example 12
Source File: AbstractExtensibleLockProviderIntegrationTest.java From ShedLock with Apache License 2.0 | 4 votes |
void assertInvalidLock(ThrowableAssert.ThrowingCallable operation) { assertThatThrownBy(operation).isInstanceOf(IllegalStateException.class); }
Example 13
Source File: TestCsvDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertRuntimeDecodingFailure(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageMatching("could not parse value .* as .* for column .*"); }
Example 14
Source File: TestCsvDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertUnsupportedColumnTypeException(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageMatching("Unsupported column type .* for column .*"); }
Example 15
Source File: TestRawDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertUnsupportedColumnTypeException(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageMatching("Unsupported column type .* for column .*"); }
Example 16
Source File: TestRawDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertWrongDataFormatException(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageMatching("Wrong dataFormat .* specified for column .*"); }
Example 17
Source File: TestRawDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertMappingDoesNotMatchDataFormatException(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageContaining("Bytes mapping for column 'some_column' does not match dataFormat"); }
Example 18
Source File: TestAvroDecoder.java From presto with Apache License 2.0 | 4 votes |
private void assertUnsupportedColumnTypeException(ThrowableAssert.ThrowingCallable callable) { assertThatThrownBy(callable) .isInstanceOf(PrestoException.class) .hasMessageMatching("Unsupported column type .* for column .*"); }
Example 19
Source File: BaseTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 2 votes |
/** * @return the exception to assert */ protected abstract Consumer<ThrowableAssert.ThrowingCallable> timeoutExceptionAssertion();
Example 20
Source File: BaseTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | votes |
protected abstract Consumer<ThrowableAssert.ThrowingCallable> serviceExceptionAssertion();