Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when layer name does not exists #74

Closed
simasch opened this issue May 30, 2018 · 1 comment
Closed

NPE when layer name does not exists #74

simasch opened this issue May 30, 2018 · 1 comment
Assignees

Comments

@simasch
Copy link

simasch commented May 30, 2018

I made a mistake in my layeredArchitecture definition. There is no layer called control:

   @ArchTest
    public static final ArchRule layerRule = layeredArchitecture()
            .layer("boundary").definedBy("..boundary..")
            .layer("service").definedBy("..control.service..")
            .layer("repository").definedBy("..control.repository..")
            .layer("entity").definedBy("..entity..")

            .whereLayer("boundary").mayNotBeAccessedByAnyLayer()
            .whereLayer("repository").mayOnlyBeAccessedByLayers("boundary", "control")
            .whereLayer("service").mayOnlyBeAccessedByLayers("boundary")
            .whereLayer("entity").mayOnlyBeAccessedByLayers("boundary", "control");

When I execute the test I get a NPE:

java.lang.NullPointerException
	at com.tngtech.archunit.library.Architectures$LayeredArchitecture$LayerDefinition.access$500(Architectures.java:229)
	at com.tngtech.archunit.library.Architectures$LayeredArchitecture.packagesOf(Architectures.java:218)
	at com.tngtech.archunit.library.Architectures$LayeredArchitecture.evaluate(Architectures.java:151)
	at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:79)
	at com.tngtech.archunit.library.Architectures$LayeredArchitecture.check(Architectures.java:174)
	at com.tngtech.archunit.junit.ArchRuleExecution.evaluateOn(ArchRuleExecution.java:57)
	at com.tngtech.archunit.junit.ArchUnitRunner.runChild(ArchUnitRunner.java:134)
	at com.tngtech.archunit.junit.ArchUnitRunner.runChild(ArchUnitRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at com.tngtech.archunit.junit.ArchUnitRunner$1.evaluate(ArchUnitRunner.java:73)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

It would be great to print a meaningful error message instead of the NPE.

@codecholeric
Copy link
Collaborator

You're absolutely right, I'll look into that right away and add a meaningful error message!!

@codecholeric codecholeric self-assigned this May 30, 2018
codecholeric added a commit that referenced this issue Feb 21, 2021
…edByLayers(..)' with meaningful error message (instead of NPE).

Resolves: #74
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants