diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 924f474baf6537a249a0eae27db589282d4e3cb9..de6fcf51b8d0f00d573f918a0b9de76463210368 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -8,8 +8,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=14 -org.eclipse.jdt.core.compiler.compliance=14 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 +org.eclipse.jdt.core.compiler.compliance=16 org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning @@ -106,7 +106,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=14 +org.eclipse.jdt.core.compiler.source=16 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/pom.xml b/pom.xml index 06b685b572dab0fb50a4bc9981717f796f3b0f8a..fae53742948b91bd58298c2155d24a85a679990b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,22 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.l2jserver</groupId> <artifactId>l2j-server-datapack</artifactId> <version>2.6.3.0-SNAPSHOT</version> <name>L2J DataPack</name> <properties> - <maven.compiler.source>14</maven.compiler.source> - <maven.compiler.target>14</maven.compiler.target> + <maven.compiler.source>16</maven.compiler.source> + <maven.compiler.target>16</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <slf4j.version>1.7.30</slf4j.version> + <slf4j.version>1.7.31</slf4j.version> <!-- L2J --> - <l2j-server-game.version>2.6.3.0-SNAPSHOT</l2j-server-game.version> + <l2j-server-game.version>2.6.3.0-SNAPSHOT</l2j-server-game.version> <!-- Test --> - <testng.version>7.3.0</testng.version> - <easymock.version>4.2</easymock.version> - <powermock.version>2.0.7</powermock.version> + <junit-jupiter.version>5.7.2</junit-jupiter.version> + <mockito.version>3.11.2</mockito.version> <!-- Plugins --> + <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version> <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> </properties> @@ -34,38 +33,43 @@ </dependency> <!-- Test --> <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <version>${testng.version}</version> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>${easymock.version}</version> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-core</artifactId> - <version>${powermock.version}</version> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>${mockito.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-easymock</artifactId> - <version>${powermock.version}</version> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <version>${mockito.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-testng</artifactId> - <version>${powermock.version}</version> + <groupId>org.mockito</groupId> + <artifactId>mockito-inline</artifactId> + <version>${mockito.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> diff --git a/src/test/java/com/l2jserver/datapack/handlers/admincommandhandlers/AdminReloadTest.java b/src/test/java/com/l2jserver/datapack/handlers/admincommandhandlers/AdminReloadTest.java index 8f77eb8461c7ae55ec5187e73bdc847aee35564d..69d8848f28c923d0f6d5104f1ddc62c6f45e11e1 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/admincommandhandlers/AdminReloadTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/admincommandhandlers/AdminReloadTest.java @@ -19,39 +19,35 @@ package com.l2jserver.datapack.handlers.admincommandhandlers; import static com.l2jserver.gameserver.config.Configuration.general; -import static org.easymock.EasyMock.anyString; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.powermock.api.easymock.PowerMock.replay; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.when; -import org.powermock.api.easymock.annotation.Mock; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; /** * Admin Reload test. * @author Zoey76 - * @version 2.6.1.0 + * @version 2.6.3.0 */ -public class AdminReloadTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class AdminReloadTest { @Mock private L2PcInstance player; - private final AdminReload adminReload = new AdminReload(); + private static final AdminReload ADMIN_RELOAD = new AdminReload(); @Test public void useAdminCommandTest() { general().setProperty("ServerListBrackets", "True"); - expect(player.getName()).andReturn("Zoey76"); - player.sendMessage(anyString()); - expectLastCall(); - replay(player); + when(player.getName()).thenReturn("Zoey76"); - adminReload.useAdminCommand("admin_reload config general", player); + ADMIN_RELOAD.useAdminCommand("admin_reload config general", player); assertFalse(general().getServerListBrackets()); } } diff --git a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantBetrayTest.java b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantBetrayTest.java index 724d591bdd516bcb9cff395f16e529a7db86696d..d83c76d0e954abf16c9712fe3059ad8bf5d4c726 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantBetrayTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantBetrayTest.java @@ -18,21 +18,17 @@ */ package com.l2jserver.datapack.handlers.effecthandlers.instant; -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK; -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replayAll; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; import java.util.Map; -import org.powermock.api.easymock.annotation.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.ai.L2CharacterAI; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.actor.L2Attackable; @@ -45,13 +41,10 @@ import com.l2jserver.gameserver.model.stats.Formulas; /** * Betray instant effect test. * @author Zoey76 - * @version 2.6.2.0 + * @version 2.6.3.0 */ -@PrepareForTest({ - BuffInfo.class, - Formulas.class -}) -public class InstantBetrayTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class InstantBetrayTest { @Mock private BuffInfo buffInfo; @@ -70,10 +63,11 @@ public class InstantBetrayTest extends AbstractTest { @Mock private L2CharacterAI creatureAI; - private InstantBetray effect; + private static InstantBetray effect; - @BeforeSuite - void init() { + @BeforeAll + static void init() { + mockStatic(Formulas.class); final var set = new StatsSet(Map.of("name", "InstantBetray")); final var params = new StatsSet(Map.of("chance", "80", "time", "30")); effect = new InstantBetray(null, null, set, params); @@ -86,100 +80,77 @@ public class InstantBetrayTest extends AbstractTest { @Test public void test_effected_is_raid() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.isRaid()).andReturn(true); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.isRaid()).thenReturn(true); effect.onStart(buffInfo); } @Test public void test_effected_not_servitor_summon_raid_minion() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.isRaid()).andReturn(false); - expect(effected.isServitor()).andReturn(false); - expect(effected.isSummon()).andReturn(false); - expect(effected.isRaidMinion()).andReturn(false); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.isRaid()).thenReturn(false); + when(effected.isServitor()).thenReturn(false); + when(effected.isSummon()).thenReturn(false); + when(effected.isRaidMinion()).thenReturn(false); effect.onStart(buffInfo); } @Test public void test_effected_is_servitor_probability_fail() { - mockStatic(Formulas.class); - expect(buffInfo.getEffected()).andReturn(effected); - expect(buffInfo.getEffector()).andReturn(effector); - expect(buffInfo.getSkill()).andReturn(skill); - expect(effected.isRaid()).andReturn(false); - expect(effected.isServitor()).andReturn(true); - expect(effected.getActingPlayer()).andReturn(masterPlayer); - expect(Formulas.calcProbability(80, effector, effected, skill)).andReturn(false); - expect(effected.getAI()).andReturn(creatureAI); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(buffInfo.getEffector()).thenReturn(effector); + when(buffInfo.getSkill()).thenReturn(skill); + when(effected.isRaid()).thenReturn(false); + when(effected.isServitor()).thenReturn(true); + when(effected.getActingPlayer()).thenReturn(masterPlayer); + when(Formulas.calcProbability(80, effector, effected, skill)).thenReturn(false); effect.onStart(buffInfo); } @Test public void test_effected_is_servitor() { - mockStatic(Formulas.class); - expect(buffInfo.getEffected()).andReturn(effected); - expect(buffInfo.getEffector()).andReturn(effector); - expect(buffInfo.getSkill()).andReturn(skill); - expect(effected.isRaid()).andReturn(false); - expect(effected.isServitor()).andReturn(true); - expect(effected.getActingPlayer()).andReturn(masterPlayer); - expect(Formulas.calcProbability(80, effector, effected, skill)).andReturn(true); - expect(effected.getAI()).andReturn(creatureAI); - creatureAI.setIntention(AI_INTENTION_ATTACK, masterPlayer); - expectLastCall(); - creatureAI.setIntention(AI_INTENTION_IDLE, masterPlayer); - expectLastCall(); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(buffInfo.getEffector()).thenReturn(effector); + when(buffInfo.getSkill()).thenReturn(skill); + when(effected.isRaid()).thenReturn(false); + when(effected.isServitor()).thenReturn(true); + when(effected.getActingPlayer()).thenReturn(masterPlayer); + when(Formulas.calcProbability(80, effector, effected, skill)).thenReturn(true); + when(effected.getAI()).thenReturn(creatureAI); effect.onStart(buffInfo); } @Test public void test_effected_is_summon() { - mockStatic(Formulas.class); - expect(buffInfo.getEffected()).andReturn(effected); - expect(buffInfo.getEffector()).andReturn(effector); - expect(buffInfo.getSkill()).andReturn(skill); - expect(effected.isRaid()).andReturn(false); - expect(effected.isServitor()).andReturn(false); - expect(effected.isSummon()).andReturn(true); - expect(effected.getActingPlayer()).andReturn(masterPlayer); - expect(Formulas.calcProbability(80, effector, effected, skill)).andReturn(true); - expect(effected.getAI()).andReturn(creatureAI); - creatureAI.setIntention(AI_INTENTION_ATTACK, masterPlayer); - expectLastCall(); - creatureAI.setIntention(AI_INTENTION_IDLE, masterPlayer); - expectLastCall(); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(buffInfo.getEffector()).thenReturn(effector); + when(buffInfo.getSkill()).thenReturn(skill); + when(effected.isRaid()).thenReturn(false); + when(effected.isServitor()).thenReturn(false); + when(effected.isSummon()).thenReturn(true); + when(effected.getActingPlayer()).thenReturn(masterPlayer); + when(Formulas.calcProbability(80, effector, effected, skill)).thenReturn(true); + when(effected.getAI()).thenReturn(creatureAI); effect.onStart(buffInfo); } @Test public void test_effected_is_raid_minion() { - mockStatic(Formulas.class); - expect(buffInfo.getEffected()).andReturn(effectedMinion); - expect(buffInfo.getEffector()).andReturn(effector); - expect(buffInfo.getSkill()).andReturn(skill); - expect(effectedMinion.isRaid()).andReturn(false); - expect(effectedMinion.isServitor()).andReturn(false); - expect(effectedMinion.isSummon()).andReturn(false); - expect(effectedMinion.isRaidMinion()).andReturn(true); - expect(effectedMinion.getLeader()).andReturn(effectedLeader); - expect(Formulas.calcProbability(80, effector, effectedMinion, skill)).andReturn(true); - expect(effectedMinion.getAI()).andReturn(creatureAI); - creatureAI.setIntention(AI_INTENTION_ATTACK, effectedLeader); - expectLastCall(); - creatureAI.setIntention(AI_INTENTION_IDLE, effectedLeader); - expectLastCall(); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effectedMinion); + when(buffInfo.getEffector()).thenReturn(effector); + when(buffInfo.getSkill()).thenReturn(skill); + when(effectedMinion.isRaid()).thenReturn(false); + when(effectedMinion.isServitor()).thenReturn(false); + when(effectedMinion.isSummon()).thenReturn(false); + when(effectedMinion.isRaidMinion()).thenReturn(true); + when(effectedMinion.getLeader()).thenReturn(effectedLeader); + when(Formulas.calcProbability(80, effector, effectedMinion, skill)).thenReturn(true); + when(effectedMinion.getAI()).thenReturn(creatureAI); effect.onStart(buffInfo); } diff --git a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantCallTargetPartyTest.java b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantCallTargetPartyTest.java index ecac8fcec44b7b78a54347c75c25f278c165cd4b..4f9e10a143a0f76b8d3ed68161050816e80a36fb 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantCallTargetPartyTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantCallTargetPartyTest.java @@ -1,18 +1,16 @@ package com.l2jserver.datapack.handlers.effecthandlers.instant; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.powermock.api.easymock.PowerMock.replayAll; +import static org.mockito.Mockito.when; import java.util.List; import java.util.Map; -import org.powermock.api.easymock.annotation.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.model.L2Party; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.actor.L2Character; @@ -22,10 +20,10 @@ import com.l2jserver.gameserver.model.skills.BuffInfo; /** * Instant Call Target Party effect test. * @author Zoey76 - * @version 2.6.2.0 + * @version 2.6.3.0 */ -@PrepareForTest(BuffInfo.class) -public class InstantCallTargetPartyTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class InstantCallTargetPartyTest { @Mock private BuffInfo buffInfo; @@ -38,10 +36,10 @@ public class InstantCallTargetPartyTest extends AbstractTest { @Mock private L2PcInstance partyMember; - private InstantCallTargetParty effect; + private static InstantCallTargetParty effect; - @BeforeSuite - void init() { + @BeforeAll + static void init() { final var set = new StatsSet(Map.of("name", "InstantBetray")); final var params = new StatsSet(Map.of("chance", "80", "time", "30")); effect = new InstantCallTargetParty(null, null, set, params); @@ -49,39 +47,34 @@ public class InstantCallTargetPartyTest extends AbstractTest { @Test void test_target_not_in_party() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.isInParty()).andReturn(false); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.isInParty()).thenReturn(false); effect.onStart(buffInfo); } @Test void test_target_in_party_cannot_summon_party_member() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.isInParty()).andReturn(true); - expect(effected.getParty()).andReturn(party); - expect(party.getMembers()).andReturn(List.of(effectedPlayer, partyMember)); - expect(effected.getActingPlayer()).andReturn(effectedPlayer); - expect(effectedPlayer.canSummonTarget(partyMember)).andReturn(false); - expect(effectedPlayer.canSummonTarget(effectedPlayer)).andReturn(false); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.isInParty()).thenReturn(true); + when(effected.getParty()).thenReturn(party); + when(party.getMembers()).thenReturn(List.of(effectedPlayer, partyMember)); + when(effected.getActingPlayer()).thenReturn(effectedPlayer); + when(effectedPlayer.canSummonTarget(partyMember)).thenReturn(false); + when(effectedPlayer.canSummonTarget(effectedPlayer)).thenReturn(false); effect.onStart(buffInfo); } @Test void test_target_in_party_can_summon_party_member() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.isInParty()).andReturn(true); - expect(effected.getParty()).andReturn(party); - expect(party.getMembers()).andReturn(List.of(effectedPlayer, partyMember)); - expect(effected.getActingPlayer()).andReturn(effectedPlayer); - expect(effectedPlayer.canSummonTarget(partyMember)).andReturn(true); - expect(effectedPlayer.canSummonTarget(effectedPlayer)).andReturn(false); - partyMember.teleToLocation(effected, true); - expectLastCall(); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.isInParty()).thenReturn(true); + when(effected.getParty()).thenReturn(party); + when(party.getMembers()).thenReturn(List.of(effectedPlayer, partyMember)); + when(effected.getActingPlayer()).thenReturn(effectedPlayer); + when(effectedPlayer.canSummonTarget(partyMember)).thenReturn(true); + when(effectedPlayer.canSummonTarget(effectedPlayer)).thenReturn(false); effect.onStart(buffInfo); } diff --git a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDespawnTest.java b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDespawnTest.java index 4f698f4cd75a5f30c10add396fe1882a82811077..f7bc81a655dbe6b8c940f7bb9dc35f37b7be322b 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDespawnTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDespawnTest.java @@ -18,20 +18,18 @@ */ package com.l2jserver.datapack.handlers.effecthandlers.instant; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replayAll; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; import java.util.Map; -import org.powermock.api.easymock.annotation.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import com.l2jserver.commons.util.Rnd; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Summon; @@ -41,13 +39,10 @@ import com.l2jserver.gameserver.model.skills.BuffInfo; /** * Despawn instant effect test. * @author Zoey76 - * @version 2.6.2.0 + * @version 2.6.3.0 */ -@PrepareForTest({ - BuffInfo.class, - Rnd.class -}) -public class InstantDespawnTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class InstantDespawnTest { private static final int CHANCE = 75; @@ -60,10 +55,12 @@ public class InstantDespawnTest extends AbstractTest { @Mock private L2Summon summon; - private InstantDespawn effect; + private static InstantDespawn effect; - @BeforeSuite - void init() { + @BeforeAll + static void init() { + mockStatic(Rnd.class); + final var set = new StatsSet(Map.of("name", "InstantDespawn")); final var params = new StatsSet(Map.of("chance", CHANCE)); effect = new InstantDespawn(null, null, set, params); @@ -76,45 +73,37 @@ public class InstantDespawnTest extends AbstractTest { @Test public void test_null_player() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.getActingPlayer()).andReturn(null); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.getActingPlayer()).thenReturn(null); effect.onStart(buffInfo); } @Test public void test_null_summon() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.getActingPlayer()).andReturn(player); - expect(player.getSummon()).andReturn(null); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.getActingPlayer()).thenReturn(player); + when(player.getSummon()).thenReturn(null); effect.onStart(buffInfo); } @Test public void test_chance_fail() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.getActingPlayer()).andReturn(player); - expect(player.getSummon()).andReturn(summon); - mockStatic(Rnd.class); - expect(Rnd.get(100)).andReturn(CHANCE - 1); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.getActingPlayer()).thenReturn(player); + when(player.getSummon()).thenReturn(summon); + when(Rnd.get(100)).thenReturn(CHANCE - 1); effect.onStart(buffInfo); } @Test public void test_chance_success() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.getActingPlayer()).andReturn(player); - expect(player.getSummon()).andReturn(summon); - mockStatic(Rnd.class); - expect(Rnd.get(100)).andReturn(CHANCE); - summon.unSummon(player); - expectLastCall(); - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.getActingPlayer()).thenReturn(player); + when(player.getSummon()).thenReturn(summon); + when(Rnd.get(100)).thenReturn(CHANCE); effect.onStart(buffInfo); } diff --git a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDispelByNameTest.java b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDispelByNameTest.java index 65899eb992db79a2de037ed2a281a50d99fabcf3..f4022e5a45b43ce46dfdeba31d6e2486f3f00915 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDispelByNameTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/instant/InstantDispelByNameTest.java @@ -18,18 +18,16 @@ */ package com.l2jserver.datapack.handlers.effecthandlers.instant; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.powermock.api.easymock.PowerMock.replayAll; +import static org.mockito.Mockito.when; import java.util.Map; -import org.powermock.api.easymock.annotation.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.model.CharEffectList; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.actor.L2Character; @@ -38,13 +36,10 @@ import com.l2jserver.gameserver.model.skills.BuffInfo; /** * Dispel By Name instant effect test. * @author Zoey76 - * @version 2.6.2.0 + * @version 2.6.3.0 */ -@PrepareForTest({ - BuffInfo.class, - CharEffectList.class -}) -public class InstantDispelByNameTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class InstantDispelByNameTest { private static final int SKILL_ID = 4342; @@ -55,10 +50,10 @@ public class InstantDispelByNameTest extends AbstractTest { @Mock private CharEffectList effectList; - private InstantDispelByName effect; + private static InstantDispelByName effect; - @BeforeSuite - void init() { + @BeforeAll + static void init() { final var set = new StatsSet(Map.of("name", "InstantDispelByName")); final var params = new StatsSet(Map.of("id", SKILL_ID)); effect = new InstantDispelByName(null, null, set, params); @@ -71,12 +66,8 @@ public class InstantDispelByNameTest extends AbstractTest { @Test public void test_effect_dispel() { - expect(buffInfo.getEffected()).andReturn(effected); - expect(effected.getEffectList()).andReturn(effectList); - effectList.stopSkillEffects(true, SKILL_ID); - expectLastCall().once(); - - replayAll(); + when(buffInfo.getEffected()).thenReturn(effected); + when(effected.getEffectList()).thenReturn(effectList); effect.onStart(buffInfo); } diff --git a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/pump/TransformHangoverTest.java b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/pump/TransformHangoverTest.java index 091c33165c1115246492b74f2d35f1a005df7808..1d8ffc472ab96042c6b653861372abf995d33b2d 100644 --- a/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/pump/TransformHangoverTest.java +++ b/src/test/java/com/l2jserver/datapack/handlers/effecthandlers/pump/TransformHangoverTest.java @@ -20,30 +20,30 @@ package com.l2jserver.datapack.handlers.effecthandlers.pump; import java.util.Map; -import org.powermock.api.easymock.annotation.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.l2jserver.datapack.test.AbstractTest; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.skills.BuffInfo; /** * Transform Hangover pump effect test. * @author Zoey76 - * @version 2.6.2.0 + * @version 2.6.3.0 */ -@PrepareForTest(BuffInfo.class) -public class TransformHangoverTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +public class TransformHangoverTest { @Mock private BuffInfo buffInfo; - private TransformHangover effect; + private static TransformHangover effect; - @BeforeSuite - void init() { + @BeforeAll + static void init() { final var set = new StatsSet(Map.of("name", "TransformHangover")); final var params = new StatsSet(Map.of()); effect = new TransformHangover(null, null, set, params); diff --git a/src/test/java/com/l2jserver/datapack/test/AbstractTest.java b/src/test/java/com/l2jserver/datapack/test/AbstractTest.java deleted file mode 100644 index b019bb96a3e0421bb36eceb0ac97ffcf54e7b059..0000000000000000000000000000000000000000 --- a/src/test/java/com/l2jserver/datapack/test/AbstractTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2004-2021 L2J DataPack - * - * This file is part of L2J DataPack. - * - * L2J DataPack is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * L2J DataPack is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package com.l2jserver.datapack.test; - -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; - -import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; -import com.l2jserver.gameserver.model.skills.Skill; - -/** - * Abstract Test. - * @author Zoey76 - * @version 2.6.2.0 - */ -@PrepareForTest({ - L2PcInstance.class, - Skill.class -}) -@PowerMockIgnore({ - "javax.xml.*", - "org.w3c.*", - "org.apache.*", - "org.slf4j.*", - "com.sun.*" -}) -public class AbstractTest extends PowerMockTestCase { - -}