Skip to content

Commit

Permalink
Extend architecture tests to javafx and javafx.collections (#2719)
Browse files Browse the repository at this point in the history
* Extend architecture tests to javafx and javafx.collections

* Add more exceptions for javafx Color, beans and the tests to the architecture tests

* Add more exceptions for things that tobias commited in the meantime
  • Loading branch information
lenhard authored and tobiasdiez committed Apr 18, 2017
1 parent 73b18f4 commit 472ca3c
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/test/java/org/jabref/ArchitectureTests.java
Expand Up @@ -5,6 +5,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -23,12 +24,18 @@ public class ArchitectureTests {

private static final String PACKAGE_JAVAX_SWING = "javax.swing";
private static final String PACKAGE_JAVA_AWT = "java.awt";
private static final String PACKAGE_JAVA_FX = "javafx";

private static final String PACKAGE_ORG_JABREF_GUI = "org.jabref.gui";
private static final String PACKAGE_ORG_JABREF_LOGIC = "org.jabref.logic";
private static final String PACKAGE_ORG_JABREF_MODEL = "org.jabref.model";
private static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals";

private static final String EXCEPTION_PACKAGE_JAVA_AWT_GEOM = "java.awt.geom";
private static final String EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS = "javafx.collections";
private static final String EXCEPTION_PACKAGE_JAVA_FX_BEANS = "javafx.beans";
private static final String EXCEPTION_CLASS_JAVA_FX_COLOR = "javafx.scene.paint.Color";

private final String firstPackage;
private final String secondPackage;
private Map<String, List<String>> exceptions;
Expand All @@ -40,22 +47,38 @@ public ArchitectureTests(String firstPackage, String secondPackage) {
// Add exceptions for the architectural test here
// Note that bending the architectural constraints should not be done inconsiderately
exceptions = new HashMap<>();

List<String> logicExceptions = new ArrayList<>(4);
logicExceptions.add(EXCEPTION_PACKAGE_JAVA_AWT_GEOM);
logicExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS);
logicExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_BEANS);
logicExceptions.add(EXCEPTION_CLASS_JAVA_FX_COLOR);

List<String> modelExceptions = new ArrayList<>(4);
modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS);
modelExceptions.add(EXCEPTION_CLASS_JAVA_FX_COLOR);
modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS);
modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_BEANS);

exceptions.put(PACKAGE_ORG_JABREF_LOGIC,
Collections.singletonList(EXCEPTION_PACKAGE_JAVA_AWT_GEOM));
logicExceptions);
exceptions.put(PACKAGE_ORG_JABREF_MODEL, modelExceptions);
}


@Parameterized.Parameters(name = "{index} -- is {0} independent of {1}?")
public static Iterable<Object[]> data() {
return Arrays.asList(
new Object[][] {
new Object[][]{
{PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_AWT},
{PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVAX_SWING},
{PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_FX},
{PACKAGE_ORG_JABREF_LOGIC, PACKAGE_ORG_JABREF_GUI},
{PACKAGE_ORG_JABREF_LOGIC, CLASS_ORG_JABREF_GLOBALS},

{PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_AWT},
{PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVAX_SWING},
{PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_FX},
{PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_GUI},
{PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_LOGIC},
{PACKAGE_ORG_JABREF_MODEL, CLASS_ORG_JABREF_GLOBALS}
Expand All @@ -72,7 +95,7 @@ public void firstPackageIsIndependentOfSecondPackage() throws IOException {

Predicate<String> isPackage = (s) -> s.startsWith("package " + firstPackage);

List<Path> files = Files.walk(Paths.get("src"))
List<Path> files = Files.walk(Paths.get("src/main/"))
.filter(p -> p.toString().endsWith(".java"))
.filter(p -> {
try {
Expand All @@ -92,5 +115,4 @@ public void firstPackageIsIndependentOfSecondPackage() throws IOException {
Assert.assertEquals("The following classes are not allowed to depend on " + secondPackage,
Collections.emptyList(), files);
}

}

0 comments on commit 472ca3c

Please sign in to comment.