Search in sources :

Example 1 with BuildingBlockDescriptor

use of org.archifacts.core.descriptor.BuildingBlockDescriptor in project archifacts by archifacts.

the class SpringDescriptorTest method assertThat_building_blocks_are_recognized.

@ParameterizedTest
@MethodSource("getBuildingBlocks")
void assertThat_building_blocks_are_recognized(final BuildingBlockDescriptor buildingBlockDescriptor, final Class<?>... matchingClasses) {
    final Application application = Application.builder().descriptor(buildingBlockDescriptor).buildApplication(DOMAIN);
    final Set<String> expectedClassNames = Arrays.stream(matchingClasses).map(Class::getName).collect(Collectors.toSet());
    assertThat(application.getBuildingBlocksOfType(buildingBlockDescriptor.type())).map(b -> b.getJavaClass().getName()).allMatch(name -> expectedClassNames.contains(name));
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) Arrays(java.util.Arrays) ReplaceUnderscores(org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) MyRepository(org.archifacts.integration.spring.domain.MyRepository) MyComponent(org.archifacts.integration.spring.domain.MyComponent) MyService(org.archifacts.integration.spring.domain.MyService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DisplayNameGeneration(org.junit.jupiter.api.DisplayNameGeneration) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Application(org.archifacts.core.model.Application) MyConfiguration(org.archifacts.integration.spring.domain.MyConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) BuildingBlockDescriptor(org.archifacts.core.descriptor.BuildingBlockDescriptor) MyController(org.archifacts.integration.spring.domain.MyController) MethodSource(org.junit.jupiter.params.provider.MethodSource) Application(org.archifacts.core.model.Application) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with BuildingBlockDescriptor

use of org.archifacts.core.descriptor.BuildingBlockDescriptor in project archifacts by archifacts.

the class AxonDescriptorsTest method assertThat_building_blocks_are_recognized.

@ParameterizedTest
@MethodSource("getBuildingBlocks")
void assertThat_building_blocks_are_recognized(final BuildingBlockDescriptor buildingBlockDescriptor, final Class<?>... matchingClasses) {
    final Application application = Application.builder().descriptor(buildingBlockDescriptor).buildApplication(DOMAIN);
    final Set<String> expectedClassNames = Arrays.stream(matchingClasses).map(Class::getName).collect(Collectors.toSet());
    assertThat(application.getBuildingBlocksOfType(buildingBlockDescriptor.type())).map(b -> b.getJavaClass().getName()).allMatch(name -> expectedClassNames.contains(name));
}
Also used : Arrays(java.util.Arrays) ReplaceUnderscores(org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) MyAggregateRootId(org.archifacts.integration.axon.domain.MyAggregateRootId) MyEvent2(org.archifacts.integration.axon.domain.MyEvent2) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MySagaEventHandler(org.archifacts.integration.axon.domain.MySagaEventHandler) MethodSource(org.junit.jupiter.params.provider.MethodSource) MyQuery1(org.archifacts.integration.axon.domain.MyQuery1) JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) Tuple(org.assertj.core.groups.Tuple) SourceBasedArtifactRelationshipDescriptor(org.archifacts.core.descriptor.SourceBasedArtifactRelationshipDescriptor) MyQuery2(org.archifacts.integration.axon.domain.MyQuery2) Assertions.tuple(org.assertj.core.api.Assertions.tuple) DisplayNameGeneration(org.junit.jupiter.api.DisplayNameGeneration) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) MyAggregateMember3(org.archifacts.integration.axon.domain.MyAggregateMember3) Application(org.archifacts.core.model.Application) MyAggregateMember2(org.archifacts.integration.axon.domain.MyAggregateMember2) MyCommand1(org.archifacts.integration.axon.domain.MyCommand1) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) MyAggregateMember1(org.archifacts.integration.axon.domain.MyAggregateMember1) MyCommand2(org.archifacts.integration.axon.domain.MyCommand2) BuildingBlockDescriptor(org.archifacts.core.descriptor.BuildingBlockDescriptor) MyAggregateRoot(org.archifacts.integration.axon.domain.MyAggregateRoot) MyEventHandler(org.archifacts.integration.axon.domain.MyEventHandler) MyEvent1(org.archifacts.integration.axon.domain.MyEvent1) MySaga(org.archifacts.integration.axon.domain.MySaga) MyQueryHandler(org.archifacts.integration.axon.domain.MyQueryHandler) Application(org.archifacts.core.model.Application) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)2 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)2 Arrays (java.util.Arrays)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 BuildingBlockDescriptor (org.archifacts.core.descriptor.BuildingBlockDescriptor)2 Application (org.archifacts.core.model.Application)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 DisplayNameGeneration (org.junit.jupiter.api.DisplayNameGeneration)2 ReplaceUnderscores (org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 Arguments (org.junit.jupiter.params.provider.Arguments)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 SourceBasedArtifactRelationshipDescriptor (org.archifacts.core.descriptor.SourceBasedArtifactRelationshipDescriptor)1 MyAggregateMember1 (org.archifacts.integration.axon.domain.MyAggregateMember1)1 MyAggregateMember2 (org.archifacts.integration.axon.domain.MyAggregateMember2)1 MyAggregateMember3 (org.archifacts.integration.axon.domain.MyAggregateMember3)1 MyAggregateRoot (org.archifacts.integration.axon.domain.MyAggregateRoot)1 MyAggregateRootId (org.archifacts.integration.axon.domain.MyAggregateRootId)1