-
Notifications
You must be signed in to change notification settings - Fork 557
Expand file tree
/
Copy pathCodeClimateConfigTest.java
More file actions
44 lines (36 loc) · 1.43 KB
/
CodeClimateConfigTest.java
File metadata and controls
44 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package fr.xephi.authme;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Consistency test for the CodeClimate configuration file.
*/
class CodeClimateConfigTest {
private static final String CONFIG_FILE = ".codeclimate.yml";
@Test
void shouldHaveExistingClassesInExclusions() {
// given / when
FileConfiguration configuration = YamlConfiguration.loadConfiguration(new File(CONFIG_FILE));
List<String> excludePaths = configuration.getStringList("exclude_patterns");
// then
assertThat(excludePaths, not(empty()));
removeTestsExclusionOrThrow(excludePaths);
for (String path : excludePaths) {
if (!new File(path).exists()) {
fail("Path '" + path + "' does not exist!");
}
}
}
private static void removeTestsExclusionOrThrow(List<String> excludePaths) {
boolean wasRemoved = excludePaths.removeIf("src/test/java/**/*Test.java"::equals);
assertThat("Expected an exclusion for test classes",
wasRemoved, equalTo(true));
}
}