use of org.archifacts.core.model.Application in project archifacts by archifacts.
the class JMoleculesDescriptorsTest method assertThat_source_based_artifact_relationship_descriptor_are_recognized.
@ParameterizedTest
@MethodSource("getSourceBasedArtifactRelationshipDescriptors")
void assertThat_source_based_artifact_relationship_descriptor_are_recognized(final ArtifactRelationshipDescriptor artifactRelationshipDescriptor, final RelationshipPair... expectedRelationshipPairs) {
final Application application = Application.builder().descriptor(JMoleculesDescriptors.BuildingBlockDescriptors.AggregateRootDescriptor).descriptor(JMoleculesDescriptors.BuildingBlockDescriptors.RepositoryDescriptor).descriptor(artifactRelationshipDescriptor).buildApplication(DOMAIN);
final Set<RelationshipPair> actualRelationshipPairs = application.getRelationshipsOfRole(artifactRelationshipDescriptor.role()).stream().map(r -> new RelationshipPair(r.getSource().getJavaClass().reflect(), r.getTarget().getJavaClass().reflect())).collect(Collectors.toSet());
assertThat(actualRelationshipPairs).containsExactlyInAnyOrder(expectedRelationshipPairs);
}
use of org.archifacts.core.model.Application in project archifacts by archifacts.
the class JMoleculesDescriptorsTest method assertThat_building_blocks_are_recognized.
@ParameterizedTest
@MethodSource("getBuildingBlocks")
void assertThat_building_blocks_are_recognized(final BuildingBlockDescriptor buildingBlockDescriptor, @AggregateWith(VarargsAggregator.class) final Class<?>... matchingClasses) {
final Application application = Application.builder().descriptor(buildingBlockDescriptor).buildApplication(DOMAIN);
final Set<String> expectedClasses = Arrays.stream(matchingClasses).map(Class::getName).collect(Collectors.toSet());
assertThat(application.getBuildingBlocksOfType(buildingBlockDescriptor.type())).map(BuildingBlock::getJavaClass).map(JavaClass::getName).containsExactlyInAnyOrderElementsOf(expectedClasses);
}
use of org.archifacts.core.model.Application 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));
}
use of org.archifacts.core.model.Application 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));
}
use of org.archifacts.core.model.Application in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_relationship_source_and_target_is_automatically_added_to_the_c4_model.
@Test
void assert_that_relationship_source_and_target_is_automatically_added_to_the_c4_model() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(buildingBlockType1Descriptor).descriptor(defaultContainerDescriptor).descriptor(referenceDescriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
application.getRelationships().stream().forEach(c4ModelBuilder::relationship);
final C4Model c4Model = c4ModelBuilder.build();
final Set<Container> containers = c4Model.softwareSystem().getContainers();
assertThat(containers).hasSize(1).extracting(Container::getName, Container::getTechnology).containsExactly(tuple("DefaultContainer", "ContainerType1"));
final Container container = containers.iterator().next();
final Component class1ForBuildingBlockType1 = container.getComponentWithName("Class1ForBuildingBlockType1");
assertThat(class1ForBuildingBlockType1).isNotNull();
final Component miscArtifact1 = container.getComponentWithName("MiscArtifact1");
assertThat(miscArtifact1).isNotNull();
assertThat(container.getComponents()).flatMap(Component::getRelationships).hasSize(1).extracting(Relationship::getDescription, Relationship::getSource, Relationship::getDestination).containsExactly(tuple("references", class1ForBuildingBlockType1, miscArtifact1));
}
Aggregations