Search in sources :

Example 1 with SpringBean

use of org.moduliths.model.SpringBean in project moduliths by moduliths.

the class DocumenterUnitTests method groupsSpringBeansByArchitecturallyEvidentType.

// #130
@Test
void groupsSpringBeansByArchitecturallyEvidentType() {
    Groupings result = CanvasOptions.defaults().groupingBy(of("Representations", nameMatching(".*Representations"))).groupingBy(of("Interface implementations", subtypeOf(Stereotypes.SomeAppInterface.class))).groupBeans(modules.getModuleByName("stereotypes").orElseThrow(RuntimeException::new));
    assertThat(result.keySet()).extracting(Grouping::getName).containsExactlyInAnyOrder("Controllers", "Services", "Repositories", "Event listeners", "Configuration properties", "Representations", "Interface implementations", "Others");
    List<SpringBean> impls = result.byGroupName("Interface implementations");
    // 
    assertThat(impls).hasSize(1).extracting(// 
    it -> it.getType()).extracting(// 
    JavaClass::getSimpleName).containsExactly("SomeAppInterfaceImplementation");
    List<SpringBean> listeners = result.byGroupName("Event listeners");
    // 
    assertThat(listeners).hasSize(2).extracting(// 
    it -> it.getType()).extracting(// 
    JavaClass::getSimpleName).containsOnly("SomeEventListener", "SomeTxEventListener");
}
Also used : Groupings(org.moduliths.docs.Documenter.CanvasOptions.Groupings) SpringBean(org.moduliths.model.SpringBean) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 Groupings (org.moduliths.docs.Documenter.CanvasOptions.Groupings)1 SpringBean (org.moduliths.model.SpringBean)1