org.assertj.core.api.ObjectAssert Java Examples
The following examples show how to use
org.assertj.core.api.ObjectAssert.
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: MySqlConnectionConfigurationTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void hosted() { for (SslMode mode : SslMode.values()) { if (mode.verifyCertificate()) { assertThatIllegalArgumentException().isThrownBy(() -> hostedSslMode(mode, null)).withMessageContaining("sslCa"); assertThat(hostedSslMode(mode, SSL_CA)).isNotNull(); } else { assertThat(hostedSslMode(mode, null)).isNotNull(); } } ObjectAssert<MySqlConnectionConfiguration> asserted = assertThat(MySqlConnectionConfiguration.builder() .host(HOST) .user(USER) .build()); asserted.extracting(MySqlConnectionConfiguration::getDomain).isEqualTo(HOST); asserted.extracting(MySqlConnectionConfiguration::getUser).isEqualTo(USER); asserted.extracting(MySqlConnectionConfiguration::isHost).isEqualTo(true); asserted.extracting(MySqlConnectionConfiguration::getSsl).extracting(MySqlSslConfiguration::getSslMode).isEqualTo(SslMode.PREFERRED); }
Example #2
Source File: FluxDiscardOnCancelTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void assemblyHook() { List<Object> publishers = new ArrayList<>(); Hooks.onEachOperator(objectPublisher -> { publishers.add(objectPublisher); return objectPublisher; }); Iterator<Integer> items = createItems(5); Flux<Integer> flux = Flux.fromIterable(() -> items); flux.transform(OperatorUtils::discardOnCancel) .as(StepVerifier::create) .expectNextCount(5) .verifyComplete(); ObjectAssert<?> element = assertThat(publishers).hasSize(2).element(1); if (flux instanceof Fuseable) { element.isExactlyInstanceOf(FluxDiscardOnCancelFuseable.class); } else { element.isExactlyInstanceOf(FluxDiscardOnCancel.class); } }
Example #3
Source File: MySqlConnectionConfigurationTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void unixSocket() { for (SslMode mode : SslMode.values()) { if (mode.startSsl()) { assertThatIllegalArgumentException().isThrownBy(() -> unixSocketSslMode(mode)).withMessageContaining("sslMode"); } else { assertThat(unixSocketSslMode(SslMode.DISABLED)).isNotNull(); } } ObjectAssert<MySqlConnectionConfiguration> asserted = assertThat(MySqlConnectionConfiguration.builder() .unixSocket(UNIX_SOCKET) .user(USER) .build()); asserted.extracting(MySqlConnectionConfiguration::getDomain).isEqualTo(UNIX_SOCKET); asserted.extracting(MySqlConnectionConfiguration::getUser).isEqualTo(USER); asserted.extracting(MySqlConnectionConfiguration::isHost).isEqualTo(false); asserted.extracting(MySqlConnectionConfiguration::getSsl).extracting(MySqlSslConfiguration::getSslMode).isEqualTo(SslMode.DISABLED); }
Example #4
Source File: MySqlConnectionConfigurationTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void hosted() { for (SslMode mode : SslMode.values()) { if (mode.verifyCertificate()) { assertThatIllegalArgumentException().isThrownBy(() -> hostedSslMode(mode, null)).withMessageContaining("sslCa"); assertThat(hostedSslMode(mode, SSL_CA)).isNotNull(); } else { assertThat(hostedSslMode(mode, null)).isNotNull(); } } ObjectAssert<MySqlConnectionConfiguration> asserted = assertThat(MySqlConnectionConfiguration.builder() .host(HOST) .user(USER) .build()); asserted.extracting(MySqlConnectionConfiguration::getDomain).isEqualTo(HOST); asserted.extracting(MySqlConnectionConfiguration::getUser).isEqualTo(USER); asserted.extracting(MySqlConnectionConfiguration::isHost).isEqualTo(true); asserted.extracting(MySqlConnectionConfiguration::getSsl).extracting(MySqlSslConfiguration::getSslMode).isEqualTo(SslMode.PREFERRED); }
Example #5
Source File: FluxDiscardOnCancelTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void assemblyHook() { List<Object> publishers = new ArrayList<>(); Hooks.onEachOperator(objectPublisher -> { publishers.add(objectPublisher); return objectPublisher; }); Iterator<Integer> items = createItems(5); Flux<Integer> flux = Flux.fromIterable(() -> items); flux.transform(OperatorUtils::discardOnCancel) .as(StepVerifier::create) .expectNextCount(5) .verifyComplete(); ObjectAssert<?> element = assertThat(publishers).hasSize(2).element(1); if (flux instanceof Fuseable) { element.isExactlyInstanceOf(FluxDiscardOnCancelFuseable.class); } else { element.isExactlyInstanceOf(FluxDiscardOnCancel.class); } }
Example #6
Source File: MySqlConnectionConfigurationTest.java From r2dbc-mysql with Apache License 2.0 | 6 votes |
@Test void unixSocket() { for (SslMode mode : SslMode.values()) { if (mode.startSsl()) { assertThatIllegalArgumentException().isThrownBy(() -> unixSocketSslMode(mode)).withMessageContaining("sslMode"); } else { assertThat(unixSocketSslMode(SslMode.DISABLED)).isNotNull(); } } ObjectAssert<MySqlConnectionConfiguration> asserted = assertThat(MySqlConnectionConfiguration.builder() .unixSocket(UNIX_SOCKET) .user(USER) .build()); asserted.extracting(MySqlConnectionConfiguration::getDomain).isEqualTo(UNIX_SOCKET); asserted.extracting(MySqlConnectionConfiguration::getUser).isEqualTo(USER); asserted.extracting(MySqlConnectionConfiguration::isHost).isEqualTo(false); asserted.extracting(MySqlConnectionConfiguration::getSsl).extracting(MySqlSslConfiguration::getSslMode).isEqualTo(SslMode.DISABLED); }
Example #7
Source File: AbstractMessageIdManagerSideEffectTest.java From james-project with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test void deletesShouldCallEventDispatcher() throws Exception { givenUnlimitedQuota(); MessageId messageId1 = testingData.persist(mailbox1.getMailboxId(), messageUid1, FLAGS, session); MessageId messageId2 = testingData.persist(mailbox1.getMailboxId(), messageUid2, FLAGS, session); MessageResult messageResult1 = messageIdManager.getMessage(messageId1, FetchGroup.MINIMAL, session).get(0); MessageMetaData simpleMessageMetaData1 = messageResult1.messageMetaData(); MessageResult messageResult2 = messageIdManager.getMessage(messageId2, FetchGroup.MINIMAL, session).get(0); MessageMetaData simpleMessageMetaData2 = messageResult2.messageMetaData(); eventBus.register(eventCollector); messageIdManager.delete(ImmutableList.of(messageId1, messageId2), session); AbstractListAssert<?, List<? extends MailboxListener.Expunged>, MailboxListener.Expunged, ObjectAssert<MailboxListener.Expunged>> events = assertThat(eventCollector.getEvents()) .filteredOn(event -> event instanceof MailboxListener.Expunged) .hasSize(2) .extracting(event -> (MailboxListener.Expunged) event); events.extracting(MailboxListener.MailboxEvent::getMailboxId).containsOnly(mailbox1.getMailboxId(), mailbox1.getMailboxId()); events.extracting(MailboxListener.Expunged::getExpunged) .containsOnly(ImmutableSortedMap.of(simpleMessageMetaData1.getUid(), simpleMessageMetaData1), ImmutableSortedMap.of(simpleMessageMetaData2.getUid(), simpleMessageMetaData2)); }
Example #8
Source File: QueryTest.java From elepy with Apache License 2.0 | 5 votes |
private ObjectAssert<Filter> assertFilterMatches(Expression expression, String propName, FilterType type, Serializable value) { return assertThat(expression) .asInstanceOf(type(Filter.class)) .satisfies(filter -> { assertThat(filter.getPropertyName()).isEqualTo(propName); assertThat(filter.getFilterType()).isEqualTo(type); assertThat(filter.getFilterValue()).isEqualTo(value.toString()); } ); }
Example #9
Source File: MultipleNodeAssert.java From xmlunit with Apache License 2.0 | 5 votes |
/** * Extracting values of given node's attribute. * If a node doesn't have the attribute then {@code null} value is return. * * @throws AssertionError if the actual nodes iterable is {@code null}. * @since XMLUnit 2.6.4 */ public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingAttribute(String attribute) { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { values.add(NodeUtils.attributeValue(node, attribute)); } String extractedDescription = String.format("Extracted attribute: %s", attribute); String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); }
Example #10
Source File: ArtifactEndpointTest.java From pnc with Apache License 2.0 | 5 votes |
@Test public void shouldGetMilestonesInfo() throws RemoteResourceException { ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous()); RemoteCollection<MilestoneInfo> milestonesInfo = client.getMilestonesInfo(artifactRest3.getId()); assertThat(milestonesInfo).hasSize(1).first().extracting(MilestoneInfo::isBuilt).isEqualTo(false); RemoteCollection<MilestoneInfo> milestonesInfo2 = client.getMilestonesInfo(artifactRest1.getId()); ObjectAssert<MilestoneInfo> milestone = assertThat(milestonesInfo2).hasSize(1).first(); milestone.extracting(MilestoneInfo::isBuilt).isEqualTo(true); milestone.extracting(MilestoneInfo::getProductName).isEqualTo("Project Newcastle Demo Product"); milestone.extracting(MilestoneInfo::getMilestoneVersion).isEqualTo("1.0.0.Build1"); }
Example #11
Source File: AssertableCallback.java From brave with Apache License 2.0 | 4 votes |
public ObjectAssert<V> assertThatSuccess() { return assertThat(join()); }
Example #12
Source File: AssertionsAdapter.java From xmlunit with Apache License 2.0 | 4 votes |
static <T> AbstractObjectAssert<?, T> assertThat(T actual) { return new ObjectAssert<>(actual); }
Example #13
Source File: RetryRuleBuilderTest.java From armeria with Apache License 2.0 | 4 votes |
static ObjectAssert<Backoff> assertBackoff(CompletionStage<RetryDecision> future) { return assertThat(future.toCompletableFuture().join().backoff()); }
Example #14
Source File: CircuitBreakerRuleBuilderTest.java From armeria with Apache License 2.0 | 4 votes |
static <T> ObjectAssert<T> assertFuture(CompletionStage<T> decisionFuture) { return assertThat(decisionFuture.toCompletableFuture().join()); }
Example #15
Source File: TraceBaggageConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
static AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> assertThatFieldNamesToTag( AssertableApplicationContext context) { return assertThat(context.getBean(SpanHandler.class)) .isInstanceOf(BaggageTagSpanHandler.class).extracting("fieldsToTag") .asInstanceOf(array(BaggageField[].class)).extracting(BaggageField::name); }
Example #16
Source File: JsonObjectAssert.java From ditto with Eclipse Public License 2.0 | 4 votes |
@Override protected ObjectAssert<JsonField> toAssert(final JsonField jsonField, final String description) { final AssertFactory<JsonField, ObjectAssert<JsonField>> objectAssertFactory = new ObjectAssertFactory<>(); return objectAssertFactory.createAssert(jsonField).as(description); }
Example #17
Source File: Assertions.java From ArchUnit with Apache License 2.0 | 4 votes |
@Override protected ObjectAssert<ThrowsDeclaration<?>> toAssert(ThrowsDeclaration<?> value, String description) { return new ObjectAssertFactory<ThrowsDeclaration<?>>().createAssert(value).as(description); }
Example #18
Source File: Assertions.java From ArchUnit with Apache License 2.0 | 4 votes |
@Override protected ObjectAssert<JavaClass> toAssert(JavaClass value, String description) { return new ObjectAssertFactory<JavaClass>().createAssert(value).as(description); }
Example #19
Source File: ConditionEventsAssertion.java From ArchUnit with Apache License 2.0 | 4 votes |
@Override protected ObjectAssert<ConditionEvent> toAssert(ConditionEvent value, String description) { return new ObjectAssertFactory<ConditionEvent>().createAssert(value).as(description); }
Example #20
Source File: DataSourceDecoratorAutoConfigurationTests.java From spring-boot-data-source-decorator with Apache License 2.0 | 4 votes |
private AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> assertThatDataSourceDecoratingChain(DataSource dataSource) { return assertThat(((DecoratedDataSource) dataSource).getDecoratingChain()).extracting("dataSource").extracting("class"); }