Skip to content

Commit a9a09fe

Browse files
author
nareshwart
committed
fix
1 parent 3a54db4 commit a9a09fe

1 file changed

Lines changed: 34 additions & 36 deletions

File tree

src/test/java/com/devopsdemo/utilities/TestGenericComparator.java

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
import com.devopsdemo.utilities.GenericComparator;
77
import com.devopsdemo.utilities.CaseInsensitiveComparator;
88

9-
import junit.framework.Test;
10-
import junit.framework.TestCase;
11-
import junit.framework.TestSuite;
12-
import org.junit.*;
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.Disabled;
11+
import static org.junit.jupiter.api.Assertions.*;
1312
/**
1413
* @author Seshagiri Sriram
1514
*
1615
*/
17-
1816
@SuppressWarnings({"rawtypes","unchecked"})
19-
20-
public class TestGenericComparator
21-
extends TestCase
22-
{
17+
public class TestGenericComparator {
2318
public void initialize(ArrayList myData) {
2419
UnitDTO d1 = new UnitDTO();
2520
d1.setDeptID(100);d1.setEmpID(200);d1.setEmpName("Sriram");d1.setSpare(new Double(18.0));d1.setSpare2(new Double(18.0));
@@ -71,24 +66,14 @@ public void initialize3(ArrayList myData) {
7166
*
7267
* @param testName name of the test case
7368
*/
74-
public TestGenericComparator( String testName )
75-
{
76-
super( testName );
77-
}
7869

79-
/**
80-
* @return the suite of tests being tested
81-
*/
82-
public static Test suite()
83-
{
84-
return new TestSuite( TestGenericComparator.class );
85-
}
8670

8771

8872
/**
8973
* Test for Sorting by Emp Name Ascending
9074
*/
91-
public void testSortEmpNameAsc() {
75+
@Test
76+
void testSortEmpNameAsc() {
9277
ArrayList myData = new ArrayList(); initialize(myData);
9378
Collections.sort(myData, new GenericComparator("empName", true)); // sort ascending..
9479
assertEquals("Asma", ((UnitDTO)myData.get(0)).getEmpName());
@@ -97,19 +82,21 @@ public void testSortEmpNameAsc() {
9782
/**
9883
* Test for Sorting by Emp Name Descending
9984
*/
100-
public void testSortEmpNameDesc() {
85+
@Test
86+
void testSortEmpNameDesc() {
10187
ArrayList myData = new ArrayList(); initialize(myData);
10288
Collections.sort(myData, new GenericComparator("empName", false)); // sort ascending..
10389
assertEquals("Vellman", ((UnitDTO)myData.get(0)).getEmpName());
10490

10591
}
10692

107-
93+
10894
/**
10995
* Test for Sorting by Emp ID Ascending
11096
*/
111-
@Ignore("testSortIDAsc")
112-
public void testSortEmpIDAsc() {
97+
@Disabled("testSortIDAsc")
98+
@Test
99+
void testSortEmpIDAsc() {
113100
ArrayList myData = new ArrayList(); initialize(myData);
114101

115102
Collections.sort(myData, new GenericComparator("empID", true)); // sort ascending..
@@ -121,7 +108,8 @@ public void testSortEmpIDAsc() {
121108
* Test for Sorting besy Emp ID Descending...
122109
*/
123110

124-
public void testSortEmpIDDesc() {
111+
@Test
112+
void testSortEmpIDDesc() {
125113
ArrayList myData = new ArrayList(); initialize(myData);
126114
Collections.sort(myData, new GenericComparator("empID", false)); // sort Descending
127115
assertEquals("Somebody", ((UnitDTO)myData.get(0)).getEmpName());
@@ -131,7 +119,8 @@ public void testSortEmpIDDesc() {
131119
/**
132120
* Test for Sorting by spare Ascending
133121
*/
134-
public void testSortEmpSpareAsc() {
122+
@Test
123+
void testSortEmpSpareAsc() {
135124
ArrayList myData = new ArrayList(); initialize(myData);
136125
Collections.sort(myData, new GenericComparator("spare", true)); // sort ascending
137126
assertEquals("Vellman", ((UnitDTO)myData.get(0)).getEmpName());
@@ -140,7 +129,8 @@ public void testSortEmpSpareAsc() {
140129
/**
141130
* Test for Sorting by spare Descending
142131
*/
143-
public void testSortEmpSpareDesc() {
132+
@Test
133+
void testSortEmpSpareDesc() {
144134
ArrayList myData = new ArrayList(); initialize(myData);
145135
Collections.sort(myData, new GenericComparator("spare", false)); // sort Descending
146136
assertEquals("Sriram", ((UnitDTO)myData.get(0)).getEmpName());
@@ -151,7 +141,8 @@ public void testSortEmpSpareDesc() {
151141
/**
152142
* Test for Sorting by spare2 Descending
153143
*/
154-
public void testSortEmpSpareDesc2() {
144+
@Test
145+
void testSortEmpSpareDesc2() {
155146
ArrayList myData = new ArrayList(); initialize(myData);
156147

157148
Collections.sort(myData, new GenericComparator("spare2", false)); // sort Descending
@@ -162,7 +153,8 @@ public void testSortEmpSpareDesc2() {
162153
/**
163154
* Test for Sorting by spare2 Ascending
164155
*/
165-
public void testSortEmpSpareAsc2() {
156+
@Test
157+
void testSortEmpSpareAsc2() {
166158
ArrayList myData = new ArrayList(); initialize(myData);
167159

168160
Collections.sort(myData, new GenericComparator("spare2", true)); // sort ascending
@@ -173,7 +165,8 @@ public void testSortEmpSpareAsc2() {
173165
/**
174166
* Test for Sorting by spare2 Ascending
175167
*/
176-
public void testSortEmpSpare2StringAsc() {
168+
@Test
169+
void testSortEmpSpare2StringAsc() {
177170
ArrayList myData = new ArrayList(); initialize2(myData);
178171
Collections.sort(myData, new GenericComparator("spare2", true)); // sort ascending
179172
assertEquals("A", ((UnitDTO)myData.get(0)).getSpare2());
@@ -182,15 +175,17 @@ public void testSortEmpSpare2StringAsc() {
182175
/**
183176
* Test for Sorting by spare2 Desc
184177
*/
185-
public void testSortEmpSpare2StringDesc() {
178+
@Test
179+
void testSortEmpSpare2StringDesc() {
186180
ArrayList myData = new ArrayList(); initialize2(myData);
187181
Collections.sort(myData, new GenericComparator("spare2", false)); // sort Descending
188182
assertEquals("Z", ((UnitDTO)myData.get(0)).getSpare2());
189183
}
190184
/**
191185
* Test for Sorting by caseInsensitive Emp Name Ascending
192186
*/
193-
public void testSortEmpNameAscNewComparator() {
187+
@Test
188+
void testSortEmpNameAscNewComparator() {
194189
ArrayList myData = new ArrayList(); initialize3(myData);
195190
Collections.sort(myData, new CaseInsensitiveComparator("empName", true)); // sort ascending..
196191
assertEquals("Asma".toUpperCase(), ((UnitDTO)myData.get(0)).getEmpName().toUpperCase());
@@ -203,7 +198,8 @@ public void testSortEmpNameAscNewComparator() {
203198
/**
204199
* Test for Sorting caseInsensitive by Emp Name Ascending
205200
*/
206-
public void testSortEmpNameAscNewComparator3Element() {
201+
@Test
202+
void testSortEmpNameAscNewComparator3Element() {
207203
ArrayList myData = new ArrayList(); initialize3(myData);
208204
Collections.sort(myData, new CaseInsensitiveComparator("empName", true)); // sort ascending..
209205
assertEquals("Asma".toUpperCase(), ((UnitDTO)myData.get(0)).getEmpName().toUpperCase());
@@ -215,7 +211,8 @@ public void testSortEmpNameAscNewComparator3Element() {
215211
/**
216212
* Test for Sorting caseInsensitive by Emp Name Descending
217213
*/
218-
public void testSortEmpNameDescNewComparator3Element() {
214+
@Test
215+
void testSortEmpNameDescNewComparator3Element() {
219216
ArrayList myData = new ArrayList(); initialize3(myData);
220217
Collections.sort(myData, new CaseInsensitiveComparator("empName", false)); // sort ascending..
221218
assertEquals("Asma".toUpperCase(), ((UnitDTO)myData.get(3)).getEmpName().toUpperCase());
@@ -224,7 +221,8 @@ public void testSortEmpNameDescNewComparator3Element() {
224221

225222
}
226223

227-
public void testDoubleSort() {
224+
@Test
225+
void testDoubleSort() {
228226
ArrayList myData = new ArrayList();
229227
UnitDTO d1 = new UnitDTO();
230228
d1.setDeptID(100);d1.setEmpID(200);d1.setEmpName("A");d1.setSpare(new Double(18.0));d1.setSpare2(new Double(18.0));

0 commit comments

Comments
 (0)