📍Use lombok, reformat, and optimize the code (#1560)

* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@ -31,8 +31,7 @@ import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDaoImpl;
import com.iluwatar.servicelayer.wizard.Wizard;
import com.iluwatar.servicelayer.wizard.WizardDaoImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
@ -52,9 +51,8 @@ import org.slf4j.LoggerFactory;
* dao, service). For persistence the example uses in-memory H2 database which is populated on each
* application startup.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
public static final String BOOK_OF_IDORES = "Book of Idores";
/**

View File

@ -26,18 +26,16 @@ package com.iluwatar.servicelayer.hibernate;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.wizard.Wizard;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Produces the Hibernate {@link SessionFactory}.
*/
@Slf4j
public final class HibernateUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class);
/**
* The cached session factory.
*/

View File

@ -93,7 +93,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testFind() {
void testFind() {
final var all = this.dao.findAll();
for (final var entity : all) {
final var byId = this.dao.find(entity.getId());
@ -103,7 +103,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testDelete() {
void testDelete() {
final var originalEntities = this.dao.findAll();
this.dao.delete(originalEntities.get(1));
this.dao.delete(originalEntities.get(2));
@ -114,14 +114,14 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testFindAll() {
void testFindAll() {
final var all = this.dao.findAll();
assertNotNull(all);
assertEquals(INITIAL_COUNT, all.size());
}
@Test
public void testSetId() {
void testSetId() {
final var entity = this.factory.apply("name");
assertNull(entity.getId());
@ -131,7 +131,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testSetName() {
void testSetName() {
final var entity = this.factory.apply("name");
assertEquals("name", entity.getName());
assertEquals("name", entity.toString());

View File

@ -46,10 +46,10 @@ import org.junit.jupiter.api.Test;
*
* @author Jeroen Meulemeester
*/
public class MagicServiceImplTest {
class MagicServiceImplTest {
@Test
public void testFindAllWizards() {
void testFindAllWizards() {
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
@ -63,7 +63,7 @@ public class MagicServiceImplTest {
}
@Test
public void testFindAllSpellbooks() {
void testFindAllSpellbooks() {
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
@ -77,7 +77,7 @@ public class MagicServiceImplTest {
}
@Test
public void testFindAllSpells() {
void testFindAllSpells() {
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
@ -91,7 +91,7 @@ public class MagicServiceImplTest {
}
@Test
public void testFindWizardsWithSpellbook() {
void testFindWizardsWithSpellbook() {
final var bookname = "bookname";
final var spellbook = mock(Spellbook.class);
final var wizards = Set.of(
@ -122,7 +122,7 @@ public class MagicServiceImplTest {
}
@Test
public void testFindWizardsWithSpell() throws Exception {
void testFindWizardsWithSpell() throws Exception {
final var wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),

View File

@ -34,14 +34,14 @@ import org.junit.jupiter.api.Test;
*
* @author Jeroen Meulemeester
*/
public class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
public SpellDaoImplTest() {
super(Spell::new, new SpellDaoImpl());
}
@Test
public void testFindByName() {
void testFindByName() {
final var dao = getDao();
final var allSpells = dao.findAll();
for (final var spell : allSpells) {

View File

@ -34,14 +34,14 @@ import org.junit.jupiter.api.Test;
*
* @author Jeroen Meulemeester
*/
public class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImpl> {
class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImpl> {
public SpellbookDaoImplTest() {
super(Spellbook::new, new SpellbookDaoImpl());
}
@Test
public void testFindByName() {
void testFindByName() {
final var dao = getDao();
final var allBooks = dao.findAll();
for (final var book : allBooks) {

View File

@ -34,14 +34,14 @@ import org.junit.jupiter.api.Test;
*
* @author Jeroen Meulemeester
*/
public class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
public WizardDaoImplTest() {
super(Wizard::new, new WizardDaoImpl());
}
@Test
public void testFindByName() {
void testFindByName() {
final var dao = getDao();
final var allWizards = dao.findAll();
for (final var spell : allWizards) {