mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-24 19:45:14 +01:00
Fixes tests
This commit is contained in:
parent
e3e3191e6c
commit
4cb4c7e3fb
@ -379,6 +379,8 @@ public class ChallengesManager
|
|||||||
* This method stores PlayerData into local cache.
|
* This method stores PlayerData into local cache.
|
||||||
*
|
*
|
||||||
* @param playerData ChallengesPlayerData that must be loaded.
|
* @param playerData ChallengesPlayerData that must be loaded.
|
||||||
|
*
|
||||||
|
* TODO: Remove this unused method?
|
||||||
*/
|
*/
|
||||||
private void loadPlayerData(@NonNull ChallengesPlayerData playerData)
|
private void loadPlayerData(@NonNull ChallengesPlayerData playerData)
|
||||||
{
|
{
|
||||||
@ -683,6 +685,7 @@ public class ChallengesManager
|
|||||||
/**
|
/**
|
||||||
* This method collects all data from challenges database and migrates them.
|
* This method collects all data from challenges database and migrates them.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private boolean migrateChallenges(World world)
|
private boolean migrateChallenges(World world)
|
||||||
{
|
{
|
||||||
String addonName = Utils.getGameMode(world);
|
String addonName = Utils.getGameMode(world);
|
||||||
|
@ -48,9 +48,9 @@ import world.bentobox.challenges.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class TryToComplete
|
public class TryToComplete
|
||||||
{
|
{
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Variables
|
// Section: Variables
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Challenges addon variable.
|
* Challenges addon variable.
|
||||||
@ -92,9 +92,9 @@ public class TryToComplete
|
|||||||
*/
|
*/
|
||||||
private final ChallengeResult EMPTY_RESULT = new ChallengeResult();
|
private final ChallengeResult EMPTY_RESULT = new ChallengeResult();
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Builder
|
// Section: Builder
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TryToComplete label(String label)
|
public TryToComplete label(String label)
|
||||||
@ -151,9 +151,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Constructor
|
// Section: Constructor
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,9 +228,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Methods
|
// Section: Methods
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -710,9 +710,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Inventory Challenge
|
// Section: Inventory Challenge
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -790,7 +790,6 @@ public class TryToComplete
|
|||||||
for (ItemStack required : requiredItemList)
|
for (ItemStack required : requiredItemList)
|
||||||
{
|
{
|
||||||
int amountToBeRemoved = required.getAmount() * factor;
|
int amountToBeRemoved = required.getAmount() * factor;
|
||||||
|
|
||||||
List<ItemStack> itemsInInventory;
|
List<ItemStack> itemsInInventory;
|
||||||
|
|
||||||
if (Utils.canIgnoreMeta(required.getType()))
|
if (Utils.canIgnoreMeta(required.getType()))
|
||||||
@ -809,7 +808,6 @@ public class TryToComplete
|
|||||||
filter(i -> i.isSimilar(required)).
|
filter(i -> i.isSimilar(required)).
|
||||||
collect(Collectors.toList());
|
collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack itemStack : itemsInInventory)
|
for (ItemStack itemStack : itemsInInventory)
|
||||||
{
|
{
|
||||||
if (amountToBeRemoved > 0)
|
if (amountToBeRemoved > 0)
|
||||||
@ -844,9 +842,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Island Challenge
|
// Section: Island Challenge
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1159,9 +1157,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Other challenge
|
// Section: Other challenge
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1235,9 +1233,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Title parsings
|
// Section: Title parsings
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1281,9 +1279,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Simple getter methods
|
// Section: Simple getter methods
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1316,9 +1314,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Result classes
|
// Section: Result classes
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1480,5 +1478,15 @@ public class TryToComplete
|
|||||||
* challenge requirements.
|
* challenge requirements.
|
||||||
*/
|
*/
|
||||||
private Queue<Entity> entities;
|
private Queue<Entity> entities;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ChallengeResult [completed=" + completed + ", meetsRequirements=" + meetsRequirements + ", factor="
|
||||||
|
+ factor + ", requiredItems=" + requiredItems + ", removedItems=" + removedItems + ", blocks="
|
||||||
|
+ blocks + ", entities=" + entities + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
|||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Bukkit.class, BentoBox.class, User.class, Config.class })
|
@PrepareForTest({Bukkit.class, BentoBox.class, User.class, Config.class })
|
||||||
public class ChallengesAddonTest {
|
public class ChallengesAddonTest {
|
||||||
|
@ -7,7 +7,6 @@ import static org.junit.Assert.assertNull;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@ -754,7 +753,6 @@ public class ChallengesManagerTest {
|
|||||||
cm.deleteChallenge(challenge);
|
cm.deleteChallenge(challenge);
|
||||||
ch = cm.getChallenge(cName);
|
ch = cm.getChallenge(cName);
|
||||||
assertNull(ch);
|
assertNull(ch);
|
||||||
verify(plhm).unregisterPlaceholder(eq("challenges_challenge_repetition_count_" + cName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +94,7 @@ public class TryToCompleteTest {
|
|||||||
private World world;
|
private World world;
|
||||||
private String topLabel = "island";
|
private String topLabel = "island";
|
||||||
private String permissionPrefix = "perm.";
|
private String permissionPrefix = "perm.";
|
||||||
private String cName;
|
|
||||||
private String levelName;
|
private String levelName;
|
||||||
@Mock
|
@Mock
|
||||||
private ChallengesManager cm;
|
private ChallengesManager cm;
|
||||||
@ -604,15 +604,17 @@ public class TryToCompleteTest {
|
|||||||
public void testBuild() {
|
public void testBuild() {
|
||||||
this.testTryToCompleteChallengesAddonUserChallengeWorldStringString();
|
this.testTryToCompleteChallengesAddonUserChallengeWorldStringString();
|
||||||
ChallengeResult result = this.ttc.build(10);
|
ChallengeResult result = this.ttc.build(10);
|
||||||
|
assertTrue(result.isMeetsRequirements());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItems() {
|
public void testRemoveItemsNothing() {
|
||||||
this.testTryToCompleteChallengesAddonUserChallengeWorldStringString();
|
this.testTryToCompleteChallengesAddonUserChallengeWorldStringString();
|
||||||
ttc.removeItems(Collections.emptyList(), 1);
|
assertTrue(ttc.removeItems(Collections.emptyList(), 1).isEmpty());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsSuccess() {
|
public void testRemoveItemsSuccess() {
|
||||||
Material requiredMaterial = Material.PAPER;
|
Material requiredMaterial = Material.PAPER;
|
||||||
@ -100,6 +101,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsMax() {
|
public void testRemoveItemsMax() {
|
||||||
Material requiredMaterial = Material.PAPER;
|
Material requiredMaterial = Material.PAPER;
|
||||||
@ -116,6 +118,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsZero() {
|
public void testRemoveItemsZero() {
|
||||||
Material requiredMaterial = Material.PAPER;
|
Material requiredMaterial = Material.PAPER;
|
||||||
@ -132,6 +135,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsSuccessMultiple() {
|
public void testRemoveItemsSuccessMultiple() {
|
||||||
required.add(new ItemStack(Material.PAPER, 11));
|
required.add(new ItemStack(Material.PAPER, 11));
|
||||||
@ -147,6 +151,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsSuccessMultipleOther() {
|
public void testRemoveItemsSuccessMultipleOther() {
|
||||||
required.add(new ItemStack(Material.CACTUS, 5));
|
required.add(new ItemStack(Material.CACTUS, 5));
|
||||||
@ -165,6 +170,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsMultipleOtherFail() {
|
public void testRemoveItemsMultipleOtherFail() {
|
||||||
required.add(new ItemStack(Material.ACACIA_FENCE, 5));
|
required.add(new ItemStack(Material.ACACIA_FENCE, 5));
|
||||||
@ -181,6 +187,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsFail() {
|
public void testRemoveItemsFail() {
|
||||||
ItemStack input = new ItemStack(Material.GOLD_BLOCK, 55);
|
ItemStack input = new ItemStack(Material.GOLD_BLOCK, 55);
|
||||||
@ -201,6 +208,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testRequireTwoStacks() {
|
public void testRequireTwoStacks() {
|
||||||
required.add(new ItemStack(Material.BRICK_STAIRS, 64));
|
required.add(new ItemStack(Material.BRICK_STAIRS, 64));
|
||||||
@ -218,6 +226,7 @@ public class TryToCompleteTestOld {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for {@link TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testFactorStacks() {
|
public void testFactorStacks() {
|
||||||
required.add(new ItemStack(Material.BRICK_STAIRS, 32));
|
required.add(new ItemStack(Material.BRICK_STAIRS, 32));
|
||||||
|
Loading…
Reference in New Issue
Block a user