Skip to content

Commit

Permalink
refactor: ArchUnit ImportUnit does not work when running GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
TatuLund committed Feb 6, 2025
1 parent 2b8a7e9 commit 638aad1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.vaadin.tatu.vaadincreate.auth.MockAccessControl;
import org.vaadin.tatu.vaadincreate.auth.RolesPermitted;
import org.vaadin.tatu.vaadincreate.backend.data.User.Role;
import org.vaadin.tatu.vaadincreate.i18n.HasI18N;

import com.vaadin.testbench.uiunittest.UIUnitTest;

import com.vaadin.icons.VaadinIcons;
Expand Down Expand Up @@ -83,7 +85,8 @@ private void mockApp(UI ui, MockAccessControl accessControl) {

@SuppressWarnings("serial")
@RolesPermitted({ Role.ADMIN })
public static class MockView extends VerticalLayout implements View {
public static class MockView extends VerticalLayout
implements View, HasI18N {

Label label = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.vaadin.tatu.vaadincreate.i18n.HasI18N;
import org.vaadin.tatu.vaadincreate.i18n.I18n;

import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.junit.ArchUnitRunner;
Expand All @@ -39,15 +38,15 @@
* of the lockedobjects package.
*/
@RunWith(ArchUnitRunner.class)
@AnalyzeClasses(packages = { "org.vaadin.tatu.vaadincreate",
"com.vaadin" }, importOptions = ImportOption.DoNotIncludeTests.class)
@AnalyzeClasses(packages = { "org.vaadin.tatu.vaadincreate", "com.vaadin" })
public class ArchitectureTest {

@ArchTest
public static final ArchRule Services_are_called_only_by_the_Preseters_UI_and_Auth = classes()
.that().resideInAPackage("..backend..").and()
.haveSimpleNameEndingWith("Service").should().onlyBeAccessed()
.byClassesThat(have(simpleNameEndingWith("Presenter"))
.or(have(simpleNameEndingWith("Test")))
.or(have(simpleName("VaadinCreateUI")))
.or(have(simpleName("AboutView")))
.or(resideInAPackage("..auth.."))
Expand All @@ -59,6 +58,7 @@ public class ArchitectureTest {
.that().resideInAPackage("..vaadincreate.eventbus..").should()
.onlyBeAccessed()
.byClassesThat(have(simpleNameEndingWith("Presenter"))
.or(have(simpleNameEndingWith("Test")))
.or(have(simpleName("VaadinCreateUI")))
.or(have(simpleName("AboutView")))
.or(resideInAPackage("..eventbus.."))
Expand Down Expand Up @@ -109,14 +109,16 @@ public class ArchitectureTest {
@ArchTest
public static final ArchRule AppLayout_should_be_used_only_by_VaadinCreateUI = classes()
.that().haveSimpleName("AppLayout").should().onlyBeAccessed()
.byClassesThat(have(simpleName("VaadinCreateUI"))
.byClassesThat(have(simpleNameEndingWith("Test"))
.or(have(simpleName("VaadinCreateUI")))
.or(have(simpleName("AppLayout"))
.or(belongTo(simpleName("AppLayout")))));

@ArchTest
public static final ArchRule LoginView_should_be_used_only_by_VaadinCreateUI = classes()
.that().haveSimpleName("LoginView").should().onlyBeAccessed()
.byClassesThat(have(simpleName("VaadinCreateUI"))
.byClassesThat(have(simpleNameEndingWith("Test"))
.or(have(simpleName("VaadinCreateUI")))
.or(have(simpleName("LoginView"))));

@ArchTest
Expand Down

0 comments on commit 638aad1

Please sign in to comment.