Java源码示例:org.assertj.core.api.IterableAssert

示例1
void assertAccountBalances(BalanceFile... balanceFiles) {
    IterableAssert<AccountBalanceSet> iterableAssert = assertThat(accountBalanceSetRepository.findAll())
            .hasSize(balanceFiles.length)
            .allMatch(abs -> abs.isComplete())
            .allMatch(abs -> abs.getProcessingEndTimestamp() != null)
            .allMatch(abs -> abs.getProcessingStartTimestamp() != null);

    for (BalanceFile balanceFile : balanceFiles) {
        iterableAssert.anyMatch(abs -> balanceFile.getConsensusTimestamp() == abs.getConsensusTimestamp() &&
                accountBalanceRepository.findByIdConsensusTimestamp(abs.getConsensusTimestamp()).size() ==
                        balanceFile.getCount());
    }
}
 
示例2
@Test
public void eventRegistryWithRabbit() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(RabbitAutoConfiguration.class))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(RabbitChannelDefinitionProcessor.class)
                .hasBean("rabbitChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();
            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors())
                .hasSize(5);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("rabbitChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(2)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
示例3
@Test
public void eventRegistryWithKafka() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(KafkaAutoConfiguration.class))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngine.getEventRegistryEngineConfiguration().getChannelModelProcessors());

            channelModelProcessorAssert
                .hasSize(5);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("kafkaChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(2)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
示例4
public IterableAssert<Relation> asTermVariationsHavingRule(String ruleName) {
	Set<Relation> variations = Sets.newHashSet();
	for(Relation v:actual.getRelations()) {
		if(getVariationRules(v).contains(ruleName))
			variations.add(v);
		
	}
	return assertThat(variations);
}
 
示例5
public IterableAssert<Relation> asTermVariations(RelationType ralType, RelationType... ralTypes) {
	EnumSet<RelationType> accepted = EnumSet.of(ralType, ralTypes);
	Set<Relation> relations = actual.getRelations().stream()
			.filter(r-> accepted.contains(r.getType()))
			.collect(toSet());
	return assertThat(
			relations);
}
 
示例6
public IterableAssert<Term> asCompoundList() {
	Set<Term> comouponds = actual.getTerms().values().stream()
		.filter(t-> t.getWords().size() == 1 && t.getWords().get(0).getWord().isCompound())
		.collect(toSet());
	IterableAssert<Term> assertThat = assertThat(comouponds);
	return assertThat;
}
 
示例7
public IterableAssert<String> asMatchingRules() {
	Set<String> matchingRuleNames = Sets.newHashSet();
	for(Relation tv:actual.getRelations().stream().filter(r->r.getType() == RelationType.VARIATION).collect(toSet())) 
		matchingRuleNames.addAll(getVariationRules(tv));
	IterableAssert<String> assertThat = assertThat(matchingRuleNames);
	return assertThat;
}
 
示例8
public ValidationRuleAssert isUsing(FieldId... fieldIds) {
    final List<FieldId> fields = collect(actual.metadata());
    final IterableAssert<FieldId> iterableAssert = new IterableAssert<>(fields);
    iterableAssert.contains(fieldIds);
    return this;
}
 
示例9
public ValidationRuleAssert isNotUsing(FieldId... fieldIds) {
    final List<FieldId> fields = collect(actual.metadata());
    final IterableAssert<FieldId> iterableAssert = new IterableAssert<>(fields);
    iterableAssert.doesNotContain(fieldIds);
    return this;
}
 
示例10
public MappingRuleAssert isUsing(FieldId... fieldIds) {
    final List<FieldId> fields = collect(actual.metadata());
    final IterableAssert<FieldId> iterableAssert = new IterableAssert<>(fields);
    iterableAssert.contains(fieldIds);
    return this;
}
 
示例11
public MappingRuleAssert isNotUsing(FieldId... fieldIds) {
    final List<FieldId> fields = collect(actual.metadata());
    final IterableAssert<FieldId> iterableAssert = new IterableAssert<>(fields);
    iterableAssert.doesNotContain(fieldIds);
    return this;
}
 
示例12
public IterableAssert<ResolvedTest> includedPatterns() {
    isNotNull();

    return Assertions.assertThat(actual.getIncludedPatterns());
}
 
示例13
public IterableAssert<ResolvedTest> excludedPatterns() {
    isNotNull();

    return Assertions.assertThat(actual.getExcludedPatterns());
}
 
示例14
@Test
public void standaloneEventRegistryWithBasicDataSource() {
    contextRunner.run(context -> {
        assertThat(context)
            .doesNotHaveBean(AppEngine.class)
            .doesNotHaveBean(ProcessEngine.class)
            .doesNotHaveBean(ChannelModelProcessor.class)
            .doesNotHaveBean("eventProcessEngineConfigurationConfigurer")
            .doesNotHaveBean("eventAppEngineConfigurationConfigurer");
        EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
        assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();
        assertAllServicesPresent(context, eventRegistryEngine);

        IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
            eventRegistryEngine.getEventRegistryEngineConfiguration().getChannelModelProcessors());

        channelModelProcessorAssert
            .hasSize(4);

        channelModelProcessorAssert
            .element(0)
            .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

        channelModelProcessorAssert
            .element(1)
            .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

        channelModelProcessorAssert
            .element(2)
            .isInstanceOf(InboundChannelModelProcessor.class);

        channelModelProcessorAssert
            .element(3)
            .isInstanceOf(OutboundChannelModelProcessor.class);

        assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
            .getBean(CustomUserEngineConfigurerConfiguration.class)
            .satisfies(configuration -> {
                assertThat(configuration.getInvokedConfigurations())
                    .containsExactly(
                        SpringEventRegistryEngineConfiguration.class
                    );
            });

    });
}
 
