org.assertj.core.api.AbstractListAssert Java Examples

The following examples show how to use org.assertj.core.api.AbstractListAssert. 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: AbstractMessageIdManagerSideEffectTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: MultipleNodeAssert.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #3
Source File: DataSourceDecoratorAutoConfigurationTests.java    From spring-boot-data-source-decorator with Apache License 2.0 4 votes vote down vote up
private AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> assertThatDataSourceDecoratingChain(DataSource dataSource) {
    return assertThat(((DecoratedDataSource) dataSource).getDecoratingChain()).extracting("dataSource").extracting("class");
}
 
Example #4
Source File: TraceBaggageConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
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 #5
Source File: BlockingObservableAssertTest.java    From assertj-rx with Apache License 2.0 4 votes vote down vote up
@Test
public void listOfValuesEmittedReturnsValidAssertion() {
    AbstractListAssert<?, ?, ?> listAssert = new BlockingObservableAssert<>(Observable.just("a", "b").toBlocking())
            .listOfValuesEmitted();
    assertThat(listAssert).isNotNull();
}
 
Example #6
Source File: BlockingObservableAssert.java    From assertj-rx with Apache License 2.0 2 votes vote down vote up
/**
 * Allows performing Assertj assertions over the list of values emitted onNext()
 *
 * @return an instance of @{link ListAssert} initialized with the values received onNext()
 */
public AbstractListAssert<?, ? extends List<? extends T>, T> listOfValuesEmitted() {
    isNotNull();
    return assertThat(getBlockingObservableExecutor().getValuesEmitted());
}