Move tests to JUnit 5 wherever possible
This commit is contained in:
@@ -20,7 +20,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -30,16 +30,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurationMetadataTests {
|
||||
class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void nullResource() throws IOException {
|
||||
void nullResource() throws IOException {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ConfigurationMetadataRepositoryJsonBuilder.create().withJsonResource(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleRepository() throws IOException {
|
||||
void simpleRepository() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo).build();
|
||||
validateFoo(repo);
|
||||
@@ -50,7 +50,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hintsOnMaps() throws IOException {
|
||||
void hintsOnMaps() throws IOException {
|
||||
try (InputStream map = getInputStreamFor("map")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(map).build();
|
||||
validateMap(repo);
|
||||
@@ -62,7 +62,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalRepositoriesNoConflict() throws IOException {
|
||||
void severalRepositoriesNoConflict() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar).build();
|
||||
validateFoo(repo);
|
||||
@@ -75,7 +75,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repositoryWithRoot() throws IOException {
|
||||
void repositoryWithRoot() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream root = getInputStreamFor("root")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root).build();
|
||||
validateFoo(repo);
|
||||
@@ -88,7 +88,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalRepositoriesIdenticalGroups() throws IOException {
|
||||
void severalRepositoriesIdenticalGroups() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream foo2 = getInputStreamFor("foo2")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2).build();
|
||||
assertThat(repo.getAllGroups()).hasSize(1);
|
||||
@@ -105,7 +105,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyGroups() throws IOException {
|
||||
void emptyGroups() throws IOException {
|
||||
try (InputStream in = getInputStreamFor("empty-groups")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(in).build();
|
||||
validateEmptyGroup(repo);
|
||||
@@ -116,7 +116,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiGroups() throws IOException {
|
||||
void multiGroups() throws IOException {
|
||||
try (InputStream in = getInputStreamFor("multi-groups")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(in).build();
|
||||
assertThat(repo.getAllGroups()).containsOnlyKeys("test.group.one.retry", "test.group.two.retry",
|
||||
@@ -134,7 +134,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon
|
||||
}
|
||||
|
||||
@Test
|
||||
public void builderInstancesAreIsolated() throws IOException {
|
||||
void builderInstancesAreIsolated() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create();
|
||||
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
@@ -32,26 +32,26 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
|
||||
|
||||
private final JsonReader reader = new JsonReader();
|
||||
|
||||
@Test
|
||||
public void emptyMetadata() throws IOException {
|
||||
void emptyMetadata() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("empty");
|
||||
assertThat(rawMetadata.getSources()).isEmpty();
|
||||
assertThat(rawMetadata.getItems()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidMetadata() throws IOException {
|
||||
void invalidMetadata() throws IOException {
|
||||
assertThatIllegalStateException().isThrownBy(() -> readFor("invalid")).withCauseInstanceOf(JSONException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyGroupName() throws IOException {
|
||||
void emptyGroupName() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("empty-groups");
|
||||
List<ConfigurationMetadataItem> items = rawMetadata.getItems();
|
||||
assertThat(items).hasSize(2);
|
||||
@@ -63,7 +63,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleMetadata() throws IOException {
|
||||
void simpleMetadata() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("foo");
|
||||
List<ConfigurationMetadataSource> sources = rawMetadata.getSources();
|
||||
assertThat(sources).hasSize(2);
|
||||
@@ -104,7 +104,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metadataHints() throws IOException {
|
||||
void metadataHints() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("bar");
|
||||
List<ConfigurationMetadataHint> hints = rawMetadata.getHints();
|
||||
assertThat(hints).hasSize(1);
|
||||
@@ -130,7 +130,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rootMetadata() throws IOException {
|
||||
void rootMetadata() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("root");
|
||||
List<ConfigurationMetadataSource> sources = rawMetadata.getSources();
|
||||
assertThat(sources).isEmpty();
|
||||
@@ -141,7 +141,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deprecatedMetadata() throws IOException {
|
||||
void deprecatedMetadata() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("deprecated");
|
||||
List<ConfigurationMetadataItem> items = rawMetadata.getItems();
|
||||
assertThat(items).hasSize(5);
|
||||
@@ -185,7 +185,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiGroupsMetadata() throws IOException {
|
||||
void multiGroupsMetadata() throws IOException {
|
||||
RawConfigurationMetadata rawMetadata = readFor("multi-groups");
|
||||
List<ConfigurationMetadataItem> items = rawMetadata.getItems();
|
||||
assertThat(items).hasSize(3);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.configurationmetadata;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -25,46 +25,46 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SentenceExtractorTests {
|
||||
class SentenceExtractorTests {
|
||||
|
||||
private static final String NEW_LINE = System.lineSeparator();
|
||||
|
||||
private SentenceExtractor extractor = new SentenceExtractor();
|
||||
|
||||
@Test
|
||||
public void extractFirstSentence() {
|
||||
void extractFirstSentence() {
|
||||
String sentence = this.extractor.getFirstSentence("My short " + "description. More stuff.");
|
||||
assertThat(sentence).isEqualTo("My short description.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractFirstSentenceNewLineBeforeDot() {
|
||||
void extractFirstSentenceNewLineBeforeDot() {
|
||||
String sentence = this.extractor
|
||||
.getFirstSentence("My short" + NEW_LINE + "description." + NEW_LINE + "More stuff.");
|
||||
assertThat(sentence).isEqualTo("My short description.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractFirstSentenceNewLineBeforeDotWithSpaces() {
|
||||
void extractFirstSentenceNewLineBeforeDotWithSpaces() {
|
||||
String sentence = this.extractor
|
||||
.getFirstSentence("My short " + NEW_LINE + " description. " + NEW_LINE + "More stuff.");
|
||||
assertThat(sentence).isEqualTo("My short description.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractFirstSentenceNoDot() {
|
||||
void extractFirstSentenceNoDot() {
|
||||
String sentence = this.extractor.getFirstSentence("My short description");
|
||||
assertThat(sentence).isEqualTo("My short description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractFirstSentenceNoDotMultipleLines() {
|
||||
void extractFirstSentenceNoDotMultipleLines() {
|
||||
String sentence = this.extractor.getFirstSentence("My short description " + NEW_LINE + " More stuff");
|
||||
assertThat(sentence).isEqualTo("My short description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractFirstSentenceNull() {
|
||||
void extractFirstSentenceNull() {
|
||||
assertThat(this.extractor.getFirstSentence(null)).isNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user