示例15
@Test
public void eventRegistryWithJms() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            ActiveMQAutoConfiguration.class,
            JmsAutoConfiguration.class
        ))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(JmsChannelModelProcessor.class)
                .hasBean("jmsChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();

            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors());

            channelModelProcessorAssert
                .hasSize(5);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("jmsChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(2)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(OutboundChannelModelProcessor.class);

        });
}
 
示例16
@Test
public void eventRegistryWithJmsRabbitAndKafka() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            ActiveMQAutoConfiguration.class,
            JmsAutoConfiguration.class,
            RabbitAutoConfiguration.class,
            KafkaAutoConfiguration.class
        ))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(JmsChannelModelProcessor.class)
                .hasBean("jmsChannelDefinitionProcessor")
                .hasSingleBean(RabbitChannelDefinitionProcessor.class)
                .hasBean("rabbitChannelDefinitionProcessor")
                .hasSingleBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();
            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors());
            channelModelProcessorAssert
                .hasSize(7)
                .contains(
                    context.getBean("jmsChannelDefinitionProcessor", JmsChannelModelProcessor.class),
                    context.getBean("rabbitChannelDefinitionProcessor", RabbitChannelDefinitionProcessor.class),
                    context.getBean("kafkaChannelDefinitionProcessor", KafkaChannelDefinitionProcessor.class)
                );

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(5)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(6)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
示例17
@Test
public void eventRegistryWithCustomDefinitionProcessors() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            ActiveMQAutoConfiguration.class,
            JmsAutoConfiguration.class,
            RabbitAutoConfiguration.class,
            KafkaAutoConfiguration.class
        ))
        .withUserConfiguration(CustomChannelDefinitionProcessorsConfiguration.class)
        .run(context -> {
            assertThat(context)
                .doesNotHaveBean(JmsChannelModelProcessor.class)
                .hasBean("jmsChannelDefinitionProcessor")
                .doesNotHaveBean(RabbitChannelDefinitionProcessor.class)
                .hasBean("rabbitChannelDefinitionProcessor")
                .doesNotHaveBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor")
                .hasBean("customChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();
            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors());
            channelModelProcessorAssert
                .hasSize(8);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("customChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isEqualTo(context.getBean("rabbitChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(2)
                .isEqualTo(context.getBean("jmsChannelDefinitionProcessor", ChannelModelProcessor.class));

        channelModelProcessorAssert
                .element(3)
                .isEqualTo(context.getBean("kafkaChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(5)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(6)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(7)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
示例18
public IterableAssert<Relation> getVariations(Term base) {
	return assertThat(UnitTests.outRels(actual, base));
}