mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
2.1.231
This commit is contained in:
parent
4d060b192b
commit
7da8c8c83a
@ -1,3 +1,8 @@
|
|||||||
|
Version 2.1.231
|
||||||
|
Fixed a bug preventing parties from being made without passwords (Thanks Momshroom)
|
||||||
|
Updated korean locale (thanks mangchi57)
|
||||||
|
Added some unit tests for party creation
|
||||||
|
|
||||||
Version 2.1.230
|
Version 2.1.230
|
||||||
Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
||||||
Fixed several exceptions when checking PVP damage when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
Fixed several exceptions when checking PVP damage when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
||||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.230</version>
|
<version>2.1.231</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<scm>
|
<scm>
|
||||||
|
98
src/test/java/com/gmail/nossr50/party/PartyManagerTest.java
Normal file
98
src/test/java/com/gmail/nossr50/party/PartyManagerTest.java
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
package com.gmail.nossr50.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
class PartyManagerTest {
|
||||||
|
|
||||||
|
static mcMMO mockMcMMO;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void setup() {
|
||||||
|
// create a static stub for LocaleLoader.class
|
||||||
|
mockStatic(LocaleLoader.class);
|
||||||
|
when(LocaleLoader.getString(anyString())).thenReturn("");
|
||||||
|
|
||||||
|
mockMcMMO = mock(mcMMO.class);
|
||||||
|
final Server mockServer = mock(Server.class);
|
||||||
|
when(mockMcMMO.getServer()).thenReturn(mockServer);
|
||||||
|
when(mockServer.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||||
|
|
||||||
|
// TODO: Add cleanup for static mock
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createPartyWithoutPasswordShouldSucceed() {
|
||||||
|
// Given
|
||||||
|
PartyManager partyManager = new PartyManager(mockMcMMO);
|
||||||
|
String partyName = "TestParty";
|
||||||
|
|
||||||
|
// TODO: Update this with utils from the other dev branches in the future
|
||||||
|
Player player = mock(Player.class);
|
||||||
|
McMMOPlayer mmoPlayer = mock(McMMOPlayer.class);
|
||||||
|
when(mmoPlayer.getPlayer()).thenReturn(player);
|
||||||
|
when(player.getUniqueId()).thenReturn(new UUID(0, 0));
|
||||||
|
|
||||||
|
// When & Then
|
||||||
|
partyManager.createParty(mmoPlayer, partyName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createPartyWithPasswordShouldSucceed() {
|
||||||
|
// Given
|
||||||
|
PartyManager partyManager = new PartyManager(mockMcMMO);
|
||||||
|
String partyName = "TestParty";
|
||||||
|
String partyPassword = "somePassword";
|
||||||
|
|
||||||
|
// TODO: Update this with utils from the other dev branches in the future
|
||||||
|
Player player = mock(Player.class);
|
||||||
|
McMMOPlayer mmoPlayer = mock(McMMOPlayer.class);
|
||||||
|
when(mmoPlayer.getPlayer()).thenReturn(player);
|
||||||
|
when(player.getUniqueId()).thenReturn(new UUID(0, 0));
|
||||||
|
|
||||||
|
// When & Then
|
||||||
|
partyManager.createParty(mmoPlayer, partyName, partyPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createPartyWithoutNameShouldFail() {
|
||||||
|
// Given
|
||||||
|
PartyManager partyManager = new PartyManager(mockMcMMO);
|
||||||
|
String partyPassword = "somePassword";
|
||||||
|
|
||||||
|
// TODO: Update this with utils from the other dev branches in the future
|
||||||
|
Player player = mock(Player.class);
|
||||||
|
McMMOPlayer mmoPlayer = mock(McMMOPlayer.class);
|
||||||
|
when(mmoPlayer.getPlayer()).thenReturn(player);
|
||||||
|
when(player.getUniqueId()).thenReturn(new UUID(0, 0));
|
||||||
|
|
||||||
|
// When & Then
|
||||||
|
assertThrows(NullPointerException.class,
|
||||||
|
() -> partyManager.createParty(mmoPlayer, null, partyPassword));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createPartyWithoutPlayerShouldFail() {
|
||||||
|
// Given
|
||||||
|
PartyManager partyManager = new PartyManager(mockMcMMO);
|
||||||
|
String partyName = "TestParty";
|
||||||
|
String partyPassword = "somePassword";
|
||||||
|
|
||||||
|
// When & Then
|
||||||
|
assertThrows(NullPointerException.class,
|
||||||
|
() -> partyManager.createParty(null, partyName, partyPassword));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user