First review changes++
First review changes++
This commit is contained in:
@ -24,8 +24,7 @@ import org.junit.Test;
|
||||
|
||||
import com.iluwatar.datamapper.Student;
|
||||
import com.iluwatar.datamapper.StudentDataMapper;
|
||||
import com.iluwatar.datamapper.StudentFirstDataMapper;
|
||||
import com.iluwatar.datamapper.StudentSecondDataMapper;
|
||||
import com.iluwatar.datamapper.StudentDataMapperImpl;
|
||||
|
||||
/**
|
||||
* The Data Mapper (DM) is a layer of software that separates the in-memory objects from the
|
||||
@ -45,41 +44,7 @@ public class DataMapperTest {
|
||||
public void testFirstDataMapper() {
|
||||
|
||||
/* Create new data mapper of first type */
|
||||
final StudentDataMapper mapper = new StudentFirstDataMapper();
|
||||
|
||||
/* Create new student */
|
||||
Student student = new Student(1, "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());
|
||||
|
||||
/* Update existing student object */
|
||||
student = new Student(student.getStudentId(), "AdamUpdated", 'A');
|
||||
|
||||
/* Update student in respectibe db */
|
||||
mapper.update(student);
|
||||
|
||||
/* Check if student is updated in db */
|
||||
assertEquals(mapper.find(student.getStudentId()).get().getName(), "AdamUpdated");
|
||||
|
||||
/* Delete student in db */
|
||||
mapper.delete(student);
|
||||
|
||||
/* Result should be false */
|
||||
assertEquals(false, mapper.find(student.getStudentId()).isPresent());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verify that second data mapper is able to perform all CRUD operations on Student
|
||||
*/
|
||||
@Test
|
||||
public void testSecondDataMapper() {
|
||||
|
||||
/* Create new data mapper of second type */
|
||||
final StudentDataMapper mapper = new StudentSecondDataMapper();
|
||||
final StudentDataMapper mapper = new StudentDataMapperImpl();
|
||||
|
||||
/* Create new student */
|
||||
Student student = new Student(1, "Adam", 'A');
|
||||
|
Reference in New Issue
Block a user