Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to JUnit 5.7.1 #429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dungeon.wiki/

# Maven
target/
pom.xml.versionsBackup

# Dungeon
saves/
Expand Down
44 changes: 28 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -133,6 +133,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down Expand Up @@ -167,6 +172,11 @@
<check/>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>com.github.unknownnpc.plugins</groupId>
<artifactId>json-compressor</artifactId>
Expand All @@ -191,17 +201,17 @@
<dependency>
<groupId>com.eclipsesource.minimal-json</groupId>
<artifactId>minimal-json</artifactId>
<version>0.9.4</version>
<version>0.9.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.1</version>
<version>2.10.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<version>3.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
Expand All @@ -212,27 +222,29 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
<version>20.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.0-M1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
<artifactId>mockito-core</artifactId>
<version>3.10.0</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
20 changes: 20 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Checking a downloaded build

```bash
bash check-hash-sum.sh [FILENAME]
```

> Note that the name of the file should end with .sha256!

# Creating the hash sum of a file

```bash
bash create-hash-sum.sh [FILENAME]
```

# Updating dependencies

```bash
# From the project root
bash scripts/update-dependencies.sh
```
5 changes: 0 additions & 5 deletions scripts/readme.txt

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/update-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

DIRECTORY="${BASH_SOURCE%/*}"
if [[ ! -d "$DIRECTORY" ]]; then DIRECTORY="$PWD"; fi
. "$DIRECTORY/include.sh"

mvn versions:use-latest-releases
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
package org.mafagafogigante.dungeon.achievements;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

