Skip to content

Commit

Permalink
Merge pull request #170 from SpongePowered/chore/package-private-tests
Browse files Browse the repository at this point in the history
chore: Make test methods package-private
  • Loading branch information
zml2008 authored Oct 4, 2020
2 parents 74a255f + ff9cbd1 commit aacef64
Show file tree
Hide file tree
Showing 27 changed files with 186 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class AbstractConfigurationNodeTest {

@Test
public void testUnattachedNodesTemporary() {
void testUnattachedNodesTemporary() {
final ConfigurationNode config = BasicConfigurationNode.root();
final ConfigurationNode node = config.getNode("some", "node");
assertTrue(node.isVirtual());
Expand All @@ -64,7 +64,7 @@ public void testUnattachedNodesTemporary() {
}

@Test
public void testNodeCreation() {
void testNodeCreation() {
final ConfigurationNode config = BasicConfigurationNode.root();
final ConfigurationNode uncreatedNode = config.getNode("uncreated", "node");
assertTrue(uncreatedNode.isVirtual()); // Just in case
Expand All @@ -78,7 +78,7 @@ public void testNodeCreation() {
}

@Test
public void testTraversingNodeCreation() {
void testTraversingNodeCreation() {
final ConfigurationNode config = BasicConfigurationNode.root();
final ConfigurationNode nodeOne = config.getNode("uncreated", "step", "node").setValue("one");
final ConfigurationNode nodeTwo = config.getNode("uncreated", "step", "color").setValue("lilac");
Expand All @@ -88,14 +88,14 @@ public void testTraversingNodeCreation() {
}

@Test
public void testGetDefaultValue() {
void testGetDefaultValue() {
final ConfigurationNode root = BasicConfigurationNode.root();
final Object testObj = new Object();
assertEquals(testObj, root.getNode("nonexistent").getValue(testObj));
}

@Test
public void testGetChildrenMap() {
void testGetChildrenMap() {
final ConfigurationNode root = BasicConfigurationNode.root();
final ConfigurationNode a = root.getNode("a").setValue("one");
final ConfigurationNode b = root.getNode("b").setValue("two");
Expand All @@ -106,7 +106,7 @@ public void testGetChildrenMap() {
}

@Test
public void testGetChildrenList() {
void testGetChildrenList() {
final ConfigurationNode root = BasicConfigurationNode.root();
final ConfigurationNode a = root.appendListNode().setValue("one");
final ConfigurationNode b = root.appendListNode().setValue("two");
Expand All @@ -125,15 +125,15 @@ public void testGetChildrenList() {
}

@Test
public void testMapUnpacking() {
void testMapUnpacking() {
final ConfigurationNode root = BasicConfigurationNode.root();
root.setValue(TEST_MAP);
assertEquals("value", root.getNode("key").getValue());
assertEquals(true, root.getNode("fabulous").getValue());
}

@Test
public void testMapPacking() {
void testMapPacking() {
final ConfigurationNode root = BasicConfigurationNode.root();
root.getNode("key").setValue("value");
root.getNode("fabulous").setValue(true);
Expand All @@ -142,23 +142,23 @@ public void testMapPacking() {
}

@Test
public void testListUnpacking() {
void testListUnpacking() {
final ConfigurationNode root = BasicConfigurationNode.root();
root.setValue(TEST_LIST);
assertEquals("test1", root.getNode(0).getValue());
assertEquals("test2", root.getNode(1).getValue());
}

@Test
public void testListPacking() {
void testListPacking() {
final ConfigurationNode root = BasicConfigurationNode.root();
root.appendListNode().setValue("test1");
root.appendListNode().setValue("test2");
assertEquals(TEST_LIST, root.getValue());
}

@Test
public void testSingleListConversion() {
void testSingleListConversion() {
final ConfigurationNode config = BasicConfigurationNode.root();
final ConfigurationNode node = config.getNode("test", "value");
node.setValue("test");
Expand All @@ -168,7 +168,7 @@ public void testSingleListConversion() {
}

@Test
public void testSettingNullRemoves() {
void testSettingNullRemoves() {
final ConfigurationNode root = BasicConfigurationNode.root();
final ConfigurationNode child = root.getNode("child").setValue("a");
assertFalse(child.isVirtual());
Expand All @@ -179,13 +179,13 @@ public void testSettingNullRemoves() {
}

@Test
public void testGetPath() {
void testGetPath() {
final ConfigurationNode root = BasicConfigurationNode.root();
assertArrayEquals(new Object[]{"a", "b", "c"}, root.getNode("a", "b", "c").getPath().getArray());
}

@Test
public void testMergeValues() {
void testMergeValues() {
final ConfigurationNode first = BasicConfigurationNode.root();
final ConfigurationNode second = BasicConfigurationNode.root();
first.getNode("scalar").setValue("one");
Expand Down Expand Up @@ -214,7 +214,7 @@ public void testMergeValues() {
}

@Test
public void testSettingMultipleTimesWorks() {
void testSettingMultipleTimesWorks() {
final ConfigurationNode subject = BasicConfigurationNode.root();
subject.setValue(UnmodifiableCollections.buildMap(build -> {
build.put("a", "b");
Expand All @@ -231,7 +231,7 @@ public void testSettingMultipleTimesWorks() {
}

@Test
public void testGetSetValueSerialized() throws ObjectMappingException {
void testGetSetValueSerialized() throws ObjectMappingException {
final ConfigurationNode subject = BasicConfigurationNode.root(ConfigurationOptions.defaults()
.withNativeTypes(UnmodifiableCollections.toSet(String.class, Integer.class)));
subject.setValue("48");
Expand All @@ -242,7 +242,7 @@ public void testGetSetValueSerialized() throws ObjectMappingException {
}

@Test
public void testDefaultsCopied() {
void testDefaultsCopied() {
final ConfigurationNode subject = BasicConfigurationNode.root(ConfigurationOptions.defaults().withShouldCopyDefaults(true));
assertNull(subject.getValue());
assertEquals("default value", subject.getValue("default value"));
Expand All @@ -251,7 +251,7 @@ public void testDefaultsCopied() {

@Test
@SuppressWarnings("rawtypes")
public void testRawTypeFails() {
void testRawTypeFails() {
final ConfigurationNode subject = BasicConfigurationNode.root(b -> {
b.getNode("test1").setValue(2);
b.getNode("test2").setValue(3);
Expand All @@ -264,7 +264,7 @@ public void testRawTypeFails() {
}

@Test
public void testHasChildArray() {
void testHasChildArray() {
final ConfigurationNode node = BasicConfigurationNode.root();
assertFalse(node.hasChild("ball"));
assertTrue(node.getNode("ball").isVirtual());
Expand All @@ -283,15 +283,15 @@ public void testHasChildArray() {
}

@Test
public void testNullElementsForbiddenHasChild() {
void testNullElementsForbiddenHasChild() {
assertThrows(NullPointerException.class, () -> {
BasicConfigurationNode.root(n -> n.getNode("test").setValue("blah"))
.hasChild("test", null);
});
}

@Test
public void testHasChildIterable() {
void testHasChildIterable() {
final ConfigurationNode node = BasicConfigurationNode.root();
assertFalse(node.hasChild(NodePath.path("ball")));
assertTrue(node.getNode("ball").isVirtual());
Expand All @@ -310,7 +310,7 @@ public void testHasChildIterable() {
}

@Test
public void testNullOutListValue() {
void testNullOutListValue() {
BasicConfigurationNode.root(n -> {
n.appendListNode().setValue("blah");
n.appendListNode().setValue(null);
Expand All @@ -324,7 +324,7 @@ public void testNullOutListValue() {
private static final RepresentationHint<Boolean> IS_EVIL = RepresentationHint.of("evil", Boolean.class);

@Test
public void testHintsReadWrite() {
void testHintsReadWrite() {
final ConfigurationNode node = BasicConfigurationNode.root();
node.setValue("I hold hints!");
assertNull(node.getHint(IS_EVIL));
Expand All @@ -334,14 +334,14 @@ public void testHintsReadWrite() {
}

@Test
public void testHintSetToNull() {
void testHintSetToNull() {
final ConfigurationNode node = BasicConfigurationNode.root();
node.setHint(IS_EVIL, null);
assertNull(node.getHint(IS_EVIL));
}

@Test
public void testGetHintInherited() {
void testGetHintInherited() {
final ConfigurationNode root = BasicConfigurationNode.root();
root.setHint(IS_EVIL, false);

Expand All @@ -356,7 +356,7 @@ public void testGetHintInherited() {
}

@Test
public void testHintsCopied() {
void testHintsCopied() {
final ConfigurationNode original = BasicConfigurationNode.root();
original.setValue("1234").setHint(IS_EVIL, true);

Expand All @@ -369,7 +369,7 @@ public void testHintsCopied() {
}

@Test
public void testHintsMerged() {
void testHintsMerged() {
final ConfigurationNode hintHolder = BasicConfigurationNode.root()
.setValue('o')
.setHint(IS_EVIL, true);
Expand All @@ -384,7 +384,7 @@ public void testHintsMerged() {
}

@Test
public void testCollectToMap() throws ObjectMappingException {
void testCollectToMap() throws ObjectMappingException {
final ConfigurationNode target = ImmutableMap.of("one", 3,
"two", 28,
"test", 14).entrySet().stream()
Expand All @@ -397,7 +397,7 @@ public void testCollectToMap() throws ObjectMappingException {
}

@Test
public void testCollectToList() throws ObjectMappingException {
void testCollectToList() throws ObjectMappingException {
final BasicConfigurationNode target = IntStream.of(1, 2, 3, 4, 8).boxed()
.collect(BasicConfigurationNode.factory().toListCollector(Integer.class));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class AttributedConfigurationNodeTest {

@Test
public void testIsEmptyIncludesAttributes() {
void testIsEmptyIncludesAttributes() {
final AttributedConfigurationNode node = AttributedConfigurationNode.root();

assertTrue(node.isEmpty());
Expand All @@ -35,7 +35,7 @@ public void testIsEmptyIncludesAttributes() {
}

@Test
public void testSettingAttributeAttaches() {
void testSettingAttributeAttaches() {
final AttributedConfigurationNode node = AttributedConfigurationNode.root();

final AttributedConfigurationNode child = node.getNode("yoink");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ConfigurationVisitorTest {
private static final TestVisitor<BasicConfigurationNode> VISITOR = new TestVisitor<>();

@Test
public void testTree() {
void testTree() {
final BasicConfigurationNode base = BasicConfigurationNode.root();

base.getNode("cats").act(c -> {
Expand All @@ -51,22 +51,22 @@ public void testTree() {
}

@Test
public void testEmptyRoot() {
void testEmptyRoot() {
final BasicConfigurationNode base = BasicConfigurationNode.root();
final String result = base.visit(VISITOR);
assertEquals("bt", result);
}

@Test
public void testSingleScalar() {
void testSingleScalar() {
final BasicConfigurationNode base = BasicConfigurationNode.root();
base.setValue("test");
final String result = base.visit(VISITOR);
assertEquals("b(s)t", result);
}

@Test
public void testChangingValueTypeOnEnter() {
void testChangingValueTypeOnEnter() {
final ConfigurationVisitor.Safe<BasicConfigurationNode, StringBuilder, String> visitor = new TestVisitor<BasicConfigurationNode>() {
@Override
public void enterListNode(final BasicConfigurationNode node, final StringBuilder state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class CopyTest {

@Test
public void testSimpleCopy() {
void testSimpleCopy() {
final ConfigurationNode node = BasicConfigurationNode.root();
node.getNode("test").setValue(5);
node.getNode("section", "val1").setValue(true);
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testSimpleCopy() {
}

@Test
public void testCopyPaths() {
void testCopyPaths() {
final ConfigurationNode node = BasicConfigurationNode.root();
node.getNode("test").setValue(5);
node.getNode("section", "val1").setValue(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class SimpleCommentedConfigurationNodeTest {

@Test
public void testCommentsTransferred() {
void testCommentsTransferred() {
final CommentedConfigurationNode subject = CommentedConfigurationNode.root();
final CommentedConfigurationNode firstChild = subject.getNode("first");
firstChild.setValue("test value");
Expand All @@ -42,7 +42,7 @@ public void testCommentsTransferred() {
}

@Test
public void testNestedCommentsTransferred() {
void testNestedCommentsTransferred() {
final CommentedConfigurationNode subject = CommentedConfigurationNode.root();
final CommentedConfigurationNode firstChild = subject.getNode("first");
final CommentedConfigurationNode firstChildChild = firstChild.getNode("child");
Expand All @@ -61,7 +61,7 @@ public void testNestedCommentsTransferred() {
}

@Test
public void testCommentsMerged() {
void testCommentsMerged() {
final CommentedConfigurationNode source = CommentedConfigurationNode.root();
final CommentedConfigurationNode target = CommentedConfigurationNode.root();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@
public class AbstractConfigurationLoaderTest {

@Test
public void testLoadNonexistantPath(final @TempDir Path tempDir) throws IOException {
void testLoadNonexistantPath(final @TempDir Path tempDir) throws IOException {
final Path tempPath = tempDir.resolve("text5.txt").getRoot().resolve("does-not-exist-dont-edit-testdir");
final TestConfigurationLoader loader = TestConfigurationLoader.builder().setPath(tempPath).build();
loader.load();
}

@Test
public void testLoadNonexistantFile(final @TempDir Path tempDir) throws IOException {
void testLoadNonexistantFile(final @TempDir Path tempDir) throws IOException {
final File tempFile = new File(tempDir.resolve("text5.txt").getRoot().toFile(), "does-not-exist-dont-edit-testdir");
final TestConfigurationLoader loader = TestConfigurationLoader.builder().setFile(tempFile).build();
loader.load();
}

@Test
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "windows FS has transient permissions issues")
public void testSaveFollowsSymbolicLinks(final @TempDir Path tempDir) throws IOException {
void testSaveFollowsSymbolicLinks(final @TempDir Path tempDir) throws IOException {
final Path actualFile = tempDir.resolve(Paths.get("first", "second", "third.json"));
Files.createDirectories(actualFile.getParent());
final Path layerOne = tempDir.resolve("general.json");
Expand Down
Loading

0 comments on commit aacef64

Please sign in to comment.