mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-29 04:28:03 +01:00
Fixed TryToComplete test class
This commit is contained in:
parent
550e348428
commit
53f0a0cb37
@ -254,7 +254,7 @@ public class TryToCompleteTest {
|
||||
// ItemFactory
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
|
||||
|
||||
// ChatColor
|
||||
PowerMockito.mockStatic(ChatColor.class, Mockito.RETURNS_MOCKS);
|
||||
when(ChatColor.stripColor(anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
@ -282,7 +282,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotDeployed() {
|
||||
challenge.setDeployed(false);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.not-deployed");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-deployed"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,7 +292,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringWrongWorld() {
|
||||
challenge.setUniqueId("test");
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("general.errors.wrong-world");
|
||||
verify(user).getTranslation(any(World.class), eq("general.errors.wrong-world"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,7 +303,7 @@ public class TryToCompleteTest {
|
||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, true);
|
||||
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.not-on-island");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.not-on-island"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -314,7 +314,7 @@ public class TryToCompleteTest {
|
||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, false);
|
||||
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"), eq("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -324,7 +324,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringLevelNotUnlocked() {
|
||||
when(cm.isLevelUnlocked(any(), any(), any())).thenReturn(false);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.challenge-level-not-available");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.challenge-level-not-available"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,7 +335,7 @@ public class TryToCompleteTest {
|
||||
challenge.setRepeatable(false);
|
||||
when(cm.isChallengeComplete(any(User.class), any(), any())).thenReturn(true);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.not-repeatable");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-repeatable"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,7 +347,7 @@ public class TryToCompleteTest {
|
||||
challenge.setMaxTimes(0);
|
||||
when(cm.getChallengeTimes(any(), any(), any(Challenge.class))).thenReturn(0L);
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"), eq("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,7 +357,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNoRank() {
|
||||
when(island.isAllowed(any(), any())).thenReturn(false);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.no-rank");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.no-rank"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ public class TryToCompleteTest {
|
||||
@Test
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntZero() {
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 0));
|
||||
verify(user).getTranslation("challenges.errors.not-valid-integer");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-valid-integer"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,7 +375,7 @@ public class TryToCompleteTest {
|
||||
@Test
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntNegative() {
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, -10));
|
||||
verify(user).getTranslation("challenges.errors.not-valid-integer");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-valid-integer"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +385,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntPositiveWrongEnvinonment() {
|
||||
challenge.setEnvironment(Collections.singleton(Environment.NETHER));
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
||||
verify(user).getTranslation("challenges.errors.wrong-environment");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.wrong-environment"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,7 +398,7 @@ public class TryToCompleteTest {
|
||||
when(user.hasPermission(anyString())).thenReturn(false);
|
||||
challenge.setRequirements(req);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
||||
verify(user).getTranslation("general.errors.no-permission");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.no-permission"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -407,7 +407,7 @@ public class TryToCompleteTest {
|
||||
@Test
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccess() {
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"), eq("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -419,7 +419,7 @@ public class TryToCompleteTest {
|
||||
req.setRequiredItems(Collections.singletonList(new ItemStack(Material.EMERALD_BLOCK)));
|
||||
challenge.setRequirements(req);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.emerald_block");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"), eq("challenges.materials.emerald_block"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -454,9 +454,9 @@ public class TryToCompleteTest {
|
||||
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
// Sufficient emerald blocks
|
||||
verify(user, never()).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.emerald_block");
|
||||
verify(user, never()).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"), eq("challenges.materials.emerald_block"));
|
||||
// Not enough books
|
||||
verify(user).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.enchanted_book");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"),eq("challenges.materials.enchanted_book"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -466,7 +466,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessCreative() {
|
||||
when(player.getGameMode()).thenReturn(GameMode.CREATIVE);
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),eq("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -496,7 +496,7 @@ public class TryToCompleteTest {
|
||||
req.setSearchRadius(1);
|
||||
challenge.setRequirements(req);
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"), eq("name"));
|
||||
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ public class TryToCompleteTest {
|
||||
req.setSearchRadius(1);
|
||||
challenge.setRequirements(req);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"), eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||
|
||||
}
|
||||
|
||||
@ -531,9 +531,9 @@ public class TryToCompleteTest {
|
||||
req.setSearchRadius(1);
|
||||
challenge.setRequirements(req);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "5", "[item]", "challenges.entities.chicken.name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"), eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("1"), eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("5"), eq("[item]"), eq("challenges.entities.chicken.name"));
|
||||
|
||||
}
|
||||
|
||||
@ -558,9 +558,9 @@ public class TryToCompleteTest {
|
||||
List<Entity> list = Collections.singletonList(ent);
|
||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
||||
verify(user, never()).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "5", "[item]", "challenges.entities.chicken.name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"), eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||
verify(user, never()).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("1"), eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("5"), eq("[item]"), eq("challenges.entities.chicken.name"));
|
||||
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ public class TryToCompleteTest {
|
||||
List<Entity> list = Collections.singletonList(ent);
|
||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"), eq("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -611,7 +611,7 @@ public class TryToCompleteTest {
|
||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||
when(netherWorld.getNearbyEntities(any(BoundingBox.class))).thenReturn(Collections.emptyList());
|
||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("1"), eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -621,7 +621,7 @@ public class TryToCompleteTest {
|
||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntMultipleTimesPositiveSuccess() {
|
||||
// Try to complete 10 times. Already done 3 times, and max is 10, so it should be only done 7 times
|
||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 10));
|
||||
verify(user).getTranslation("challenges.messages.you-repeated-challenge-multiple", "[value]", "name", "[count]", "7");
|
||||
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-repeated-challenge-multiple"), eq("[value]"), eq("name"), eq("[count]"), eq("7"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user