forked from moditect/deptective
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moditect#27 WIP Adding cycle detection to architecture validation
- Loading branch information
1 parent
2e21d50
commit 396ba1f
Showing
11 changed files
with
244 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
javac-plugin/src/test/java/org/moditect/deptective/plugintest/cycle/CycleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.moditect.deptective.plugintest.cycle; | ||
|
||
import static com.google.testing.compile.CompilationSubject.assertThat; | ||
|
||
import org.junit.Test; | ||
import org.moditect.deptective.plugintest.PluginTestBase; | ||
import org.moditect.deptective.plugintest.cycle.bar.Bar; | ||
import org.moditect.deptective.plugintest.cycle.baz.Baz; | ||
import org.moditect.deptective.plugintest.cycle.foo.Foo; | ||
import org.moditect.deptective.plugintest.cycle.qux.Qux; | ||
|
||
import com.google.testing.compile.Compilation; | ||
import com.google.testing.compile.Compiler; | ||
|
||
public class CycleTest extends PluginTestBase { | ||
|
||
@Test | ||
public void shouldDetectCyclesInArchitectureModel() { | ||
Compilation compilation = Compiler.javac() | ||
.withOptions( | ||
"-Xplugin:Deptective", | ||
getConfigFileOption() | ||
) | ||
.compile( | ||
forTestClass(Foo.class), | ||
forTestClass(Bar.class), | ||
forTestClass(Baz.class), | ||
forTestClass(Qux.class) | ||
); | ||
|
||
assertThat(compilation).failed(); | ||
assertThat(compilation).hadErrorContaining("Architecture model contains cycle(s) between these components:"); | ||
assertThat(compilation).hadErrorContaining(" - bar, baz, foo, qux"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
javac-plugin/src/test/java/org/moditect/deptective/plugintest/cycle/bar/Bar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.moditect.deptective.plugintest.cycle.bar; | ||
|
||
import org.moditect.deptective.plugintest.cycle.baz.Baz; | ||
import org.moditect.deptective.plugintest.cycle.qux.Qux; | ||
|
||
public class Bar { | ||
|
||
Baz baz; | ||
Qux qux; | ||
} |
23 changes: 23 additions & 0 deletions
23
javac-plugin/src/test/java/org/moditect/deptective/plugintest/cycle/baz/Baz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.moditect.deptective.plugintest.cycle.baz; | ||
|
||
import org.moditect.deptective.plugintest.cycle.foo.Foo; | ||
|
||
public class Baz { | ||
|
||
private Foo foo; | ||
} |
23 changes: 23 additions & 0 deletions
23
javac-plugin/src/test/java/org/moditect/deptective/plugintest/cycle/foo/Foo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.moditect.deptective.plugintest.cycle.foo; | ||
|
||
import org.moditect.deptective.plugintest.cycle.bar.Bar; | ||
|
||
public class Foo { | ||
|
||
private final Bar bar = new Bar(); | ||
} |
23 changes: 23 additions & 0 deletions
23
javac-plugin/src/test/java/org/moditect/deptective/plugintest/cycle/qux/Qux.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.moditect.deptective.plugintest.cycle.qux; | ||
|
||
import org.moditect.deptective.plugintest.cycle.bar.Bar; | ||
|
||
public class Qux { | ||
|
||
Bar bar; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
javac-plugin/src/test/resources/org/moditect/deptective/plugintest/cycle/deptective.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"components" : [ | ||
{ | ||
"name" : "foo", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.foo" ], | ||
"reads" : [ "bar" ] | ||
}, | ||
{ | ||
"name" : "bar", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.bar" ], | ||
"reads" : [ "baz", "qux" ] | ||
}, | ||
{ | ||
"name" : "baz", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.baz" ], | ||
"reads" : [ "foo" ] | ||
}, | ||
{ | ||
"name" : "qux", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.qux" ], | ||
"reads" : [ "bar" ] | ||
} | ||
] | ||
} |