|
| 1 | +package warranty; |
| 2 | + |
| 3 | +import java.text.ParseException; |
| 4 | +import java.text.SimpleDateFormat; |
| 5 | +import org.junit.Test; |
| 6 | + |
| 7 | +import warranty.Contract.Status; |
| 8 | + |
| 9 | +import junit.framework.Assert; |
| 10 | + |
| 11 | +public class TestClaimsAdjudication { |
| 12 | + |
| 13 | + @Test |
| 14 | + public void testClaimsAdjudication() throws ParseException |
| 15 | + { |
| 16 | + SimpleDateFormat sourceFormat = new SimpleDateFormat("MM-dd-yyyy"); |
| 17 | + |
| 18 | + Contract contract = new Contract(999, 100.0); |
| 19 | + contract.effectiveDate = sourceFormat.parse("08-05-2010"); |
| 20 | + contract.expirationDate = sourceFormat.parse("08-05-2012"); |
| 21 | + contract.status = Status.ACTIVE; |
| 22 | + |
| 23 | + Claim claim = new Claim(888, 79.0, sourceFormat.parse("08-05-2010")); |
| 24 | + |
| 25 | + ClaimsAdjudicationService adjudicator = new ClaimsAdjudicationService(); |
| 26 | + |
| 27 | + adjudicator.Adjudicate(contract, claim); |
| 28 | + |
| 29 | + Assert.assertEquals(1, contract.getClaims().size()); |
| 30 | + } |
| 31 | + |
| 32 | + |
| 33 | + @Test |
| 34 | + public void testClaimsAdjudicationForInvalidClaim() throws ParseException |
| 35 | + { |
| 36 | + SimpleDateFormat sourceFormat = new SimpleDateFormat("MM-dd-yyyy"); |
| 37 | + |
| 38 | + Contract contract = new Contract(999, 100.0); |
| 39 | + contract.effectiveDate = sourceFormat.parse("08-05-2010"); |
| 40 | + contract.expirationDate = sourceFormat.parse("08-05-2012"); |
| 41 | + contract.status = Status.ACTIVE; |
| 42 | + |
| 43 | + Claim claim = new Claim(888, 81.0, sourceFormat.parse("08-05-2010")); |
| 44 | + |
| 45 | + ClaimsAdjudicationService adjudicator = new ClaimsAdjudicationService(); |
| 46 | + |
| 47 | + adjudicator.Adjudicate(contract, claim); |
| 48 | + |
| 49 | + Assert.assertEquals(0, contract.getClaims().size()); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void testClaimsAdjudicationForPendingContract() throws ParseException |
| 54 | + { |
| 55 | + SimpleDateFormat sourceFormat = new SimpleDateFormat("MM-dd-yyyy"); |
| 56 | + |
| 57 | + Claim claim = new Claim(888, 81.0, sourceFormat.parse("08-05-2010")); |
| 58 | + |
| 59 | + Contract pendingContract = new Contract(999, 100.0); |
| 60 | + pendingContract.effectiveDate = sourceFormat.parse("08-05-2010"); |
| 61 | + pendingContract.expirationDate = sourceFormat.parse("08-05-2012"); |
| 62 | + pendingContract.status = Status.PENDING; |
| 63 | + |
| 64 | + ClaimsAdjudicationService adjudicator = new ClaimsAdjudicationService(); |
| 65 | + |
| 66 | + adjudicator.Adjudicate(pendingContract, claim); |
| 67 | + |
| 68 | + Assert.assertEquals(0, pendingContract.getClaims().size()); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void testClaimsAdjudicationForExpiredContract() throws ParseException |
| 73 | + { |
| 74 | + SimpleDateFormat sourceFormat = new SimpleDateFormat("MM-dd-yyyy"); |
| 75 | + |
| 76 | + Claim claim = new Claim(888, 79.0, sourceFormat.parse("08-05-2010")); |
| 77 | + |
| 78 | + Contract pendingContract = new Contract(999, 100.0); |
| 79 | + pendingContract.effectiveDate = sourceFormat.parse("08-05-2010"); |
| 80 | + pendingContract.expirationDate = sourceFormat.parse("08-05-2012"); |
| 81 | + pendingContract.status = Status.EXPIRED; |
| 82 | + |
| 83 | + ClaimsAdjudicationService adjudicator = new ClaimsAdjudicationService(); |
| 84 | + |
| 85 | + adjudicator.Adjudicate(pendingContract, claim); |
| 86 | + |
| 87 | + Assert.assertEquals(0, pendingContract.getClaims().size()); |
| 88 | + } |
| 89 | +} |
0 commit comments