org.assertj.core.api.AbstractObjectAssert Java Examples

The following examples show how to use org.assertj.core.api.AbstractObjectAssert. 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: ServerMessageDecoderTest.java    From r2dbc-mysql with Apache License 2.0 6 votes vote down vote up
@Test
void okAndPreparedOk() {
    AbstractObjectAssert<?, OkMessage> ok = assertThat(decode(okLike(), DecodeContext.command()))
        .isExactlyInstanceOf(OkMessage.class)
        .extracting(message -> (OkMessage) message);

    ok.extracting(OkMessage::getAffectedRows).isEqualTo(1L);
    ok.extracting(OkMessage::getLastInsertId).isEqualTo(0x10000L); // 65536
    ok.extracting(OkMessage::getServerStatuses).isEqualTo((short) 0x100); // 256
    ok.extracting(OkMessage::getWarnings).isEqualTo(0);

    AbstractObjectAssert<?, PreparedOkMessage> preparedOk = assertThat(decode(okLike(), DecodeContext.prepareQuery()))
        .isExactlyInstanceOf(PreparedOkMessage.class)
        .extracting(message -> (PreparedOkMessage) message);

    preparedOk.extracting(PreparedOkMessage::getStatementId).isEqualTo(0xFD01); // 64769
    preparedOk.extracting(PreparedOkMessage::getTotalColumns).isEqualTo(1);
    preparedOk.extracting(PreparedOkMessage::getTotalParameters).isEqualTo(1);
}
 
Example #2
Source File: ServerMessageDecoderTest.java    From r2dbc-mysql with Apache License 2.0 6 votes vote down vote up
@Test
void okAndPreparedOk() {
    AbstractObjectAssert<?, OkMessage> ok = assertThat(decode(okLike(), DecodeContext.command()))
        .isExactlyInstanceOf(OkMessage.class)
        .extracting(message -> (OkMessage) message);

    ok.extracting(OkMessage::getAffectedRows).isEqualTo(1L);
    ok.extracting(OkMessage::getLastInsertId).isEqualTo(0x10000L); // 65536
    ok.extracting(OkMessage::getServerStatuses).isEqualTo((short) 0x100); // 256
    ok.extracting(OkMessage::getWarnings).isEqualTo(0);

    AbstractObjectAssert<?, PreparedOkMessage> preparedOk = assertThat(decode(okLike(), DecodeContext.prepareQuery()))
        .isExactlyInstanceOf(PreparedOkMessage.class)
        .extracting(message -> (PreparedOkMessage) message);

    preparedOk.extracting(PreparedOkMessage::getStatementId).isEqualTo(0xFD01); // 64769
    preparedOk.extracting(PreparedOkMessage::getTotalColumns).isEqualTo(1);
    preparedOk.extracting(PreparedOkMessage::getTotalParameters).isEqualTo(1);
}
 
Example #3
Source File: JsonPathAssert.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
public AbstractObjectAssert<?, Object> hasPath(String path) {
	try {
		return Assertions.assertThat(this.actual.read(path, Object.class));
	}
	catch (PathNotFoundException ex) {
		failWithMessage("The JSON " + this.actual.jsonString() + " does not contain the path '" + path + "'");
		return null;
	}
}
 
Example #4
Source File: AbstractCommandResultsAssert.java    From ts-reaktive with MIT License 4 votes vote down vote up
/**
 * Asserts there is a validation error, and allows further assertions on it.
 */
public AbstractObjectAssert<?,?> validationError() {
    return Assertions.assertThat(validationError(Object.class));
}
 
Example #5
Source File: AbstractCommandResultsAssert.java    From ts-reaktive with MIT License 4 votes vote down vote up
/**
 * Asserts the results are valid and NOT already applied, and performs further assertions on the reply message.
 */
public AbstractObjectAssert<?,?> nonIdempotentReply() {
    return Assertions.assertThat(nonIdempotentReply(Object.class));
}
 
Example #6
Source File: EventsAssert.java    From ddd-wro-warehouse with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> AbstractObjectAssert<?, T> assertAt(int index, Class<T> type) {
    AbstractObjectAssert<?, ?> anAssert = Assertions.assertThat(events.get(index));
    anAssert.isInstanceOf(type);
    return (AbstractObjectAssert<?, T>) anAssert;
}
 
Example #7
Source File: EventsAssert.java    From ddd-wro-warehouse with MIT License 4 votes vote down vote up
public <T> AbstractObjectAssert<?, T> assertFirst(Class<T> type) {
    return this.assertAt(0, type);
}
 
Example #8
Source File: EventsAssert.java    From ddd-wro-warehouse with MIT License 4 votes vote down vote up
public <T> AbstractObjectAssert<?, T> assertLast(Class<T> type) {
    return this.assertAt(events.size() - 1, type);
}
 
Example #9
Source File: JsonPathAssert.java    From spring-cloud-open-service-broker with Apache License 2.0 4 votes vote down vote up
public AbstractObjectAssert<?, Object> hasPath(String path) {
	return Assertions.assertThat(actual.read(path, Object.class));
}
 
Example #10
Source File: DefaultTierStatisticsDisabledTest.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
private AbstractObjectAssert<?, Number> assertStat(String key) {
  return assertThat((Number) onHeap.getKnownStatistics().get(key).value());
}
 
Example #11
Source File: DefaultCacheStatisticsTest.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
private AbstractObjectAssert<?, Number> assertStat(String key) {
  return assertThat((Number) cacheStatistics.getKnownStatistics().get(key).value());
}
 
Example #12
Source File: DefaultTierStatisticsTest.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
private AbstractObjectAssert<?, Number> assertStat(String key) {
  return assertThat((Number) onHeap.getKnownStatistics().get(key).value());
}
 
Example #13
Source File: AssertionsAdapter.java    From xmlunit with Apache License 2.0 4 votes vote down vote up
static <T> AbstractObjectAssert<?, T> assertThat(T actual) {
    return new ObjectAssert<>(actual);
}
 
Example #14
Source File: ProtocolAdapterTest.java    From ditto with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Make equality assertions on {@link org.eclipse.ditto.model.base.headers.WithDittoHeaders} comparing only
 * the external headers.
 *
 * @param actual a signal.
 * @return an Assert object for the signal.
 */
default AbstractObjectAssert<?, WithDittoHeaders> assertWithExternalHeadersThat(final WithDittoHeaders actual) {
    return new WithFilteredHeadersAssert(actual, DittoProtocolAdapter.getHeaderTranslator(), true);
}
 
Example #15
Source File: AbstractCommandResultsAssert.java    From ts-reaktive with MIT License 2 votes vote down vote up
/**
 * Asserts the results are valid and already applied, and performs further assertions on the reply message.
 *
 * It is recommended that subclasses declare a more specific overload of this method, e.g.
 * <pre>
 *    public AbstractObjectAssert<?, MyResponseType> idempotentReply() {
 *      return Assertions.assertThat(idempotentReply(MyResponseType.class));
 *    }
 * </pre>
 */
public AbstractObjectAssert<?,?> idempotentReply() {
    return Assertions.assertThat(idempotentReply(Object.class));
}
 
Example #16
Source File: AbstractCalculationTest.java    From ehcache3 with Apache License 2.0 2 votes vote down vote up
/**
 * A little wrapper over {@code assertThat} that just mention that this what we expect from the test. So if the
 * expectation fails, it's probably the test that is wrong, not the implementation.
 *
 * @param actual actual value
 * @return an AssertJ assertion
 */
protected static <T> AbstractObjectAssert<?, T> expect(T actual) {
  return assertThat(actual);
}