Migrate to Junit 5 syntax (#421)
This commit is contained in:
parent
73b3248542
commit
7b1d8e7368
20 changed files with 64 additions and 77 deletions
|
@ -1,14 +1,10 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ package net.kemitix.checkstyle.ruleset.builder;
|
|||
import lombok.val;
|
||||
import me.andrz.builder.map.MapBuilder;
|
||||
import org.assertj.core.api.ThrowableAssert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
@ -36,11 +36,8 @@ public class CheckstyleWriterTest {
|
|||
|
||||
private static final String FILE_SEPARATOR = System.getProperty("file.separator");
|
||||
|
||||
@org.junit.Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@org.junit.Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
@TempDir
|
||||
public File folder;
|
||||
|
||||
private CheckstyleWriter checkstyleWriter;
|
||||
|
||||
|
@ -61,7 +58,7 @@ public class CheckstyleWriterTest {
|
|||
private RuleClassLocator ruleClassLocator = mock(RuleClassLocator.class);
|
||||
private SourcesProperties sourceProperties = new SourcesProperties();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
ruleName = "RegexpOnFilename";
|
||||
ruleClassname = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck";
|
||||
|
@ -74,12 +71,12 @@ public class CheckstyleWriterTest {
|
|||
.put(getOutputFile(RuleLevel.COMPLEXITY))
|
||||
.build();
|
||||
outputProperties.setRulesetFiles(outputFiles);
|
||||
outputDirectory = folder.newFolder()
|
||||
.toPath();
|
||||
outputDirectory = folder.toPath();
|
||||
Files.createDirectories(outputDirectory);
|
||||
outputProperties.setDirectory(outputDirectory);
|
||||
templateProperties = new TemplateProperties();
|
||||
val checkstyleTemplate = folder.newFile("checkstyle-template.xml")
|
||||
.toPath();
|
||||
val checkstyleTemplate = folder.toPath().resolve("checkstyle-template.xml");
|
||||
checkstyleTemplate.toFile().createNewFile();
|
||||
Files.write(
|
||||
checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING);
|
||||
templateProperties.setCheckstyleXml(checkstyleTemplate);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import lombok.val;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -20,7 +20,7 @@ public class DefaultReadmeIndexBuilderTest {
|
|||
|
||||
private RulesProperties rulesProperties;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
rulesProperties = new RulesProperties();
|
||||
indexBuilder = new DefaultReadmeIndexBuilder(rulesProperties);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class DefaultRuleClassLocatorTest {
|
|||
private final RuleSource checkstyleRuleSource = RuleSourceMother.checkstyle.get();
|
||||
private final RuleSource sevntuRuleSource = RuleSourceMother.sevntu.get();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
sourceProperties.setSources(Arrays.asList(
|
||||
checkstyleRuleSource, sevntuRuleSource
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import lombok.val;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultRuleReadmeLoader}.
|
||||
*
|
||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||
*/
|
||||
public class DefaultRuleReadmeLoaderTest {
|
||||
public class DefaultRuleReadmeLoaderTest
|
||||
implements WithAssertions {
|
||||
|
||||
private RuleReadmeLoader loader;
|
||||
|
||||
|
@ -27,17 +27,14 @@ public class DefaultRuleReadmeLoaderTest {
|
|||
|
||||
private Path fragments;
|
||||
|
||||
@org.junit.Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
@TempDir
|
||||
public File folder;
|
||||
|
||||
@org.junit.Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
final TemplateProperties templateProperties = new TemplateProperties();
|
||||
fragments = folder.newFolder("fragments")
|
||||
.toPath();
|
||||
fragments = folder.toPath().resolve("fragments");
|
||||
Files.createDirectories(fragments);
|
||||
templateProperties.setReadmeFragments(fragments);
|
||||
loader = new DefaultRuleReadmeLoader(templateProperties);
|
||||
rule = new Rule();
|
||||
|
@ -61,10 +58,10 @@ public class DefaultRuleReadmeLoaderTest {
|
|||
public void loadEnabledWithMissingFragment() {
|
||||
//given
|
||||
rule.setEnabled(true);
|
||||
exception.expect(ReadmeFragmentNotFoundException.class);
|
||||
exception.expectMessage("name");
|
||||
//when
|
||||
loader.load(rule);
|
||||
assertThatExceptionOfType(ReadmeFragmentNotFoundException.class)
|
||||
.isThrownBy(() -> loader.load(rule))
|
||||
.withMessage("name");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -2,8 +2,8 @@ package net.kemitix.checkstyle.ruleset.builder;
|
|||
|
||||
import lombok.val;
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
|
@ -17,7 +17,7 @@ public class OutputPropertiesTest {
|
|||
|
||||
private OutputProperties outputProperties;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
outputProperties = new OutputProperties();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
|
@ -19,7 +17,7 @@ public class ReadmeBuilderTest {
|
|||
private ReadmeBuilder readmeBuilder;
|
||||
private String template = "i:%s,ec:%s,es:%s,dc:%s,ds:%s";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import lombok.val;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import net.kemitix.files.FileReaderWriter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
@ -40,7 +40,7 @@ public class ReadmeWriterTest {
|
|||
private String templateBody = UUID.randomUUID().toString();
|
||||
private String formattedOutput = UUID.randomUUID().toString();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws IOException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class RuleLoaderTest {
|
|||
private String enabledRuleName = "enabled-" + UUID.randomUUID().toString();
|
||||
private String disabledRuleName = "disabled-" + UUID.randomUUID().toString();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import lombok.val;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -2,9 +2,8 @@ package net.kemitix.checkstyle.ruleset.builder;
|
|||
|
||||
import lombok.val;
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -19,7 +18,7 @@ public class RuleTest {
|
|||
|
||||
private RuleSource ruleSource = RuleSourceMother.checkstyle.get();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
rule = new Rule();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class RulesPropertiesTest {
|
|||
|
||||
private RulesProperties rulesProperties;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
rulesProperties = new RulesProperties();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -9,7 +9,7 @@ public class SourcesPropertiesTest {
|
|||
|
||||
private SourcesProperties sourcesProperties;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
sourcesProperties = new SourcesProperties();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package net.kemitix.checkstyle.ruleset.builder;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
@ -17,7 +17,7 @@ public class TemplatePropertiesTest {
|
|||
|
||||
private TemplateProperties templateProperties;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
templateProperties = new TemplateProperties();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue