Skip to content

Commit b240501

Browse files
Updated to JUnit 5
Also updated several Maven dependencies and added versions-maven-plugin. There's now a script to update dependencies.
1 parent 3d37253 commit b240501

File tree

80 files changed

+890
-742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+890
-742
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dungeon.wiki/
2121

2222
# Maven
2323
target/
24+
pom.xml.versionsBackup
2425

2526
# Dungeon
2627
saves/

pom.xml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
<plugin>
4747
<groupId>org.apache.maven.plugins</groupId>
4848
<artifactId>maven-compiler-plugin</artifactId>
49-
<version>3.2</version>
49+
<version>3.8.1</version>
5050
<configuration>
51-
<source>1.7</source>
52-
<target>1.7</target>
51+
<source>8</source>
52+
<target>8</target>
5353
</configuration>
5454
</plugin>
5555
<plugin>
@@ -133,6 +133,11 @@
133133
</execution>
134134
</executions>
135135
</plugin>
136+
<plugin>
137+
<groupId>org.apache.maven.plugins</groupId>
138+
<artifactId>maven-surefire-plugin</artifactId>
139+
<version>3.0.0-M5</version>
140+
</plugin>
136141
<plugin>
137142
<groupId>com.github.spotbugs</groupId>
138143
<artifactId>spotbugs-maven-plugin</artifactId>
@@ -167,6 +172,11 @@
167172
<check/>
168173
</configuration>
169174
</plugin>
175+
<plugin>
176+
<groupId>org.codehaus.mojo</groupId>
177+
<artifactId>versions-maven-plugin</artifactId>
178+
<version>2.8.1</version>
179+
</plugin>
170180
<plugin>
171181
<groupId>com.github.unknownnpc.plugins</groupId>
172182
<artifactId>json-compressor</artifactId>
@@ -191,17 +201,17 @@
191201
<dependency>
192202
<groupId>com.eclipsesource.minimal-json</groupId>
193203
<artifactId>minimal-json</artifactId>
194-
<version>0.9.4</version>
204+
<version>0.9.5</version>
195205
</dependency>
196206
<dependency>
197207
<groupId>joda-time</groupId>
198208
<artifactId>joda-time</artifactId>
199-
<version>2.8.1</version>
209+
<version>2.10.10</version>
200210
</dependency>
201211
<dependency>
202212
<groupId>org.apache.commons</groupId>
203213
<artifactId>commons-lang3</artifactId>
204-
<version>3.4</version>
214+
<version>3.12.0</version>
205215
</dependency>
206216
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
207217
<dependency>
@@ -212,27 +222,29 @@
212222
<dependency>
213223
<groupId>org.jetbrains</groupId>
214224
<artifactId>annotations</artifactId>
215-
<version>13.0</version>
225+
<version>20.1.0</version>
216226
</dependency>
227+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
217228
<dependency>
218-
<groupId>junit</groupId>
219-
<artifactId>junit</artifactId>
220-
<version>4.11</version>
229+
<groupId>org.junit.jupiter</groupId>
230+
<artifactId>junit-jupiter-api</artifactId>
231+
<version>5.8.0-M1</version>
221232
<scope>test</scope>
222233
</dependency>
223-
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
234+
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
224235
<dependency>
225236
<groupId>org.hamcrest</groupId>
226-
<artifactId>hamcrest-all</artifactId>
227-
<version>1.3</version>
237+
<artifactId>hamcrest</artifactId>
238+
<version>2.2</version>
239+
<scope>test</scope>
228240
</dependency>
241+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
229242
<dependency>
230243
<groupId>org.mockito</groupId>
231-
<artifactId>mockito-all</artifactId>
232-
<version>2.0.2-beta</version>
244+
<artifactId>mockito-core</artifactId>
245+
<version>3.10.0</version>
233246
<scope>test</scope>
234247
</dependency>
235-
236248
</dependencies>
237249

238250
</project>

scripts/update-dependencies.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
DIRECTORY="${BASH_SOURCE%/*}"
4+
if [[ ! -d "$DIRECTORY" ]]; then DIRECTORY="$PWD"; fi
5+
. "$DIRECTORY/include.sh"
6+
7+
mvn versions:use-latest-releases
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
package org.mafagafogigante.dungeon.achievements;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
45

