-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerPriorityComparatorTest.java
More file actions
61 lines (46 loc) · 1.94 KB
/
Copy pathCustomerPriorityComparatorTest.java
File metadata and controls
61 lines (46 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import static org.junit.Assert.*;
import org.junit.Test;
public class CustomerPriorityComparatorTest
{
@Test
public void test_compare_differentRating_firstSmaller(){
Customer c1 = new Customer("Customer One", 123);
CreditHistory h1 = new CreditHistory();
h1.addRating(4);
c1.setCreditHistory(h1);
Customer c2 = new Customer("Customer Two", 456);
CreditHistory h2 = new CreditHistory();
h2.addRating(5);
c2.setCreditHistory(h2);
int actual = (new CustomerPriorityComparator()).compare(c1,c2);
assertTrue("Lower credit rating should be ordered after In other words, credit rating of 4 is greater than (worse) credit rating of 5.", actual > 0);
}
@Test
public void test_compare_differentRating_secondSmaller(){
Customer c1 = new Customer("Customer One", 123);
CreditHistory h1 = new CreditHistory();
h1.addRating(-1);
c1.setCreditHistory(h1);
Customer c2 = new Customer("Customer Two", 456);
CreditHistory h2 = new CreditHistory();
h2.addRating(3);
c2.setCreditHistory(h2);
int actual = (new CustomerPriorityComparator()).compare(c2,c1);
assertTrue("Lower credit rating should be ordered after In other words, credit rating of -1 is greater than (worse) credit rating of 3.", actual < 0);
}
@Test
public void test_compare_sameRating(){
Customer c1 = new Customer("Customer Two", 123);
CreditHistory h1 = new CreditHistory();
h1.addRating(3);
h1.addRating(4);
c1.setCreditHistory(h1);
Customer c2 = new Customer("Customer Two", 123);
CreditHistory h2 = new CreditHistory();
h2.addRating(3);
h2.addRating(4);
c2.setCreditHistory(h2);
int actual = (new CustomerPriorityComparator()).compare(c1,c2);
assertEquals("Expecting zero when both have same credit rating.", 0, actual);
}
}