public class AchievementStoreFactoryTest {

@Test(expected = IllegalStateException.class)
@Test
public void testMakeAchievementStoreShouldReturnLockedStore() throws Exception {
AchievementBuilder achievementBuilder = new AchievementBuilder();
achievementBuilder.setId("ACHIEVEMENT");
List<Achievement> emptyList = Collections.emptyList();
AchievementStore achievementStore = AchievementStoreFactory.makeAchievementStore(emptyList);
achievementStore.addAchievement(achievementBuilder.createAchievement());
Assertions.assertThrows(IllegalStateException.class, () -> {
achievementStore.addAchievement(achievementBuilder.createAchievement());
});
}

@Test(expected = IllegalStateException.class)
@Test
public void testDefaultStoreShouldBeLocked() throws Exception {
AchievementBuilder achievementBuilder = new AchievementBuilder();
achievementBuilder.setId("ACHIEVEMENT");
AchievementStore defaultStore = AchievementStoreFactory.getDefaultStore();
defaultStore.addAchievement(achievementBuilder.createAchievement());
Assertions.assertThrows(IllegalStateException.class, () -> {
defaultStore.addAchievement(achievementBuilder.createAchievement());
});
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.mafagafogigante.dungeon.achievements;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AchievementStoreTest {

@Test(expected = IllegalStateException.class)
@Test
public void testAddAchievementShouldFailIfLocked() throws Exception {
// Not the right way to instantiate an AchievementStore outside the factory, used only for testing.
AchievementBuilder achievementBuilder = new AchievementBuilder();
Expand All @@ -13,17 +14,21 @@ public void testAddAchievementShouldFailIfLocked() throws Exception {
achievementStore.addAchievement(achievementBuilder.createAchievement());
achievementStore.lock();
achievementBuilder.setId("B");
achievementStore.addAchievement(achievementBuilder.createAchievement());
Assertions.assertThrows(IllegalStateException.class, () -> {
achievementStore.addAchievement(achievementBuilder.createAchievement());
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testAddAchievementShouldFailForRepeatedId() throws Exception {
// Not the right way to instantiate an AchievementStore outside the factory, used only for testing.
AchievementBuilder achievementBuilder = new AchievementBuilder();
achievementBuilder.setId("A");
AchievementStore achievementStore = new AchievementStore();
achievementStore.addAchievement(achievementBuilder.createAchievement());
achievementStore.addAchievement(achievementBuilder.createAchievement());
Assertions.assertThrows(IllegalArgumentException.class, () -> {
achievementStore.addAchievement(achievementBuilder.createAchievement());
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.mafagafogigante.dungeon.util.CounterMap;
import org.mafagafogigante.dungeon.util.Percentage;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AchievementTest {

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

Statistics statistics = new Statistics();
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getBattleStatistics().addBattle(new Creature(cowPreset), unarmedCauseOfDeath, PartOfDay.DAWN);
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getBattleStatistics().addBattle(new Creature(cowPreset), unarmedCauseOfDeath, PartOfDay.DAWN);
Assert.assertTrue(achievement.isFulfilled(statistics));
Assertions.assertTrue(achievement.isFulfilled(statistics));
}

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

Statistics statistics = new Statistics();
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
Date startOfDawn = new Date(PartOfDay.DAWN.getStartingHour());
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"), startOfDawn);
Assert.assertTrue(achievement.isFulfilled(statistics));
Assertions.assertTrue(achievement.isFulfilled(statistics));
}

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

Statistics statistics = new Statistics();
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
Date startOfDawn = new Date(PartOfDay.DAWN.getStartingHour());
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"), startOfDawn);
Assert.assertFalse(achievement.isFulfilled(statistics));
Assertions.assertFalse(achievement.isFulfilled(statistics));
statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"), startOfDawn);
Assert.assertTrue(achievement.isFulfilled(statistics));
Assertions.assertTrue(achievement.isFulfilled(statistics));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.mafagafogigante.dungeon.stats.Statistics;
import org.mafagafogigante.dungeon.util.CounterMap;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.Comparator;
Expand All @@ -21,7 +21,7 @@ public class AchievementTrackerTest {
@Test
public void testGetUnlockedCountShouldReturnZeroInNewAchievementTracker() throws Exception {
AchievementTracker achievementTracker = new AchievementTracker(new Statistics());
Assert.assertEquals(0, achievementTracker.getUnlockedCount());
Assertions.assertEquals(0, achievementTracker.getUnlockedCount());
}

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

@Test
Expand All @@ -54,9 +54,9 @@ public void testGetUnlockedAchievementsReturnsTheExpectedUnlockedAchievements()
Comparator<UnlockedAchievement> defaultComparator = UnlockedAchievementComparators.getDefaultComparator();
List<UnlockedAchievement> unlocked = tracker.getUnlockedAchievements(defaultComparator);
for (UnlockedAchievement unlockedAchievement : unlocked) {
Assert.assertEquals(name, unlockedAchievement.getName());
Assert.assertEquals(info, unlockedAchievement.getInfo());
Assert.assertEquals(date, unlockedAchievement.getDate());
Assertions.assertEquals(name, unlockedAchievement.getName());
Assertions.assertEquals(info, unlockedAchievement.getInfo());
Assertions.assertEquals(date, unlockedAchievement.getDate());
}
}

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

Assert.assertTrue(tracker.hasNotBeenUnlocked(achievement));
Assertions.assertTrue(tracker.hasNotBeenUnlocked(achievement));

statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("PLACE"),
new Date(PartOfDay.DAWN.getStartingHour()));
new Date(PartOfDay.DAWN.getStartingHour()));

Assert.assertTrue(tracker.hasNotBeenUnlocked(achievement));
Assertions.assertTrue(tracker.hasNotBeenUnlocked(achievement));

tracker.update(achievementStore, date.plus(1, DungeonTimeUnit.SECOND));
Assert.assertFalse(tracker.hasNotBeenUnlocked(achievement));
Assertions.assertFalse(tracker.hasNotBeenUnlocked(achievement));
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.mafagafogigante.dungeon.commands;

import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class CommandSetTest {

Expand All @@ -15,19 +15,19 @@ public void execute(@NotNull String[] arguments) {
}
};
commandSet.addCommand(command);
Assert.assertEquals(command, commandSet.getCommand("go"));
Assertions.assertEquals(command, commandSet.getCommand("go"));
}

@Test
public void shouldGetNullWhenRetrievingANonexistentCommand() throws Exception {
CommandSet commandSet = CommandSet.emptyCommandSet();
Assert.assertNull(commandSet.getCommand("go"));
Assertions.assertNull(commandSet.getCommand("go"));
}

@Test
public void shouldNotGetNullWhenRetrievingTheCommandsCommand() throws Exception {
CommandSet commandSet = CommandSet.emptyCommandSet();
Assert.assertNotNull(commandSet.getCommand("commands"));
Assertions.assertNotNull(commandSet.getCommand("commands"));
}

}
Loading