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

Extend architecture tests to javafx and javafx.collections #2719

Merged
merged 4 commits into from Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}

}