56
import java.util.Collections;
67
import java.util.List;
78

89
public class AchievementStoreFactoryTest {
910

10-
@Test(expected = IllegalStateException.class)
11+
@Test
1112
public void testMakeAchievementStoreShouldReturnLockedStore() throws Exception {
1213
AchievementBuilder achievementBuilder = new AchievementBuilder();
1314
achievementBuilder.setId("ACHIEVEMENT");
1415
List<Achievement> emptyList = Collections.emptyList();
1516
AchievementStore achievementStore = AchievementStoreFactory.makeAchievementStore(emptyList);
16-
achievementStore.addAchievement(achievementBuilder.createAchievement());
17+
Assertions.assertThrows(IllegalStateException.class, () -> {
18+
achievementStore.addAchievement(achievementBuilder.createAchievement());
19+
});
1720
}
1821

19-
@Test(expected = IllegalStateException.class)
22+
@Test
2023
public void testDefaultStoreShouldBeLocked() throws Exception {
2124
AchievementBuilder achievementBuilder = new AchievementBuilder();
2225
achievementBuilder.setId("ACHIEVEMENT");
2326
AchievementStore defaultStore = AchievementStoreFactory.getDefaultStore();
24-
defaultStore.addAchievement(achievementBuilder.createAchievement());
27+
Assertions.assertThrows(IllegalStateException.class, () -> {
28+
defaultStore.addAchievement(achievementBuilder.createAchievement());
29+
});
2530
}
2631

2732
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package org.mafagafogigante.dungeon.achievements;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
45

56
public class AchievementStoreTest {
67

7-
@Test(expected = IllegalStateException.class)
8+
@Test
89
public void testAddAchievementShouldFailIfLocked() throws Exception {
910
// Not the right way to instantiate an AchievementStore outside the factory, used only for testing.
1011
AchievementBuilder achievementBuilder = new AchievementBuilder();
@@ -13,17 +14,21 @@ public void testAddAchievementShouldFailIfLocked() throws Exception {
1314
achievementStore.addAchievement(achievementBuilder.createAchievement());
1415
achievementStore.lock();
1516
achievementBuilder.setId("B");
16-
achievementStore.addAchievement(achievementBuilder.createAchievement());
17+
Assertions.assertThrows(IllegalStateException.class, () -> {
18+
achievementStore.addAchievement(achievementBuilder.createAchievement());
19+
});
1720
}
1821

19-
@Test(expected = IllegalArgumentException.class)
22+
@Test
2023
public void testAddAchievementShouldFailForRepeatedId() throws Exception {
2124
// Not the right way to instantiate an AchievementStore outside the factory, used only for testing.
2225
AchievementBuilder achievementBuilder = new AchievementBuilder();
2326
achievementBuilder.setId("A");
2427
AchievementStore achievementStore = new AchievementStore();
2528
achievementStore.addAchievement(achievementBuilder.createAchievement());
26-
achievementStore.addAchievement(achievementBuilder.createAchievement());
29+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
30+
achievementStore.addAchievement(achievementBuilder.createAchievement());
31+
});
2732
}
2833

2934
}

src/test/java/org/mafagafogigante/dungeon/achievements/AchievementTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import org.mafagafogigante.dungeon.util.CounterMap;
1212
import org.mafagafogigante.dungeon.util.Percentage;
1313

14-
import org.junit.Assert;
15-
import org.junit.Test;
14+
import org.junit.jupiter.api.Assertions;
15+
import org.junit.jupiter.api.Test;
1616

