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

Update Architecture Tests to catch static imports #3766

Merged
merged 2 commits into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.Assert;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MainArchitectureTests {

public static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals";
Expand Down Expand Up @@ -78,7 +79,8 @@ public static Stream<Arguments> getPackages() {
@ParameterizedTest(name = "{index} -- is {0} independent of {1}?")
@MethodSource("getPackages")
public void firstPackageIsIndependentOfSecondPackage(String firstPackage, String secondPackage) throws IOException {
Predicate<String> isExceptionPackage = (s) -> s.startsWith("import " + secondPackage)
Predicate<String> isExceptionPackage = (s) -> (s.startsWith("import " + secondPackage)
|| s.startsWith("import static " + secondPackage))
&& exceptions.getOrDefault(firstPackage, Collections.emptyList())
.stream()
.noneMatch(exception -> s.startsWith("import " + exception));
Expand All @@ -104,8 +106,7 @@ public void firstPackageIsIndependentOfSecondPackage(String firstPackage, String
})
.collect(Collectors.toList());

Assert.assertEquals("The following classes are not allowed to depend on " + secondPackage,
Collections.emptyList(), files);
assertEquals(Collections.emptyList(), files, "The following classes are not allowed to depend on " + secondPackage);
}
}
}