Minor refactorings and code style changes (#807)

* Made minor changes in some patterns such as removed throws clause where not needed, changed incorrect order of arguments in assertEquals

* Minor refactorings and code style changes. 1) Removed several use of raw types 2) Removed unnecessary throws clauses 3) Used lambda expressions wherever applicable 4) Used apt assertion methods for readability 5) Use of try with resources wherever applicable 6) Corrected incorrect order of assertXXX arguments

* Removed unused import from Promise

* Addressed review comments

* Addressed checkstyle issue
This commit is contained in:
Narendra Pathai
2018-10-23 13:45:41 +05:30
committed by GitHub
parent 25ed7c09c5
commit 2aa9e78ddd
112 changed files with 312 additions and 463 deletions

View File

@ -40,7 +40,7 @@ public class AppTest {
}
@AfterEach
public void tearDown() throws Exception {
public void tearDown() {
HibernateUtil.dropSession();
}

View File

@ -76,7 +76,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@BeforeEach
public void setUp() throws Exception {
public void setUp() {
for (int i = 0; i < INITIAL_COUNT; i++) {
final String className = dao.persistentClass.getSimpleName();
final String entityName = String.format("%s%d", className, ID_GENERATOR.incrementAndGet());
@ -85,7 +85,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@AfterEach
public void tearDown() throws Exception {
public void tearDown() {
HibernateUtil.dropSession();
}
@ -94,7 +94,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testFind() throws Exception {
public void testFind() {
final List<E> all = this.dao.findAll();
for (final E entity : all) {
final E byId = this.dao.find(entity.getId());
@ -104,7 +104,7 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testDelete() throws Exception {
public void testDelete() {
final List<E> originalEntities = this.dao.findAll();
this.dao.delete(originalEntities.get(1));
this.dao.delete(originalEntities.get(2));
@ -115,24 +115,24 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
}
@Test
public void testFindAll() throws Exception {
public void testFindAll() {
final List<E> all = this.dao.findAll();
assertNotNull(all);
assertEquals(INITIAL_COUNT, all.size());
}
@Test
public void testSetId() throws Exception {
public void testSetId() {
final E entity = this.factory.apply("name");
assertNull(entity.getId());
final Long expectedId = Long.valueOf(1);
final Long expectedId = 1L;
entity.setId(expectedId);
assertEquals(expectedId, entity.getId());
}
@Test
public void testSetName() throws Exception {
public void testSetName() {
final E entity = this.factory.apply("name");
assertEquals("name", entity.getName());
assertEquals("name", entity.toString());

View File

@ -51,7 +51,7 @@ import static org.mockito.Mockito.when;
public class MagicServiceImplTest {
@Test
public void testFindAllWizards() throws Exception {
public void testFindAllWizards() {
final WizardDao wizardDao = mock(WizardDao.class);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final SpellDao spellDao = mock(SpellDao.class);

View File

@ -42,7 +42,7 @@ public class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
}
@Test
public void testFindByName() throws Exception {
public void testFindByName() {
final SpellDaoImpl dao = getDao();
final List<Spell> allSpells = dao.findAll();
for (final Spell spell : allSpells) {

View File

@ -42,7 +42,7 @@ public class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImp
}
@Test
public void testFindByName() throws Exception {
public void testFindByName() {
final SpellbookDaoImpl dao = getDao();
final List<Spellbook> allBooks = dao.findAll();
for (final Spellbook book : allBooks) {

View File

@ -42,7 +42,7 @@ public class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
}
@Test
public void testFindByName() throws Exception {
public void testFindByName() {
final WizardDaoImpl dao = getDao();
final List<Wizard> allWizards = dao.findAll();
for (final Wizard spell : allWizards) {