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
1 parent
5b13205
commit 7ca857b
Showing
10 changed files
with
216 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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
/** | ||
* 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.Ignore; | ||
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 com.google.testing.compile.Compilation; | ||
import com.google.testing.compile.Compiler; | ||
|
||
public class CycleTest extends PluginTestBase { | ||
|
||
@Test | ||
@Ignore | ||
public void shouldDetectCycleInArchitectureModel() { | ||
Compilation compilation = Compiler.javac() | ||
.withOptions( | ||
"-Xplugin:Deptective", | ||
getConfigFileOption() | ||
) | ||
.compile( | ||
forTestClass(Foo.class), | ||
forTestClass(Bar.class), | ||
forTestClass(Baz.class) | ||
); | ||
|
||
assertThat(compilation).failed(); | ||
assertThat(compilation).hadErrorContaining( | ||
"Architecture model contains component cycle(s): foo -> bar -> baz -> foo" | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
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,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.bar; | ||
|
||
import org.moditect.deptective.plugintest.cycle.baz.Baz; | ||
|
||
public class Bar { | ||
|
||
Baz baz; | ||
} |
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(); | ||
} |
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
19 changes: 19 additions & 0 deletions
19
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,19 @@ | ||
{ | ||
"components" : [ | ||
{ | ||
"name" : "foo", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.foo" ], | ||
"reads" : [ "bar" ] | ||
}, | ||
{ | ||
"name" : "bar", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.bar" ], | ||
"reads" : [ "baz" ] | ||
}, | ||
{ | ||
"name" : "baz", | ||
"contains" : [ "org.moditect.deptective.plugintest.cycle.baz" ], | ||
"reads" : [ "foo" ] | ||
} | ||
] | ||
} |