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:
@ -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());
|
||||
|
Reference in New Issue
Block a user