Search in sources :

Example 16 with Application

use of org.archifacts.core.model.Application in project archifacts by archifacts.

the class AxonDescriptorsTest method assertThat_source_based_artifact_relationship_descriptor_are_recognized.

@ParameterizedTest
@MethodSource("getSourceBasedArtifactRelationshipDescriptors")
void assertThat_source_based_artifact_relationship_descriptor_are_recognized(final SourceBasedArtifactRelationshipDescriptor sourceBasedArtifactRelationshipDescriptor, final Tuple... expectedTuples) {
    final Application application = Application.builder().descriptor(sourceBasedArtifactRelationshipDescriptor).buildApplication(DOMAIN);
    assertThat(application.getRelationshipsOfRole(sourceBasedArtifactRelationshipDescriptor.role())).extracting(r -> r.getSource().getJavaClass().reflect(), r -> r.getTarget().getJavaClass().reflect()).containsExactlyInAnyOrder(expectedTuples);
}
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)

Example 17 with Application

use of org.archifacts.core.model.Application in project archifacts by archifacts.

the class C4ModelBuilderTest method assert_that_relationships_are_not_added_automatically.

@Test
void assert_that_relationships_are_not_added_automatically() {
    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.getArtifacts().stream().forEach(c4ModelBuilder::artifact);
    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 Set<Component> components = containers.iterator().next().getComponents();
    assertThat(components).hasSize(2).extracting(Component::getName, Component::getTechnology).containsExactlyInAnyOrder(tuple("Class1ForBuildingBlockType1", "BuildingBlockType1"), tuple("MiscArtifact1", "Misc"));
    assertThat(components).flatMap(Component::getRelationships).isEmpty();
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ArtifactContainer(org.archifacts.core.model.ArtifactContainer) Container(com.structurizr.model.Container) Component(com.structurizr.model.Component) Application(org.archifacts.core.model.Application) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Aggregations

Application (org.archifacts.core.model.Application)17 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)16 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)16 Workspace (com.structurizr.Workspace)12 Test (org.junit.jupiter.api.Test)12 Component (com.structurizr.model.Component)10 Container (com.structurizr.model.Container)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 Set (java.util.Set)7 Stream (java.util.stream.Stream)7 BuildingBlockDescriptor (org.archifacts.core.descriptor.BuildingBlockDescriptor)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 DisplayNameGeneration (org.junit.jupiter.api.DisplayNameGeneration)7 ReplaceUnderscores (org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores)7 SourceBasedArtifactRelationshipDescriptor (org.archifacts.core.descriptor.SourceBasedArtifactRelationshipDescriptor)5 Artifact (org.archifacts.core.model.Artifact)5 BuildingBlock (org.archifacts.core.model.BuildingBlock)5 MiscArtifact (org.archifacts.core.model.MiscArtifact)5 Assertions.tuple (org.assertj.core.api.Assertions.tuple)5 JavaClass (com.tngtech.archunit.core.domain.JavaClass)4