org.assertj.core.api.ThrowableAssertAlternative Java Examples
The following examples show how to use
org.assertj.core.api.ThrowableAssertAlternative.
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: ThingsConditionalHeadersValidatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void assertThrowingNotModifiedWhenSelectedFieldDoesNotContainPolicy() { final String ifNoneMatchHeaderValue = "\"rev:1\""; final EntityTag actualEntityTag = EntityTag.fromString("\"rev:1\""); final String expectedMessage = format(IF_NONE_MATCH_NOT_MODIFIED_MESSAGE_PATTERN, ifNoneMatchHeaderValue, actualEntityTag); final RetrieveThing retrieveThing = createRetrieveThingCommand(ifNoneMatchHeaderValue, "_revision"); final ThrowableAssertAlternative<ThingPreconditionNotModifiedException> assertion = assertThatExceptionOfType(ThingPreconditionNotModifiedException.class) .isThrownBy(() -> SUT.checkConditionalHeaders(retrieveThing, actualEntityTag)) .withMessage(expectedMessage); assertion.satisfies(exception -> assertETagHeaderInDre(exception, actualEntityTag)); }
Example #2
Source File: ThingsConditionalHeadersValidatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
private void assertPreconditionFailed(final String ifMatchHeaderValue, final String ifNoneMatchHeaderValue, @Nullable final EntityTag actualEntityTag, final Category commandCategory, final String expectedMessage) { final Command commandMock = createCommandMock(commandCategory, ifMatchHeaderValue, ifNoneMatchHeaderValue); final ThrowableAssertAlternative<ThingPreconditionFailedException> assertion = assertThatExceptionOfType(ThingPreconditionFailedException.class) .isThrownBy(() -> SUT.checkConditionalHeaders(commandMock, actualEntityTag)) .withMessage(expectedMessage); if (actualEntityTag == null) { assertion.satisfies(exception -> assertThat(exception.getDittoHeaders().getETag()).isNotPresent()); } else { assertion.satisfies(exception -> assertETagHeaderInDre(exception, actualEntityTag)); } }
Example #3
Source File: ThingsConditionalHeadersValidatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
private void assertNotModified(final String ifMatchHeaderValue, final String ifNoneMatchHeaderValue, @Nullable final EntityTag actualEntityTag, final String expectedMessage) { final Command commandMock = createCommandMock(QUERY, ifMatchHeaderValue, ifNoneMatchHeaderValue); final ThrowableAssertAlternative<ThingPreconditionNotModifiedException> assertion = assertThatExceptionOfType(ThingPreconditionNotModifiedException.class) .isThrownBy(() -> SUT.checkConditionalHeaders(commandMock, actualEntityTag)) .withMessage(expectedMessage); if (actualEntityTag == null) { assertion.satisfies(exception -> assertThat(exception.getDittoHeaders().getETag()).isNotPresent()); } else { assertion.satisfies(exception -> assertETagHeaderInDre(exception, actualEntityTag)); } }
Example #4
Source File: PoliciesConditionalHeadersValidatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
private void assertPreconditionFailed(final String ifMatchHeaderValue, final String ifNoneMatchHeaderValue, @Nullable final EntityTag actualEntityTag, final Category commandCategory, final String expectedMessage) { final Command commandMock = createCommandMock(commandCategory, ifMatchHeaderValue, ifNoneMatchHeaderValue, null); final ThrowableAssertAlternative<PolicyPreconditionFailedException> assertion = assertThatExceptionOfType(PolicyPreconditionFailedException.class) .isThrownBy(() -> SUT.checkConditionalHeaders(commandMock, actualEntityTag)) .withMessage(expectedMessage); if (actualEntityTag == null) { assertion.satisfies(exception -> assertThat(exception.getDittoHeaders().getETag()).isNotPresent()); } else { assertion.satisfies(exception -> assertETagHeaderInDre(exception, actualEntityTag)); } }
Example #5
Source File: PoliciesConditionalHeadersValidatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
private void assertNotModified(final String ifMatchHeaderValue, final String ifNoneMatchHeaderValue, @Nullable final EntityTag actualEntityTag, final String expectedMessage, final @Nullable JsonObject selectedFields) { final Command commandMock = createCommandMock(QUERY, ifMatchHeaderValue, ifNoneMatchHeaderValue, selectedFields); final ThrowableAssertAlternative<PolicyPreconditionNotModifiedException> assertion = assertThatExceptionOfType(PolicyPreconditionNotModifiedException.class) .isThrownBy(() -> SUT.checkConditionalHeaders(commandMock, actualEntityTag)) .withMessage(expectedMessage); if (actualEntityTag == null) { assertion.satisfies(exception -> assertThat(exception.getDittoHeaders().getETag()).isNotPresent()); } else { assertion.satisfies(exception -> assertETagHeaderInDre(exception, actualEntityTag)); } }
Example #6
Source File: DefaultContextExpectationsTest.java From reactor-core with Apache License 2.0 | 4 votes |
private ThrowableAssertAlternative<AssertionError> assertContextExpectationFails( Function<Flux<Integer>, Flux<Integer>> sourceTransformer, Function<DefaultContextExpectations<Integer>, ContextExpectations<Integer>> expectations) { return assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> assertContextExpectation(sourceTransformer, expectations)); }
Example #7
Source File: TerminatedServerTest.java From ehcache3 with Apache License 2.0 | 4 votes |
private <T extends Throwable> ThrowableAssertAlternative<T> assertExceptionOccurred(Class<T> exception, TimeLimitedTask<?> task) { return assertThatExceptionOfType(exception) .isThrownBy(() -> task.run()); }