1717
public class AchievementTest {
1818

@@ -37,11 +37,11 @@ public void testBattleAchievementShouldBeFulfilled() throws Exception {
3737
CauseOfDeath unarmedCauseOfDeath = CauseOfDeath.getUnarmedCauseOfDeath();
3838

3939
Statistics statistics = new Statistics();
40-
Assert.assertFalse(achievement.isFulfilled(statistics));
40+
Assertions.assertFalse(achievement.isFulfilled(statistics));
4141
statistics.getBattleStatistics().addBattle(new Creature(cowPreset), unarmedCauseOfDeath, PartOfDay.DAWN);
42-
Assert.assertFalse(achievement.isFulfilled(statistics));
42+
Assertions.assertFalse(achievement.isFulfilled(statistics));
4343
statistics.getBattleStatistics().addBattle(new Creature(cowPreset), unarmedCauseOfDeath, PartOfDay.DAWN);
44-
Assert.assertTrue(achievement.isFulfilled(statistics));
44+
Assertions.assertTrue(achievement.isFulfilled(statistics));
4545
}
4646

4747
@Test
@@ -55,14 +55,14 @@ public void testVisitedLocationsBasedAchievementsShouldWorkAsExpected() throws E
5555
Achievement achievement = achievementBuilder.createAchievement();
5656

5757
Statistics statistics = new Statistics();
58-
Assert.assertFalse(achievement.isFulfilled(statistics));
58+
Assertions.assertFalse(achievement.isFulfilled(statistics));
5959
Date startOfDawn = new Date(PartOfDay.DAWN.getStartingHour());
6060
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
61-
Assert.assertFalse(achievement.isFulfilled(statistics));
61+
Assertions.assertFalse(achievement.isFulfilled(statistics));
6262
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
63-
Assert.assertFalse(achievement.isFulfilled(statistics));
63+
Assertions.assertFalse(achievement.isFulfilled(statistics));
6464
statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"), startOfDawn);
65-
Assert.assertTrue(achievement.isFulfilled(statistics));
65+
Assertions.assertTrue(achievement.isFulfilled(statistics));
6666
}
6767

6868
@Test
@@ -76,14 +76,14 @@ public void testMaximumVisitsAchievementsShouldWorkAsExpected() throws Exception
7676
Achievement achievement = achievementBuilder.createAchievement();
7777

7878
Statistics statistics = new Statistics();
79-
Assert.assertFalse(achievement.isFulfilled(statistics));
79+
Assertions.assertFalse(achievement.isFulfilled(statistics));
8080
Date startOfDawn = new Date(PartOfDay.DAWN.getStartingHour());
8181
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
82-
Assert.assertFalse(achievement.isFulfilled(statistics));
82+
Assertions.assertFalse(achievement.isFulfilled(statistics));
8383
statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"), startOfDawn);
84-
Assert.assertFalse(achievement.isFulfilled(statistics));
84+
Assertions.assertFalse(achievement.isFulfilled(statistics));
8585
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
86-
Assert.assertTrue(achievement.isFulfilled(statistics));
86+
Assertions.assertTrue(achievement.isFulfilled(statistics));
8787
}
8888

8989
}

src/test/java/org/mafagafogigante/dungeon/achievements/AchievementTrackerTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.mafagafogigante.dungeon.stats.Statistics;
1010
import org.mafagafogigante.dungeon.util.CounterMap;
1111

12-
import org.junit.Assert;
13-
import org.junit.Test;
12+
import org.junit.jupiter.api.Assertions;
13+
import org.junit.jupiter.api.Test;
1414

1515
import java.util.Collections;
1616
import java.util.Comparator;
@@ -21,7 +21,7 @@ public class AchievementTrackerTest {
2121
@Test
2222
public void testGetUnlockedCountShouldReturnZeroInNewAchievementTracker() throws Exception {
2323
AchievementTracker achievementTracker = new AchievementTracker(new Statistics());
24-
Assert.assertEquals(0, achievementTracker.getUnlockedCount());
24+
Assertions.assertEquals(0, achievementTracker.getUnlockedCount());
2525
}
2626

2727
@Test
@@ -31,9 +31,9 @@ public void testGetUnlockedCountShouldBeUpdatedAsExpected() throws Exception {
3131
List<Achievement> achievements = Collections.singletonList(achievementBuilder.createAchievement());
3232
AchievementStore achievementStore = AchievementStoreFactory.makeAchievementStore(achievements);
3333
AchievementTracker achievementTracker = new AchievementTracker(new Statistics());
34-
Assert.assertEquals(0, achievementTracker.getUnlockedCount());
34+
Assertions.assertEquals(0, achievementTracker.getUnlockedCount());
3535
achievementTracker.update(achievementStore, new Date(1, 1, 1));
36-
Assert.assertEquals(1, achievementTracker.getUnlockedCount());
36+
Assertions.assertEquals(1, achievementTracker.getUnlockedCount());
3737
}
3838

3939
@Test
@@ -54,9 +54,9 @@ public void testGetUnlockedAchievementsReturnsTheExpectedUnlockedAchievements()
5454
Comparator<UnlockedAchievement> defaultComparator = UnlockedAchievementComparators.getDefaultComparator();
5555
List<UnlockedAchievement> unlocked = tracker.getUnlockedAchievements(defaultComparator);
5656
for (UnlockedAchievement unlockedAchievement : unlocked) {
57-
Assert.assertEquals(name, unlockedAchievement.getName());
58-
Assert.assertEquals(info, unlockedAchievement.getInfo());
59-
Assert.assertEquals(date, unlockedAchievement.getDate());
57+
Assertions.assertEquals(name, unlockedAchievement.getName());
58+
Assertions.assertEquals(info, unlockedAchievement.getInfo());
59+
Assertions.assertEquals(date, unlockedAchievement.getDate());
6060
}
6161
}
6262

