Rename ...Dao -> ...Repository

This commit is contained in:
P0nk
2024-09-14 12:06:09 +02:00
parent abbec8120e
commit 08eeeb54dc
17 changed files with 103 additions and 103 deletions

View File

@@ -21,19 +21,19 @@ import static org.mockito.Mockito.when;
class DropProviderTest {
@Mock
private DropDao dropDao;
private DropRepository dropRepository;
private DropProvider dropProvider;
@BeforeEach
void reset() {
MockitoAnnotations.openMocks(this);
this.dropProvider = new DropProvider(dropDao);
this.dropProvider = new DropProvider(dropRepository);
}
@Test
void getMonsterDropEntries_noDrops() {
when(dropDao.getMonsterDrops(anyInt())).thenReturn(Collections.emptyList());
when(dropRepository.getMonsterDrops(anyInt())).thenReturn(Collections.emptyList());
List<MonsterDropEntry> dropEntries = dropProvider.getMonsterDropEntries(489340);
@@ -43,7 +43,7 @@ class DropProviderTest {
@Test
void getMonsterDropEntries() {
MonsterDrop snailShellDrop = snailShellDrop();
when(dropDao.getMonsterDrops(anyInt())).thenReturn(List.of(snailShellDrop));
when(dropRepository.getMonsterDrops(anyInt())).thenReturn(List.of(snailShellDrop));
List<MonsterDropEntry> dropEntries = dropProvider.getMonsterDropEntries(100100);
@@ -58,7 +58,7 @@ class DropProviderTest {
@Test
void getCachedMonsterDropEntries() {
when(dropDao.getMonsterDrops(anyInt())).thenReturn(List.of(snailShellDrop()));
when(dropRepository.getMonsterDrops(anyInt())).thenReturn(List.of(snailShellDrop()));
int monsterId = 100100;
List<MonsterDropEntry> dropEntries1 = dropProvider.getMonsterDropEntries(monsterId);
@@ -73,7 +73,7 @@ class DropProviderTest {
assertEquals(dropEntry1.Maximum, dropEntry2.Maximum);
assertEquals(dropEntry1.questid, dropEntry2.questid);
assertEquals(dropEntry1.chance, dropEntry2.chance);
verify(dropDao, times(1)).getMonsterDrops(anyInt());
verify(dropRepository, times(1)).getMonsterDrops(anyInt());
}
private MonsterDrop snailShellDrop() {
@@ -83,7 +83,7 @@ class DropProviderTest {
@Test
void getCachedGlobalDropEntries() {
GlobalMonsterDrop globalDrop = new GlobalMonsterDrop(2049100, -1, 2, 3, null, 450);
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(globalDrop));
when(dropRepository.getGlobalMonsterDrops()).thenReturn(List.of(globalDrop));
List<MonsterGlobalDropEntry> dropEntries1 = dropProvider.getRelevantGlobalDrops(AnyValues.integer());
List<MonsterGlobalDropEntry> dropEntries2 = dropProvider.getRelevantGlobalDrops(AnyValues.integer());
@@ -104,13 +104,13 @@ class DropProviderTest {
assertEquals(dropEntry1.questid, dropEntry2.questid);
assertEquals(450, dropEntry1.chance);
assertEquals(dropEntry1.chance, dropEntry2.chance);
verify(dropDao, times(1)).getGlobalMonsterDrops();
verify(dropRepository, times(1)).getGlobalMonsterDrops();
}
@Test
void getRelevantGlobalDrop() {
GlobalMonsterDrop ossyriaDrop = new GlobalMonsterDrop(AnyValues.integer(), 2, AnyValues.integer(), AnyValues.integer(), AnyValues.integer(), AnyValues.integer());
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(ossyriaDrop));
when(dropRepository.getGlobalMonsterDrops()).thenReturn(List.of(ossyriaDrop));
int ossyriaMapId = 200_000_200;
List<MonsterGlobalDropEntry> dropEntries = dropProvider.getRelevantGlobalDrops(ossyriaMapId);
@@ -121,7 +121,7 @@ class DropProviderTest {
@Test
void getRelevantGlobalDrop_wrongContinent() {
GlobalMonsterDrop ellinDrop = new GlobalMonsterDrop(AnyValues.integer(), 3, AnyValues.integer(), AnyValues.integer(), AnyValues.integer(), AnyValues.integer());
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(ellinDrop));
when(dropRepository.getGlobalMonsterDrops()).thenReturn(List.of(ellinDrop));
int victoriaMapId = 102_000_000;
List<MonsterGlobalDropEntry> dropEntries = dropProvider.getRelevantGlobalDrops(victoriaMapId);
@@ -132,28 +132,28 @@ class DropProviderTest {
@Test
void clearCaches_shouldClearMonsterDrops() {
MonsterDrop drop = snailShellDrop();
when(dropDao.getMonsterDrops(anyInt())).thenReturn(List.of(drop));
when(dropRepository.getMonsterDrops(anyInt())).thenReturn(List.of(drop));
int monsterId = 100100;
List<MonsterDropEntry> drops1 = dropProvider.getMonsterDropEntries(monsterId);
dropProvider.clearCaches();
List<MonsterDropEntry> drops2 = dropProvider.getMonsterDropEntries(monsterId);
verify(dropDao, times(2)).getMonsterDrops(anyInt());
verify(dropRepository, times(2)).getMonsterDrops(anyInt());
assertEquals(1, drops1.size());
assertEquals(1, drops2.size());
}
@Test
void clearCaches_shouldClearGlobalDrops() {
when(dropDao.getGlobalMonsterDrops()).thenReturn(List.of(globalDrop()));
when(dropRepository.getGlobalMonsterDrops()).thenReturn(List.of(globalDrop()));
int mapId = 100_000_123;
List<MonsterGlobalDropEntry> drops1 = dropProvider.getRelevantGlobalDrops(mapId);
dropProvider.clearCaches();
List<MonsterGlobalDropEntry> drops2 = dropProvider.getRelevantGlobalDrops(mapId);
verify(dropDao, times(2)).getGlobalMonsterDrops();
verify(dropRepository, times(2)).getGlobalMonsterDrops();
assertEquals(1, drops1.size());
assertEquals(1, drops2.size());
}

View File

@@ -22,14 +22,14 @@ import static org.mockito.Mockito.when;
class MakerInfoProviderTest {
@Mock
private MakerDao makerDao;
private MakerRepository makerRepository;
private MakerInfoProvider makerInfoProvider;
@BeforeEach
void reset() {
MockitoAnnotations.openMocks(this);
this.makerInfoProvider = new MakerInfoProvider(makerDao);
this.makerInfoProvider = new MakerInfoProvider(makerRepository);
}
@Test
@@ -41,7 +41,7 @@ class MakerInfoProviderTest {
void getReagentFromDb() {
int itemId = 5783;
MakerReagent reagent = createReagent(itemId);
when(makerDao.getReagent(anyInt())).thenReturn(Optional.of(reagent));
when(makerRepository.getReagent(anyInt())).thenReturn(Optional.of(reagent));
Optional<MakerReagent> retrievedReagent = makerInfoProvider.getMakerReagent(itemId);
@@ -53,7 +53,7 @@ class MakerInfoProviderTest {
void getCachedReagent() {
int itemId = 90123444;
MakerReagent reagent = createReagent(itemId);
when(makerDao.getReagent(anyInt())).thenReturn(Optional.of(reagent));
when(makerRepository.getReagent(anyInt())).thenReturn(Optional.of(reagent));
Optional<MakerReagent> firstReagent = makerInfoProvider.getMakerReagent(itemId);
Optional<MakerReagent> secondReagent = makerInfoProvider.getMakerReagent(itemId);
@@ -62,7 +62,7 @@ class MakerInfoProviderTest {
assertEquals(reagent, firstReagent.get());
assertTrue(secondReagent.isPresent());
assertEquals(reagent, secondReagent.get());
verify(makerDao, times(1)).getReagent(itemId);
verify(makerRepository, times(1)).getReagent(itemId);
}
private MakerReagent createReagent(int itemId) {
@@ -73,7 +73,7 @@ class MakerInfoProviderTest {
void getRecipeFromDb() {
int itemId = 43893;
MakerRecipe recipe = createRecipe(itemId);
when(makerDao.getRecipe(itemId)).thenReturn(Optional.of(recipe));
when(makerRepository.getRecipe(itemId)).thenReturn(Optional.of(recipe));
Optional<MakerRecipe> retrievedRecipe = makerInfoProvider.getMakerRecipe(itemId);
@@ -94,7 +94,7 @@ class MakerInfoProviderTest {
void getCachedRecipe() {
int itemId = 10848;
MakerRecipe recipe = createRecipe(itemId);
when(makerDao.getRecipe(anyInt())).thenReturn(Optional.of(recipe));
when(makerRepository.getRecipe(anyInt())).thenReturn(Optional.of(recipe));
Optional<MakerRecipe> firstRecipe = makerInfoProvider.getMakerRecipe(itemId);
Optional<MakerRecipe> secondRecipe = makerInfoProvider.getMakerRecipe(itemId);
@@ -103,7 +103,7 @@ class MakerInfoProviderTest {
assertEquals(recipe, firstRecipe.get());
assertTrue(secondRecipe.isPresent());
assertEquals(recipe, secondRecipe.get());
verify(makerDao, times(1)).getRecipe(itemId);
verify(makerRepository, times(1)).getRecipe(itemId);
}
private MakerRecipe createRecipe(int itemId) {
@@ -114,7 +114,7 @@ class MakerInfoProviderTest {
void getStimulant() {
int catalyst = 4031200;
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));
when(makerRepository.getRecipe(anyInt())).thenReturn(Optional.of(recipeWithCatalyst));
Optional<Integer> stimulant = makerInfoProvider.getStimulant(AnyValues.integer());
@@ -144,9 +144,9 @@ class MakerInfoProviderTest {
void getMakerItemCreateEntry() {
final int itemId = 458945;
MakerRecipe recipe = createRecipe(itemId);
when(makerDao.getRecipe(anyInt())).thenReturn(Optional.of(recipe));
when(makerRepository.getRecipe(anyInt())).thenReturn(Optional.of(recipe));
MakerIngredient ingredient = new MakerIngredient(1002003, (short) 5);
when(makerDao.getIngredients(anyInt())).thenReturn(List.of(ingredient));
when(makerRepository.getIngredients(anyInt())).thenReturn(List.of(ingredient));
Optional<MakerItemFactory.MakerItemCreateEntry> optionalCreateEntry = makerInfoProvider.getMakerItemEntry(itemId);
@@ -166,6 +166,6 @@ class MakerInfoProviderTest {
}
private void givenNoRecipe() {
when(makerDao.getRecipe(anyInt())).thenReturn(Optional.empty());
when(makerRepository.getRecipe(anyInt())).thenReturn(Optional.empty());
}
}