mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-28 17:38:01 +01:00
tests: Move to JUnit 5 (#3357)
This commit is contained in:
parent
f086826942
commit
858b6b5471
@ -30,14 +30,12 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class ClickStripTransformTest {
|
||||
|
||||
@ -53,7 +51,7 @@ class ClickStripTransformTest {
|
||||
)
|
||||
);
|
||||
var transformedComponent = transform.transform(component);
|
||||
assertNull(transformedComponent.clickEvent());
|
||||
Assertions.assertNull(transformedComponent.clickEvent());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -68,7 +66,7 @@ class ClickStripTransformTest {
|
||||
var component = Component.text("Hello")
|
||||
.clickEvent(originalClickEvent);
|
||||
var transformedComponent = transform.transform(component);
|
||||
assertEquals(originalClickEvent, transformedComponent.clickEvent());
|
||||
Assertions.assertEquals(originalClickEvent, transformedComponent.clickEvent());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -88,9 +86,9 @@ class ClickStripTransformTest {
|
||||
inner.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, "https://example.org"))
|
||||
);
|
||||
var transformedComponent = transform.transform(component);
|
||||
assertFalse(transformedComponent.children().isEmpty()); // child still exists
|
||||
assertEquals(inner, transformedComponent.children().get(0)); // only the click event has changed
|
||||
assertNull(transformedComponent.children().get(0).clickEvent());
|
||||
Assertions.assertFalse(transformedComponent.children().isEmpty()); // child still exists
|
||||
Assertions.assertEquals(inner, transformedComponent.children().get(0)); // only the click event has changed
|
||||
Assertions.assertNull(transformedComponent.children().get(0).clickEvent());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,10 +32,9 @@ import com.plotsquared.core.plot.flag.implementations.UseFlag;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FlagTest {
|
||||
|
||||
@ -43,7 +42,7 @@ public class FlagTest {
|
||||
|
||||
private ItemType testBlock;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
//EventUtil.manager = new EventUtilTest();
|
||||
DBFunc.dbManager = new AbstractDBTest();
|
||||
@ -72,7 +71,7 @@ public class FlagTest {
|
||||
@Test
|
||||
public void testFlagName() {
|
||||
String flagName = PlotFlag.getFlagName(UseFlag.class);
|
||||
assertEquals("use", flagName);
|
||||
Assertions.assertEquals("use", flagName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,19 +25,13 @@
|
||||
*/
|
||||
package com.plotsquared.core.plot;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PlotRangeIteratorTest {
|
||||
|
||||
@Test
|
||||
@ -45,10 +39,10 @@ public class PlotRangeIteratorTest {
|
||||
// an iterator that should only contain the given plot
|
||||
PlotId id = PlotId.of(3, 7);
|
||||
PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id, id);
|
||||
assertTrue(range.hasNext());
|
||||
assertEquals(id, range.next());
|
||||
assertFalse(range.hasNext());
|
||||
assertThrows(NoSuchElementException.class, range::next);
|
||||
Assertions.assertTrue(range.hasNext());
|
||||
Assertions.assertEquals(id, range.next());
|
||||
Assertions.assertFalse(range.hasNext());
|
||||
Assertions.assertThrows(NoSuchElementException.class, range::next);
|
||||
}
|
||||
|
||||
// the tests below assume a specific order (first increasing y, then increasing x)
|
||||
@ -63,11 +57,11 @@ public class PlotRangeIteratorTest {
|
||||
List<PlotId> all = Arrays.asList(id00, id01, id10, id11);
|
||||
PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id00, id11);
|
||||
for (PlotId id : all) {
|
||||
assertTrue(range.hasNext());
|
||||
assertEquals(id, range.next());
|
||||
Assertions.assertTrue(range.hasNext());
|
||||
Assertions.assertEquals(id, range.next());
|
||||
}
|
||||
assertFalse(range.hasNext());
|
||||
assertThrows(NoSuchElementException.class, range::next);
|
||||
Assertions.assertFalse(range.hasNext());
|
||||
Assertions.assertThrows(NoSuchElementException.class, range::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -82,11 +76,11 @@ public class PlotRangeIteratorTest {
|
||||
List<PlotId> all = Arrays.asList(id00, id01, id02, id10, id11, id12);
|
||||
PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id00, id12);
|
||||
for (PlotId id : all) {
|
||||
assertTrue(range.hasNext());
|
||||
assertEquals(id, range.next());
|
||||
Assertions.assertTrue(range.hasNext());
|
||||
Assertions.assertEquals(id, range.next());
|
||||
}
|
||||
assertFalse(range.hasNext());
|
||||
assertThrows(NoSuchElementException.class, range::next);
|
||||
Assertions.assertFalse(range.hasNext());
|
||||
Assertions.assertThrows(NoSuchElementException.class, range::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -101,11 +95,11 @@ public class PlotRangeIteratorTest {
|
||||
List<PlotId> all = Arrays.asList(id00, id01, id10, id11, id20, id21);
|
||||
PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id00, id21);
|
||||
for (PlotId id : all) {
|
||||
assertTrue(range.hasNext());
|
||||
assertEquals(id, range.next());
|
||||
Assertions.assertTrue(range.hasNext());
|
||||
Assertions.assertEquals(id, range.next());
|
||||
}
|
||||
assertFalse(range.hasNext());
|
||||
assertThrows(NoSuchElementException.class, range::next);
|
||||
Assertions.assertFalse(range.hasNext());
|
||||
Assertions.assertThrows(NoSuchElementException.class, range::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -115,9 +109,9 @@ public class PlotRangeIteratorTest {
|
||||
PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id00, id01);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
assertNotEquals(0, range.next().getY());
|
||||
Assertions.assertNotEquals(0, range.next().getY());
|
||||
}
|
||||
assertFalse(range.hasNext());
|
||||
assertThrows(NoSuchElementException.class, range::next);
|
||||
Assertions.assertFalse(range.hasNext());
|
||||
Assertions.assertThrows(NoSuchElementException.class, range::next);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ package com.plotsquared.core.plot;
|
||||
import com.plotsquared.core.PlotVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PlotVersionTest {
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.synchronization;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -32,9 +33,6 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class LockRepositoryTest {
|
||||
|
||||
private LockKey key;
|
||||
@ -55,11 +53,9 @@ class LockRepositoryTest {
|
||||
throw new IllegalStateException("Expected a ReentrantLock");
|
||||
}
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> {
|
||||
this.lockRepository.useLock(this.key, () -> {
|
||||
throw new IllegalStateException();
|
||||
});
|
||||
});
|
||||
assertFalse(lock.isLocked());
|
||||
Assertions.assertThrows(IllegalStateException.class, () -> this.lockRepository.useLock(this.key, () -> {
|
||||
throw new IllegalStateException();
|
||||
}));
|
||||
Assertions.assertFalse(lock.isLocked());
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,6 @@ val javadocDir = rootDir.resolve("docs").resolve("javadoc").resolve(project.name
|
||||
allprojects {
|
||||
dependencies {
|
||||
// Tests
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user