Global monster drops are retrieved from DropProvider (postgres db)
This commit is contained in:
@@ -6,6 +6,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import server.life.MonsterDropEntry;
|
||||
import server.life.MonsterGlobalDropEntry;
|
||||
import testutil.Any;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -82,8 +83,8 @@ class DropProviderTest {
|
||||
GlobalMonsterDrop globalDrop = new GlobalMonsterDrop(2049100, -1, 2, 3, null, 450);
|
||||
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(globalDrop));
|
||||
|
||||
List<MonsterGlobalDropEntry> dropEntries1 = dropProvider.getGlobalDropEntries();
|
||||
List<MonsterGlobalDropEntry> dropEntries2 = dropProvider.getGlobalDropEntries();
|
||||
List<MonsterGlobalDropEntry> dropEntries1 = dropProvider.getRelevantGlobalDrops(Any.integer());
|
||||
List<MonsterGlobalDropEntry> dropEntries2 = dropProvider.getRelevantGlobalDrops(Any.integer());
|
||||
|
||||
assertEquals(1, dropEntries1.size());
|
||||
assertEquals(1, dropEntries2.size());
|
||||
@@ -104,6 +105,28 @@ class DropProviderTest {
|
||||
verify(dropDao, times(1)).getGlobalMonsterDrops();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRelevantGlobalDrop() {
|
||||
GlobalMonsterDrop ossyriaDrop = new GlobalMonsterDrop(Any.integer(), 2, Any.integer(), Any.integer(), Any.integer(), Any.integer());
|
||||
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(ossyriaDrop));
|
||||
int ossyriaMapId = 200_000_200;
|
||||
|
||||
List<MonsterGlobalDropEntry> dropEntries = dropProvider.getRelevantGlobalDrops(ossyriaMapId);
|
||||
|
||||
assertEquals(1, dropEntries.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRelevantGlobalDrop_wrongContinent() {
|
||||
GlobalMonsterDrop ellinDrop = new GlobalMonsterDrop(Any.integer(), 3, Any.integer(), Any.integer(), Any.integer(), Any.integer());
|
||||
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(ellinDrop));
|
||||
int victoriaMapId = 102_000_000;
|
||||
|
||||
List<MonsterGlobalDropEntry> dropEntries = dropProvider.getRelevantGlobalDrops(victoriaMapId);
|
||||
|
||||
assertTrue(dropEntries.isEmpty());
|
||||
}
|
||||
|
||||
// TODO: add tests for getRandomStealDrop() once ItemInformationProvider is able to be mocked.
|
||||
// Currently, it does database calls (and a bunch of other stuff) in the constructor, which is problematic.
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import server.MakerItemFactory;
|
||||
import testutil.AnyValues;
|
||||
import testutil.Any;
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.List;
|
||||
@@ -80,7 +80,7 @@ class MakerInfoProviderTest {
|
||||
void getRecipeFromDb_notFound() {
|
||||
givenNoRecipe();
|
||||
|
||||
Optional<MakerRecipe> recipe = makerInfoProvider.getMakerRecipe(AnyValues.integer());
|
||||
Optional<MakerRecipe> recipe = makerInfoProvider.getMakerRecipe(Any.integer());
|
||||
|
||||
assertTrue(recipe.isEmpty());
|
||||
}
|
||||
@@ -111,7 +111,7 @@ class MakerInfoProviderTest {
|
||||
MakerRecipe recipeWithCatalyst = new MakerRecipe(0, (short) 0, (short) 0, (short) 0, 0, null, null, catalyst, (short) 0, (short) 0);
|
||||
when(makerDao.getRecipe(anyInt())).thenReturn(Optional.of(recipeWithCatalyst));
|
||||
|
||||
Optional<Integer> stimulant = makerInfoProvider.getStimulant(AnyValues.integer());
|
||||
Optional<Integer> stimulant = makerInfoProvider.getStimulant(Any.integer());
|
||||
|
||||
assertTrue(stimulant.isPresent());
|
||||
assertEquals(catalyst, stimulant.get());
|
||||
@@ -121,7 +121,7 @@ class MakerInfoProviderTest {
|
||||
void getStimulant_noRecipe() {
|
||||
givenNoRecipe();
|
||||
|
||||
Optional<Integer> stimulant = makerInfoProvider.getStimulant(AnyValues.integer());
|
||||
Optional<Integer> stimulant = makerInfoProvider.getStimulant(Any.integer());
|
||||
|
||||
assertTrue(stimulant.isEmpty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user