|
@@ -1,150 +0,0 @@
|
|
|
-package com.redhat.training.claims;
|
|
|
-
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-
|
|
|
-import com.redhat.training.claims.model.Claim;
|
|
|
-import com.redhat.training.claims.model.ClaimProcessingAborted;
|
|
|
-import com.redhat.training.claims.model.ClaimResults;
|
|
|
-import com.redhat.training.claims.model.Claimant;
|
|
|
-import com.redhat.training.claims.model.Gender;
|
|
|
-
|
|
|
-import org.junit.Test;
|
|
|
-
|
|
|
-public class ClaimantInvolvedTest extends ClaimsTestSupport {
|
|
|
- @Test
|
|
|
- public void testClaimantInvolved() {
|
|
|
- System.out.println("Running testClaimantInvolved...");
|
|
|
-
|
|
|
- this.insertValidClaimantAndClaim(123, 1000.00, "John Doe", Gender.MALE, "Crash");
|
|
|
-
|
|
|
- session.getAgenda().getAgendaGroup("sanity").setFocus();
|
|
|
- session.fireAllRules();
|
|
|
-
|
|
|
- ArrayList<ClaimResults> crs = this.getClaimResults();
|
|
|
- ArrayList<ClaimProcessingAborted> cpas = this.getClaimProcessingAborted();
|
|
|
-
|
|
|
- // must succeed
|
|
|
- assertEquals("Unexpected number of claim results", 1, crs.size());
|
|
|
- assertEquals("Unexpected number of claim rejections", 1, cpas.size());
|
|
|
- assertEquals("No rejection expected", 0, cpas.get(0).getReasons().size());
|
|
|
- assertTrue("Expected reason not in claim result", crs.get(0).getReasons().contains("Claim owner properly listed as involved."));
|
|
|
-
|
|
|
- System.out.println("Finished assertions for testClaimantInvolved.");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testClaimantNotInvolved() {
|
|
|
- System.out.println("Running testClaimantNotInvolved...");
|
|
|
-
|
|
|
- this.insertInvalidClaimantAndClaim(234, 1500.00, "Jane Doe", Gender.FEMALE, "Breakdown");
|
|
|
-
|
|
|
- session.getAgenda().getAgendaGroup("sanity").setFocus();
|
|
|
- session.fireAllRules();
|
|
|
-
|
|
|
- ArrayList<ClaimResults> crs = this.getClaimResults();
|
|
|
- ArrayList<ClaimProcessingAborted> cpas = this.getClaimProcessingAborted();
|
|
|
-
|
|
|
- assertEquals("Unexpected number of claim results", 1, crs.size());
|
|
|
- assertEquals("Unexpected number of claim rejections", 1, cpas.size());
|
|
|
- assertEquals("Rejection expected", 1, cpas.get(0).getReasons().size());
|
|
|
- assertTrue("Expected reason not in claim result", cpas.get(0).getReasons().contains("Can't file claim on behalf of someone else."));
|
|
|
-
|
|
|
- System.out.println("Finished assertions for testClaimantNotInvolved.");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testClaimantNotInvolvedLowAmount() {
|
|
|
- System.out.println("Running testClaimantNotInvolvedLowAmount...");
|
|
|
-
|
|
|
- this.insertInvalidClaimantAndClaim(345, 100.00, "Jane Doe", Gender.FEMALE, "Foo");
|
|
|
-
|
|
|
- session.getAgenda().getAgendaGroup("sanity").setFocus();
|
|
|
- session.fireAllRules();
|
|
|
-
|
|
|
- ArrayList<ClaimResults> crs = this.getClaimResults();
|
|
|
- ArrayList<ClaimProcessingAborted> cpas = this.getClaimProcessingAborted();
|
|
|
-
|
|
|
- assertEquals("Unexpected number of claim results", 1, crs.size());
|
|
|
- assertEquals("Unexpected number of claim rejections", 1, cpas.size());
|
|
|
- assertEquals("Rejection expected", 1, cpas.get(0).getReasons().size());
|
|
|
- assertTrue("Expected reason not in claim result", cpas.get(0).getReasons().contains("Can't file claim on behalf of someone else."));
|
|
|
-
|
|
|
- System.out.println("Finished assertions for testClaimantNotInvolvedLowAmount.");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMultipleClaimsOneClaimant() {
|
|
|
- System.out.println("Running testMultipleClaimsOneClaimant...");
|
|
|
- Claimant c = new Claimant();
|
|
|
- c.setName("John Doe");
|
|
|
- c.setGender(Gender.MALE);
|
|
|
-
|
|
|
- Claim cl1 = new Claim();
|
|
|
- cl1.setId(123);
|
|
|
- cl1.setAmount(1000.00);
|
|
|
- cl1.setReason("Crash");
|
|
|
- cl1.getInvolvedPersons().add(c);
|
|
|
-
|
|
|
- Claim cl2 = new Claim();
|
|
|
- cl2.setId(234);
|
|
|
- cl2.setAmount(1000.00);
|
|
|
- cl2.setReason("Crash");
|
|
|
- //cl.getInvolvedPersons().add(c);
|
|
|
-
|
|
|
- c.getClaims().add(cl1);
|
|
|
- c.getClaims().add(cl2);
|
|
|
-
|
|
|
- session.insert(c);
|
|
|
- session.insert(cl1);
|
|
|
- session.insert(cl2);
|
|
|
-
|
|
|
- session.getAgenda().getAgendaGroup("sanity").setFocus();
|
|
|
- session.fireAllRules();
|
|
|
-
|
|
|
- ArrayList<ClaimResults> crs = this.getClaimResults();
|
|
|
- ArrayList<ClaimProcessingAborted> cpas = this.getClaimProcessingAborted();
|
|
|
-
|
|
|
- assertEquals("Unexpected number of claim results", 2, crs.size());
|
|
|
- assertEquals("Unexpected number of claim rejections", 2, cpas.size());
|
|
|
-
|
|
|
- for (ClaimProcessingAborted cpa : cpas) {
|
|
|
- // Expect cl1 to NOT be rejected.
|
|
|
- if (cpa.getClaimId() == cl1.getId()) {
|
|
|
- assertEquals("No rejection expected for Claim " + cl1.getId(), 0, cpa.getReasons().size());
|
|
|
- }
|
|
|
- // Expect cl2 to BE rejected.
|
|
|
- if (cpa.getClaimId() == cl2.getId()) {
|
|
|
- assertEquals("Rejection expected for Claim " + cl2.getId(), 1, cpa.getReasons().size());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println("Finished assertions for testMultipleClaimsOneClaimant.");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMultipleClaimsMultiClaimants() {
|
|
|
- System.out.println("Running testMultipleClaimsMultiClaimants...");
|
|
|
-
|
|
|
- this.insertValidClaimantAndClaim(123, 1000.00, "John Doe", Gender.MALE, "Crash");
|
|
|
- this.insertValidClaimantAndClaim(234, 1500.00, "Jane Doe", Gender.FEMALE, "Breakdown");
|
|
|
-
|
|
|
- session.getAgenda().getAgendaGroup("sanity").setFocus();
|
|
|
- session.fireAllRules();
|
|
|
-
|
|
|
- ArrayList<ClaimResults> crs = this.getClaimResults();
|
|
|
- ArrayList<ClaimProcessingAborted> cpas = this.getClaimProcessingAborted();
|
|
|
-
|
|
|
- assertEquals("Unexpected number of claim results", 2, crs.size());
|
|
|
- assertEquals("Unexpected number of claim rejections", 2, cpas.size());
|
|
|
-
|
|
|
- for (ClaimProcessingAborted cpa : cpas) {
|
|
|
- // Expect NO claim to be rejected.
|
|
|
- assertEquals("No rejection expected for Claim " + cpa.getClaimId(), 0, cpa.getReasons().size());
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println("Finished assertions for testMultipleClaimsMultiClaimants.");
|
|
|
- }
|
|
|
-}
|