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

This commit is contained in:
Narendra Pathai
2018-10-17 21:11:31 +05:30
parent db33cc533b
commit 2f569d670a
39 changed files with 96 additions and 146 deletions

View File

@@ -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
@@ -58,12 +59,12 @@ public class DataMapperTest {
mapper.update(student);
/* Check if student is updated in db */
assertEquals(mapper.find(student.getStudentId()).get().getName(), "AdamUpdated");
assertEquals("AdamUpdated", 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());
}
}

View File

@@ -20,7 +20,9 @@ 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;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -28,28 +30,27 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
public final class StudentTest {
@Test
/**
* This API tests the equality behaviour of Student object
* Object Equality should work as per logic defined in equals method
*
* @throws Exception if any execution error during test
*/
@Test
public void testEquality() throws Exception {
/* Create some students */
final Student firstStudent = new Student(1, "Adam", 'A');
final Student secondStudent = new Student(2, "Donald", 'B');
final Student secondSameStudent = new Student(2, "Donald", 'B');
final Student firstSameStudent = firstStudent;
/* Check equals functionality: should return 'true' */
assertTrue(firstStudent.equals(firstSameStudent));
assertEquals(firstStudent, firstStudent);
/* Check equals functionality: should return 'false' */
assertFalse(firstStudent.equals(secondStudent));
assertNotEquals(firstStudent, secondStudent);
/* Check equals functionality: should return 'true' */
assertTrue(secondStudent.equals(secondSameStudent));
assertEquals(secondStudent, secondSameStudent);
}
}