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:
@ -21,6 +21,7 @@ package com.iluwatar.datamapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
/**
|
||||
* The Data Mapper (DM) is a layer of software that separates the in-memory objects from the
|
||||
@ -43,27 +44,29 @@ public class DataMapperTest {
|
||||
final StudentDataMapper mapper = new StudentDataMapperImpl();
|
||||
|
||||
/* Create new student */
|
||||
Student student = new Student(1, "Adam", 'A');
|
||||
int studentId = 1;
|
||||
Student student = new Student(studentId, "Adam", 'A');
|
||||
|
||||
/* Add student in respectibe db */
|
||||
mapper.insert(student);
|
||||
|
||||
/* Check if student is added in db */
|
||||
assertEquals(student.getStudentId(), mapper.find(student.getStudentId()).get().getStudentId());
|
||||
assertEquals(studentId, mapper.find(student.getStudentId()).get().getStudentId());
|
||||
|
||||
/* Update existing student object */
|
||||
student = new Student(student.getStudentId(), "AdamUpdated", 'A');
|
||||
String updatedName = "AdamUpdated";
|
||||
student = new Student(student.getStudentId(), updatedName, 'A');
|
||||
|
||||
/* Update student in respectibe db */
|
||||
mapper.update(student);
|
||||
|
||||
/* Check if student is updated in db */
|
||||
assertEquals(mapper.find(student.getStudentId()).get().getName(), "AdamUpdated");
|
||||
assertEquals(updatedName, mapper.find(student.getStudentId()).get().getName());
|
||||
|
||||
/* Delete student in db */
|
||||
mapper.delete(student);
|
||||
|
||||
/* Result should be false */
|
||||
assertEquals(false, mapper.find(student.getStudentId()).isPresent());
|
||||
assertFalse(mapper.find(student.getStudentId()).isPresent());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user