mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-20 14:24:15 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -24,25 +24,22 @@
|
||||
*/
|
||||
package com.iluwatar.servicelayer.app;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
/** Application test */
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
HibernateUtil.dropSession();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,31 +43,23 @@ import org.junit.jupiter.api.Test;
|
||||
*/
|
||||
public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>> {
|
||||
|
||||
/**
|
||||
* The number of entities stored before each test
|
||||
*/
|
||||
/** The number of entities stored before each test */
|
||||
private static final int INITIAL_COUNT = 5;
|
||||
|
||||
/**
|
||||
* The unique id generator, shared between all entities
|
||||
*/
|
||||
/** The unique id generator, shared between all entities */
|
||||
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* Factory, used to create new entity instances with the given name
|
||||
*/
|
||||
/** Factory, used to create new entity instances with the given name */
|
||||
private final Function<String, E> factory;
|
||||
|
||||
/**
|
||||
* The tested data access object
|
||||
*/
|
||||
/** The tested data access object */
|
||||
private final D dao;
|
||||
|
||||
/**
|
||||
* Create a new test using the given factory and dao
|
||||
*
|
||||
* @param factory The factory, used to create new entity instances with the given name
|
||||
* @param dao The tested data access object
|
||||
* @param dao The tested data access object
|
||||
*/
|
||||
public BaseDaoTest(final Function<String, E> factory, final D dao) {
|
||||
this.factory = factory;
|
||||
@@ -141,5 +133,4 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
|
||||
assertEquals(expectedName, entity.getName());
|
||||
assertEquals(expectedName, entity.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-16
@@ -41,10 +41,7 @@ import com.iluwatar.servicelayer.wizard.WizardDao;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* MagicServiceImplTest
|
||||
*
|
||||
*/
|
||||
/** MagicServiceImplTest */
|
||||
class MagicServiceImplTest {
|
||||
|
||||
@Test
|
||||
@@ -93,11 +90,7 @@ class MagicServiceImplTest {
|
||||
void testFindWizardsWithSpellbook() {
|
||||
final var bookname = "bookname";
|
||||
final var spellbook = mock(Spellbook.class);
|
||||
final var wizards = Set.of(
|
||||
mock(Wizard.class),
|
||||
mock(Wizard.class),
|
||||
mock(Wizard.class)
|
||||
);
|
||||
final var wizards = Set.of(mock(Wizard.class), mock(Wizard.class), mock(Wizard.class));
|
||||
when(spellbook.getWizards()).thenReturn(wizards);
|
||||
|
||||
final var spellbookDao = mock(SpellbookDao.class);
|
||||
@@ -106,7 +99,6 @@ class MagicServiceImplTest {
|
||||
final var wizardDao = mock(WizardDao.class);
|
||||
final var spellDao = mock(SpellDao.class);
|
||||
|
||||
|
||||
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
|
||||
verifyNoInteractions(wizardDao, spellbookDao, spellDao, spellbook);
|
||||
|
||||
@@ -122,11 +114,7 @@ class MagicServiceImplTest {
|
||||
|
||||
@Test
|
||||
void testFindWizardsWithSpell() {
|
||||
final var wizards = Set.of(
|
||||
mock(Wizard.class),
|
||||
mock(Wizard.class),
|
||||
mock(Wizard.class)
|
||||
);
|
||||
final var wizards = Set.of(mock(Wizard.class), mock(Wizard.class), mock(Wizard.class));
|
||||
final var spellbook = mock(Spellbook.class);
|
||||
when(spellbook.getWizards()).thenReturn(wizards);
|
||||
|
||||
@@ -152,5 +140,4 @@ class MagicServiceImplTest {
|
||||
|
||||
verifyNoMoreInteractions(wizardDao, spellbookDao, spellDao);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import com.iluwatar.servicelayer.common.BaseDaoTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* SpellDaoImplTest
|
||||
*
|
||||
*/
|
||||
/** SpellDaoImplTest */
|
||||
class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
|
||||
|
||||
public SpellDaoImplTest() {
|
||||
@@ -51,5 +48,4 @@ class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
|
||||
assertEquals(spell.getName(), spellByName.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-5
@@ -30,10 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import com.iluwatar.servicelayer.common.BaseDaoTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* SpellbookDaoImplTest
|
||||
*
|
||||
*/
|
||||
/** SpellbookDaoImplTest */
|
||||
class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImpl> {
|
||||
|
||||
public SpellbookDaoImplTest() {
|
||||
@@ -51,5 +48,4 @@ class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImpl> {
|
||||
assertEquals(book.getName(), spellByName.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import com.iluwatar.servicelayer.common.BaseDaoTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* WizardDaoImplTest
|
||||
*
|
||||
*/
|
||||
/** WizardDaoImplTest */
|
||||
class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
|
||||
|
||||
public WizardDaoImplTest() {
|
||||
@@ -51,5 +48,4 @@ class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
|
||||
assertEquals(spell.getName(), byName.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user