use of org.archifacts.core.model.ArtifactContainer in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_computation_rule_is_applied_to_artifact.
@Test
void assert_that_computation_rule_is_applied_to_artifact() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(buildingBlockType1Descriptor).descriptor(defaultContainerDescriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
final Set<ArtifactContainer> artifactContainers = application.getContainersOfType(containerType1);
assertThat(artifactContainers).hasSize(1);
final ArtifactContainer defaultContainer = artifactContainers.iterator().next();
application.getBuildingBlocksOfType(buildingBlockType1).forEach(c4ModelBuilder::artifact);
c4ModelBuilder.artifactRule().predicate(artifact -> artifact.getName().equals("Class1ForBuildingBlockType1")).computation((artifact, lookup) -> Set.of(lookup.container(defaultContainer).addComponent("CustomName1", null, "CustomTechnology1"), lookup.container(defaultContainer).addComponent("CustomName2", null, "CustomTechnology2")));
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("CustomName1", "CustomTechnology1"), tuple("CustomName2", "CustomTechnology2"));
}
Aggregations