@@ -81,15 +81,15 @@ public void testHasNotBeenUnlocked() throws Exception {
8181
final Date date = new Date(1, 1, 1);
8282
tracker.update(achievementStore, date);
8383

84-
Assert.assertTrue(tracker.hasNotBeenUnlocked(achievement));
84+
Assertions.assertTrue(tracker.hasNotBeenUnlocked(achievement));
8585

8686
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("PLACE"),
87-
new Date(PartOfDay.DAWN.getStartingHour()));
87+
new Date(PartOfDay.DAWN.getStartingHour()));
8888

89-
Assert.assertTrue(tracker.hasNotBeenUnlocked(achievement));
89+
Assertions.assertTrue(tracker.hasNotBeenUnlocked(achievement));
9090

9191
tracker.update(achievementStore, date.plus(1, DungeonTimeUnit.SECOND));
92-
Assert.assertFalse(tracker.hasNotBeenUnlocked(achievement));
92+
Assertions.assertFalse(tracker.hasNotBeenUnlocked(achievement));
9393
}
9494

9595
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.mafagafogigante.dungeon.commands;
22

33
import org.jetbrains.annotations.NotNull;
4-
import org.junit.Assert;
5-
import org.junit.Test;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.api.Test;
66

77
public class CommandSetTest {
88

@@ -15,19 +15,19 @@ public void execute(@NotNull String[] arguments) {
1515
}
1616
};
1717
commandSet.addCommand(command);
18-
Assert.assertEquals(command, commandSet.getCommand("go"));
18+
Assertions.assertEquals(command, commandSet.getCommand("go"));
1919
}
2020

2121
@Test
2222
public void shouldGetNullWhenRetrievingANonexistentCommand() throws Exception {
2323
CommandSet commandSet = CommandSet.emptyCommandSet();
24-
Assert.assertNull(commandSet.getCommand("go"));
24+
Assertions.assertNull(commandSet.getCommand("go"));
2525
}
2626

2727
@Test
2828
public void shouldNotGetNullWhenRetrievingTheCommandsCommand() throws Exception {
2929
CommandSet commandSet = CommandSet.emptyCommandSet();
30-
Assert.assertNotNull(commandSet.getCommand("commands"));
30+
Assertions.assertNotNull(commandSet.getCommand("commands"));
3131
}
3232

3333
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package org.mafagafogigante.dungeon.commands;
22

33
import org.apache.commons.lang3.StringUtils;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.api.Test;
56

67
public class IssuedCommandTest {
78

8-
@Test(expected = IllegalArgumentException.class)
9+
@Test
910
public void constructorShouldThrowExceptionOnInputTooBig() throws Exception {
10-
new IssuedCommand(StringUtils.repeat('A', 65536));
11+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
12+
new IssuedCommand(StringUtils.repeat('A', 65536));
13+
});
1114
}
1215

13-
@Test(expected = IllegalArgumentException.class)
16+
@Test
1417
public void constructorShouldThrowExceptionOnInputWithoutTokens() throws Exception {
15-
new IssuedCommand(StringUtils.repeat(' ', 128));
18+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
19+
new IssuedCommand(StringUtils.repeat(' ', 128));
20+
});
1621
}
1722

1823
}

0 commit comments

Comments
 (0)