Java tutorial
package com.aiatss.coast.pmm.application.service.agreement; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.poi.ss.usermodel.DateUtil; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; import com.aiatss.coast.appservice.systemsetup.application.bean.AccountBean; import com.aiatss.coast.appservice.systemsetup.application.bean.BillPlanBean; import com.aiatss.coast.appservice.systemsetup.application.bean.CurrencyBean; import com.aiatss.coast.appservice.systemsetup.application.service.AccountCodeAppService; import com.aiatss.coast.appservice.systemsetup.application.service.BillPlanAppService; import com.aiatss.coast.appservice.systemsetup.application.service.CurrencyAppService; import com.aiatss.coast.appservice.systemsetup.application.service.LookupAppService; import com.aiatss.coast.common.biztransaction.application.service.BizTransactionManager; import com.aiatss.coast.common.biztransaction.domain.model.BizTransaction; import com.aiatss.coast.common.infrastructure.persistent.BaseContext; import com.aiatss.coast.common.util.date.DateTimeUtil; import com.aiatss.coast.common.util.string.JsonUtil; import com.aiatss.coast.pmm.application.service.domainInitial.InitialMembers; import com.aiatss.coast.pmm.application.service.party.MemberService; import com.aiatss.coast.pmm.application.service.party.OrganizationService; import com.aiatss.coast.pmm.application.service.product.ProductService; import com.aiatss.coast.pmm.domain.model.agreement.Policy; import com.aiatss.coast.pmm.domain.model.agreement.PolicyAttachment; import com.aiatss.coast.pmm.domain.model.agreement.PolicyPkgScheme; import com.aiatss.coast.pmm.domain.model.agreement.PolicyPkgSchemeDetail; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProduct; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductAge; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductAttachment; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductBenefit; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductBenefitSum; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductPlan; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductPremiumRate; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductProducer; import com.aiatss.coast.pmm.domain.model.agreement.PolicyProductRepository; import com.aiatss.coast.pmm.domain.model.party.Address; import com.aiatss.coast.pmm.domain.model.party.Organization; import com.aiatss.coast.pmm.domain.model.product.Product; import com.aiatss.coast.pmm.domain.model.product.ProductPlan; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:spring/spring-datasource.xml" }) public class PolicyServiceTest { // @Autowired // @Qualifier(value = "jdbcDatabaseTester") // private IDatabaseTester databaseTester; // // @Autowired // @Qualifier(value = "jdbcTemplate") // private JdbcTemplate jdbcT; // @Autowired @Qualifier(value = "terminatePolicyService") private TerminatePolicyService terminatePolicyService; @Autowired @Qualifier(value = "policyService") private PolicyService policyService; @Autowired @Qualifier(value = "productService") private ProductService productService; @Autowired @Qualifier(value = "policyProductService") private PolicyProductService policyProductService; @Autowired @Qualifier(value = "policyProductRepository") private PolicyProductRepository policyProductRepository; @Autowired @Qualifier(value = "updatePolicyProductService") private UpdatePolicyProductService updatePolicyProductService; @Autowired @Qualifier(value = "updatePolicyService") private UpdatePolicyService updatePolicyService; @Autowired @Qualifier(value = "lookupAppService") private LookupAppService lookupAppService; @Autowired @Qualifier(value = "currencyAppService") private CurrencyAppService currencyAppService; @Autowired @Qualifier(value = "baseContext") private BaseContext baseContext; @Autowired @Qualifier(value = "memberService") private MemberService memberService; @Before public void setUp() throws Exception { baseContext.setUserId("Vincent"); } Date EffectiveDateAll = DateTimeUtil.getCurrentDate(); Date ExpireDateAll = DateUtil.parseYYYYMMDDDate("2099/12/31"); Date TransactionDateAll = DateTimeUtil.getCurrentDate(); Date InitialEffectiveDateAll = DateTimeUtil.getCurrentDate(); @Test public void verifyNewPolicyNoTest() throws Exception { // test createPolicy start ------- // Policy policy = new Policy(); // policy.setPolicyId(2); // policy.setPolicyNo("000000009"); // policy.setOrganizationId(1); // policy.setPolicyDesc("???"); // policy.setCompanyCode(1); // policy.setInitialEffectiveDate(DateTimeUtil.getCurrentDate()); // policy.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policy.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policy.setStatus("A"); // policy.setAnniversaryDate(DateTimeUtil.getCurrentDate()); // policy.setNoOfMember(1); // policy.setNoOfDependent(1); // policy.setTeamCode("0"); // policy.setServiceAEUserId("0"); // policy.setServicingOfficerUserId("0"); // policy.setAgeRefIND("0"); // policy.setAgeCalculateBase("0"); // policy.setAgencyForceClaimInd("0"); // policy.setAgencyForcePremiumInd("0"); // policy.setWaitingPeriod("0"); // policy.setEnrollPeriodDays(3); // policy.setAutoRenewInd("0"); // policy.setRenewalDays(3); // policy.setRecordStatus("A"); // policy.setClaimOfficerUserId("0"); // policy.setBillingOfficerUserId("0"); // policy.setRecordChangedBy("RanZhang"); // policy.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyService.createPolicy(policy); // test createPolicy end ------- // System.out.println(policyAttachment.toString()); // test createPolicyAttachment data ------start ------ // PolicyAttachment policyAttachment = new PolicyAttachment(); // policyAttachment.setPolicyId(10); // policyAttachment.setPolicyType("1"); // policyAttachment.setMMCRType("2"); // policyAttachment.setMMCRCycleDay(1); // policyAttachment.setMMCRSort("3"); // policyAttachment.setBatchBillCycleDay(1); // policyAttachment.setBatchAdjBillCycleDay(1); // policyAttachment.setBatchBillMode("4"); // policyAttachment.setBillWithMemberListInd("5"); // policyAttachment.setSuppressBillPrinting("6"); // policyAttachment.setSuppressBillInd("7"); // policyAttachment.setSuppressReceiptInd("8"); // policyAttachment.setAnnualizeClaimsLimitsInd("9"); // policyAttachment.setClaimPayeeType("1"); // policyAttachment.setExamptHoldClaimPremium("1"); // policyAttachment.setExemptHoldClaimShortfall("1"); // policyAttachment.setMonthlyEOBInd("1"); // policyAttachment.setMonthlyEOBCycleDay(1); // policyAttachment.setClaimAutoPayControlReport("1"); // policyAttachment.setAnnualizeClaimsLimitsInd("0"); // policyAttachment.setRecordChangedBy("RanZhang"); // policyAttachment.setRecordStatus("A"); // policyAttachment.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyService.createPolicyAttachment(policyAttachment); // test createPolicyAttachment data ------end ------ // test CreatePackagePolicyPlan data ------start ------ // PolicyPkgPlan policyPkgPlan = new PolicyPkgPlan(); // // policyPkgPlan.setPolicyPkgPlanId(1); // policyPkgPlan.setPolicyId(1); // policyPkgPlan.setPlanCode("A"); // policyPkgPlan.setPlanDesc("PlanDesc"); // policyPkgPlan.setPkgProductId(1); // policyPkgPlan.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyPkgPlan.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyPkgPlan.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyPkgPlan.setRecordStatus("A"); // policyPkgPlan.setRecordChangedBy("RanZhang"); // policyPkgPlan.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyService.CreatePackagePolicyPlan(policyPkgPlan); // test createPolicyAttachment data ------end ------ // test createProduct data ------start ------ // Product product = new Product(); // product.setProductId(1); // product.setProductCode("0"); // product.setProductShortName("001"); // product.setProductLocalShortName("1"); // product.setProductName("001"); // product.setProductLocalDesc("001"); // product.setEffectiveDate(DateTimeUtil.getCurrentDate()); // product.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // product.setCurrencyCode("0"); // product.setRLOBCode(new BigDecimal(22)); // product.setProductType("0"); // product.setProductGroup("0"); // product.setReinsuranceScemeCode("0"); // product.setPremiumTaxPercent(new BigDecimal(22)); // product.setPremiumTAX(new BigDecimal(22)); // product.setAccountCode("0"); // product.setValuationCode("0"); // product.setLocalValuationCode("0"); // product.setMAPAInd(new BigDecimal(22)); // product.setProductAbbreviation("0"); // product.setClaimProductType("0"); // product.setMedicalProudctType("0"); // product.setVoluntaryInd("0"); // product.setActuralTaxableInd("0"); // product.setRegulatorTaxableInd("0"); // product.setProductCategory("0"); // product.setClaimTATType("0"); // product.setDWHGroup("0"); // product.setPKGProductType("0"); // product.setFlexiNoOfPlan(1); // product.setFlexiIND("1"); // product.setLicenseType("0"); // product.setRecordStatus("A"); // product.setRecordChangedBy("RanZhang"); // product.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // productService.createProduct(product); // test createProduct data ------start ------ // PkgProduct pkgProduct = new PkgProduct(); // // pkgProduct.setPackageProductId(1); // pkgProduct.setPkgProductId(1); // pkgProduct.setProductId(3); // pkgProduct.setEffectiveDate(DateTimeUtil.getCurrentDate()); // pkgProduct.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // pkgProduct.setOptionalInd("001"); // pkgProduct.setRecordChangedBy("0"); // pkgProduct.setRecordStatus("RanZhang"); // pkgProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // test CreatePolicyPkgPlanDetail data ------start ------ // PolicyPkgPlanDetail policyPkgPlanDetail = new PolicyPkgPlanDetail(); // // policyPkgPlanDetail.setPolicyPkgPlanDetailId(30); // policyPkgPlanDetail.setPolicyPkgPlanId(3); // policyPkgPlanDetail.setPolicyProductPlanId(5); // policyPkgPlanDetail.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyPkgPlanDetail.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyPkgPlanDetail.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyPkgPlanDetail.setPolicyId(1); // policyPkgPlanDetail.setPkgProductId(3); // policyPkgPlanDetail.setRecordStatus("A"); // policyPkgPlanDetail.setRecordChangedBy("R"); // policyPkgPlanDetail.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyService.CreatePolicyPkgPlanDetail(policyPkgPlanDetail); // test createPolicyAttachment data ------end ------ // test CreatePolicyPkgPlanDetail data ------start ------ // PolicyPkgPlanDetail policyPkgPlanDetail = new PolicyPkgPlanDetail(); // policyPkgPlanDetail.setPolicyPkgPlanDetailId(31); // policyPkgPlanDetail.setPolicyPkgPlanId(3); // policyPkgPlanDetail.setPolicyProductPlanId(5); // policyPkgPlanDetail.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyPkgPlanDetail.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyPkgPlanDetail.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyPkgPlanDetail.setPolicyId(1); // policyPkgPlanDetail.setPkgProductId(3); // policyPkgPlanDetail.setRecordStatus("A"); // policyPkgPlanDetail.setRecordChangedBy("R"); // policyPkgPlanDetail.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyService.CreatePolicyPkgPlanDetail(policyPkgPlanDetail); // test createPolicyAttachment data ------end ------ // PolicyProductProducer policyProductProducer = new // PolicyProductProducer(); // // policyProductProducer.setPolicyProductProducerId(50); // policyProductProducer.setPolicyProductId(3); // policyProductProducer.setPolicyId(1); // policyProductProducer.setProductId(3); // policyProductProducer.setProducerId(1); // policyProductProducer.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyProductProducer.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyProductProducer.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyProductProducer.setProducerSharePC(new BigDecimal(1)); // policyProductProducer.setOriginalAgencyId(1); // policyProductProducer.setSevicingProducerInd("1"); // policyProductProducer.setReceiveCorrespondenceInd("1"); // policyProductProducer.setRecordStatus("A"); // policyProductProducer.setRecordChangedBy("RanZhang"); // policyProductProducer.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyProductService.createPolicyProductProducer(policyProductProducer); // PolicyProductAttachment policyProductAttachment = new // PolicyProductAttachment(); // // policyProductAttachment.setPolicyProductId(1); // policyProductService.findPolicyProductAttachment(2); // PolicyProductAttachment policyProductAttachment = new // PolicyProductAttachment(); // policyProductAttachment.setPolicyProductId(3); // policyProductAttachment.setCreditExpiredDate(DateTimeUtil.getCurrentDate()); // policyProductAttachment.setPoolCode("A"); // PolicyProduct policyProduct=new PolicyProduct(); // policyProduct.setPolicyProductId(2); // policyProduct.setStatus("A"); // policyProduct.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyProduct.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyProduct.setInitialEffectiveDate(DateTimeUtil.getCurrentDate()); // policyProduct.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyProduct.setCurrencyCode("fuc"); // policyProduct.setAccountCode("fuc"); // policyProduct.setBillPlanCode("001"); // policyProduct.setBillType("Y"); // policyProduct.setBillMode("Y"); // policyProduct.setPremiumRateType("Y"); // policyProduct.setBizSource("y"); // policyProduct.setBizType("Y"); // policyProduct.setEnrollPeriodDay(new BigDecimal("12")); // policyProduct.setRenewType("A"); // policyProduct.setRecordChangedBy("Mark"); // policyProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyProduct.setRecordStatus("A"); // updatePolicyProductService.updatePolicyProduct(policyProduct); // updatePolicyProductService.updatePolicyProductAttachment(policyProduct); // PolicyProductPlan policyProductPlan=new PolicyProductPlan(); // policyProductPlan.setPolicyProductPlanId(4); // policyProductPlan.setEffectiveDate(DateTimeUtil.getCurrentDate()); // policyProductPlan.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); // policyProductPlan.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyProductPlan.setRecordChangedBy("Mark22"); // policyProductPlan.setRecordChangedTime(DateTimeUtil.getCurrentDate()); // policyProductPlan.setRecordStatus("A"); // updatePolicyProductService.updatePolicyProductPlan(policyProductPlan); } @Autowired @Qualifier(value = "bizTransactionManager") BizTransactionManager bizTransactionManager; @Test public void createPolicyForTailormadeProductsTest1() throws Exception { Policy policy = inputManualData(); policyService.createPolicyForNB(policy); // BizTransaction bizTransaction = bizTransactionManager // .beginTransaction("test"); // memberService.addMembers(policy, InitialMember.generateMembers()); // bizTransactionManager.commit(bizTransaction); System.out.println("Policy ID: " + policy.getPolicyId()); } @Test public void createPolicyForPkg() throws Exception { Policy policy = inputDataPkgPolicy(); policyService.createPolicyForNB(policy); System.out.println("Policy ID: " + policy.getPolicyId()); // addMembers(policy); } private void addMembers(Policy policy) { BizTransaction bizTransaction = bizTransactionManager.beginTransaction("test"); memberService.addMembers(policy, InitialMembers.generateMembers()); bizTransactionManager.commit(bizTransaction); } private Policy inputDataPkgPolicy() { Policy policy = inputPolicy(); // product PolicyProduct policyProduct = new PolicyProduct(); policyProduct.setStatus("A"); policyProduct.setEffectiveDate(EffectiveDateAll); policyProduct.setInitialEffectiveDate(InitialEffectiveDateAll); policyProduct.setTransactionDate(TransactionDateAll); policyProduct.setCurrencyId(13); policyProduct.setAccountId(1); policyProduct.setBillPlanId(2); policyProduct.setBillType("A"); policyProduct.setBillMode("A"); policyProduct.setPremiumRateType("A"); policyProduct.setCommissionId(18); policyProduct.setBizSource("A"); policyProduct.setBizType("NER"); policyProduct.setEnrollPeriodDay(new BigDecimal(30)); // policyProduct.d(new BigDecimal("12")); policyProduct.setCollectOfficeId(1); policyProduct.setReinsuranceSchemeId(1); policyProduct.setRenewType("A"); policyProduct.setRecordStatus("A"); PolicyProductAttachment policyProductAttachment = new PolicyProductAttachment(); policyProductAttachment.setPolicyProductId(policyProduct.getPolicyProductId()); policyProductAttachment.setRlobId(1); policyProductAttachment.setCoverageTerrmMonth(1); policyProductAttachment.setPremiumTerrmMonth(1); policyProductAttachment.setSurrenderScaleId(1); policyProductAttachment.setCreditFacilityInd("A"); policyProductAttachment.setCreditExpiredDate(DateTimeUtil.getCurrentDate()); policyProductAttachment.setSuppressDailyEobInd("A"); policyProductAttachment.setSuppressCheckInd("A"); policyProductAttachment.setHivLimitAmt(new BigDecimal("1")); policyProductAttachment.setSpecialBizInd("A"); policyProductAttachment.setSpecialBizCode("A"); policyProductAttachment.setReduceSaLinkPolicyNo("A"); policyProductAttachment.setReduceSaLinkProductCode("A"); policyProductAttachment.setRetireeCoverageInd("A"); policyProductAttachment.setPoolCode("A"); policyProductAttachment.setRecordChangedBy("RanZhang"); policyProductAttachment.setRecordStatus("A"); policyProductAttachment.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProduct.setPolicyProductAttachment(policyProductAttachment); // producer policyProduct.setPolicyProductProducers(inputPolicyProductProducers(null)); List<PolicyProduct> policyProducts = new ArrayList<PolicyProduct>(); policyProducts.add(policyProduct); policy.setPolicyProducts(policyProducts); // pkg plan PolicyPkgScheme pkgPlan = new PolicyPkgScheme(); pkgPlan.setPkgProductId(301); pkgPlan.setPkgProductCode("CEB1A"); pkgPlan.setSchemeCode("001"); pkgPlan.setStatus("A"); List<PolicyPkgSchemeDetail> policyPkgPlanDetails = new ArrayList<PolicyPkgSchemeDetail>(); { PolicyPkgSchemeDetail policyPkgPlanDetail = new PolicyPkgSchemeDetail(); policyPkgPlanDetail.setPkgProductId(pkgPlan.getPkgProductId()); policyPkgPlanDetail.setProductId(4); policyPkgPlanDetail.setPlanCode(pkgPlan.getSchemeCode()); policyPkgPlanDetail.setBenefitPlanCode("L01"); policyPkgPlanDetail.setStatus("A"); policyPkgPlanDetails.add(policyPkgPlanDetail); } { PolicyPkgSchemeDetail policyPkgPlanDetail = new PolicyPkgSchemeDetail(); policyPkgPlanDetail.setPkgProductId(pkgPlan.getPkgProductId()); policyPkgPlanDetail.setProductId(32); policyPkgPlanDetail.setPlanCode(pkgPlan.getSchemeCode()); policyPkgPlanDetail.setBenefitPlanCode("L01"); policyPkgPlanDetail.setStatus("A"); policyPkgPlanDetails.add(policyPkgPlanDetail); } { PolicyPkgSchemeDetail policyPkgPlanDetail = new PolicyPkgSchemeDetail(); policyPkgPlanDetail.setPkgProductId(pkgPlan.getPkgProductId()); policyPkgPlanDetail.setProductId(99); policyPkgPlanDetail.setPlanCode(pkgPlan.getSchemeCode()); policyPkgPlanDetail.setBenefitPlanCode("L01"); policyPkgPlanDetail.setStatus("A"); policyPkgPlanDetails.add(policyPkgPlanDetail); } pkgPlan.setPolicyPkgSchemeDetails(policyPkgPlanDetails); List<PolicyPkgScheme> policyPkgPlans = new ArrayList<PolicyPkgScheme>(); policyPkgPlans.add(pkgPlan); policy.setPolicyPkgSchemes(policyPkgPlans); return policy; } @Test public void createPolicyForTailormadeProductsTest2() throws Exception { inputPolicyProductsFromStandardProducts(); } private List<PolicyProductAge> inputPolicyProductAges(Integer productId) { List<PolicyProductAge> policyProductAges = new ArrayList<PolicyProductAge>(); { PolicyProductAge policyProductAge = new PolicyProductAge(); policyProductAge.setProductId(productId); policyProductAge.setMembershipType("M"); policyProductAge.setMinAge(16); policyProductAge.setMaxEntryAge(64); policyProductAge.setMaxCoverAge(70); policyProductAge.setEffectiveDate(EffectiveDateAll); policyProductAge.setExpireDate(ExpireDateAll); policyProductAge.setTransactionDate(TransactionDateAll); policyProductAge.setStatus("A"); policyProductAge.setRecordChangedBy("Mark"); policyProductAge.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductAge.setRecordStatus("A"); policyProductAges.add(policyProductAge); } { PolicyProductAge policyProductAge = new PolicyProductAge(); policyProductAge.setProductId(productId); policyProductAge.setMembershipType("S"); policyProductAge.setMinAge(16); policyProductAge.setMaxEntryAge(64); policyProductAge.setMaxCoverAge(70); policyProductAge.setEffectiveDate(EffectiveDateAll); policyProductAge.setExpireDate(ExpireDateAll); policyProductAge.setTransactionDate(TransactionDateAll); policyProductAge.setStatus("A"); policyProductAge.setRecordChangedBy("Mark"); policyProductAge.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductAge.setRecordStatus("A"); policyProductAges.add(policyProductAge); } { PolicyProductAge policyProductAge = new PolicyProductAge(); policyProductAge.setProductId(productId); policyProductAge.setMembershipType("C"); policyProductAge.setMinAge(1); policyProductAge.setMaxEntryAge(18); policyProductAge.setMaxCoverAge(25); policyProductAge.setEffectiveDate(EffectiveDateAll); policyProductAge.setExpireDate(ExpireDateAll); policyProductAge.setTransactionDate(TransactionDateAll); policyProductAge.setStatus("A"); policyProductAge.setRecordChangedBy("Mark"); policyProductAge.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductAge.setRecordStatus("A"); policyProductAges.add(policyProductAge); } return policyProductAges; } private Policy inputManualData() { Policy policy = inputPolicy(); policy.setPolicyProducts(new ArrayList<PolicyProduct>()); policy.getPolicyProducts().add(inputProduct1()); policy.getPolicyProducts().add(inputProduct2()); policy.getPolicyProducts().add(inputProduct3()); //Logger.getLogger("ROOT").info(JsonUtil.toJson(policy)); return policy; } @Test public void jsonConversionTest() throws Exception { Policy policy = inputPolicy(); policy.setPolicyProducts(new ArrayList<PolicyProduct>()); policy.getPolicyProducts().add(inputProduct1()); policy.getPolicyProducts().add(inputProduct2()); policy.getPolicyProducts().add(inputProduct3()); String json = JsonUtil.toJson(policy); Logger.getLogger("ROOT").info(json); Logger.getLogger("ROOT").info(JsonUtil.toBean(json, Policy.class)); // policyService.createTailorMadePolicy(policy); } private PolicyProductPlan inputPlan(Integer productId, String benefitPlanCode, Integer premiumRateId, List<PolicyProductPremiumRate> policyProductPremiumRates, String membershipType, Integer benefitId) { PolicyProductPlan policyProductPlan = new PolicyProductPlan(); policyProductPlan.setProductId(productId); policyProductPlan.setBenefitPlanCode(benefitPlanCode); policyProductPlan.setBenefitPlanDesc("YRT 1980 VERSION"); policyProductPlan.setPremiumRateId(premiumRateId); policyProductPlan.setEffectiveDate(EffectiveDateAll); policyProductPlan.setExpireDate(ExpireDateAll); policyProductPlan.setTransactionDate(TransactionDateAll); policyProductPlan.setRecordChangedBy("Mark22"); policyProductPlan.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductPlan.setStatus("A"); policyProductPlan.setRecordStatus("A"); policyProductPlan.setPolicyProductPremiumRates(policyProductPremiumRates); policyProductPlan.setPolicyProductBenefits( inputPolicyProductBenefits(productId, benefitId, membershipType, benefitPlanCode)); return policyProductPlan; } private List<PolicyProductBenefit> inputPolicyProductBenefits(Integer productId, Integer benefitId, String membershipType, String benefitPlanCode) { List<PolicyProductBenefit> policyProductBenefits = new ArrayList<PolicyProductBenefit>(); PolicyProductBenefit policyProductBenefit = new PolicyProductBenefit(); policyProductBenefit.setProductId(productId); policyProductBenefit.setBenefitId(benefitId); policyProductBenefit.setMembershipType(membershipType); policyProductBenefit.setSaCalculateType(("M")); policyProductBenefit.setMaxSaAmt(new BigDecimal("999999")); policyProductBenefit.setMinSaAmt(new BigDecimal("1000")); policyProductBenefit.setFlatAmt(new BigDecimal("10000")); policyProductBenefit.setMultipleFactor(new BigDecimal("30")); policyProductBenefit.setBenefitPlanCode(benefitPlanCode); policyProductBenefit.setStatus("A"); policyProductBenefit.setEffectiveDate(EffectiveDateAll); policyProductBenefit.setExpireDate(ExpireDateAll); policyProductBenefit.setTransactionDate(TransactionDateAll); //PolicyProductBenefitSum List<PolicyProductBenefitSum> policyProductBenefitSums = new ArrayList<PolicyProductBenefitSum>(); PolicyProductBenefitSum policyProductBenefitSum = new PolicyProductBenefitSum(); policyProductBenefitSum.setPolicyProductBenefitId(policyProductBenefit.getPolicyProductBenefitId()); policyProductBenefitSum.setSumSequenceNo(1); policyProductBenefitSum.setEffectiveDate(DateTimeUtil.getCurrentDate()); policyProductBenefitSum.setExpireDate(DateUtil.parseYYYYMMDDDate("2099/12/31")); policyProductBenefitSum.setTransactionDate(DateTimeUtil.getCurrentDate()); policyProductBenefitSum.setMemberShipType("L"); policyProductBenefitSum.setSumCategory("L"); policyProductBenefitSum.setSumType("L"); policyProductBenefitSum.setSumTimeFrame("L"); policyProductBenefitSum.setFamilyShareInd("L"); policyProductBenefitSum.setSumSettingCode("L"); policyProductBenefitSum.setOutNetworkSumValue(1); policyProductBenefitSum.setInNetworkSumValue(1); policyProductBenefitSum.setShareInd("L"); policyProductBenefitSum.setStatus("L"); policyProductBenefitSums.add(policyProductBenefitSum); policyProductBenefit.setPolicyProductBenefitSums(policyProductBenefitSums); policyProductBenefits.add(policyProductBenefit); return policyProductBenefits; } private List<PolicyProductPremiumRate> inputPolicyProductPremiumRates(Integer productId) { List<PolicyProductPremiumRate> policyProductPremiumRates = new ArrayList<PolicyProductPremiumRate>(); PolicyProductPremiumRate policyProductPremiumRate1 = new PolicyProductPremiumRate(); policyProductPremiumRate1.setProductId(productId); policyProductPremiumRate1.setCoverageCode("MEM"); policyProductPremiumRate1.setModalPremium(new BigDecimal(10)); policyProductPremiumRate1.setUnitPerValue(new BigDecimal(1000)); policyProductPremiumRate1.setMemberContributionPct(new BigDecimal(0.5)); policyProductPremiumRate1.setMemberContributionAmt(new BigDecimal(50)); policyProductPremiumRate1.setEffectiveDate(EffectiveDateAll); policyProductPremiumRate1.setExpireDate(ExpireDateAll); policyProductPremiumRate1.setTransactionDate(TransactionDateAll); policyProductPremiumRate1.setStatus("A"); policyProductPremiumRate1.setAnnualizePremium(new BigDecimal("100")); policyProductPremiumRate1.setRecordChangedBy("Mark22"); policyProductPremiumRate1.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductPremiumRate1.setRecordStatus("A"); PolicyProductPremiumRate policyProductPremiumRate2 = new PolicyProductPremiumRate(); policyProductPremiumRate2.setProductId(productId); policyProductPremiumRate2.setCoverageCode("SPU"); policyProductPremiumRate2.setModalPremium(new BigDecimal(10)); policyProductPremiumRate2.setUnitPerValue(new BigDecimal(1000)); policyProductPremiumRate2.setMemberContributionPct(new BigDecimal(0.5)); policyProductPremiumRate2.setMemberContributionAmt(new BigDecimal(50)); policyProductPremiumRate2.setEffectiveDate(EffectiveDateAll); policyProductPremiumRate2.setExpireDate(ExpireDateAll); policyProductPremiumRate2.setTransactionDate(TransactionDateAll); policyProductPremiumRate2.setStatus("A"); policyProductPremiumRate2.setAnnualizePremium(new BigDecimal("100")); policyProductPremiumRate2.setRecordChangedBy("Mark22"); policyProductPremiumRate2.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductPremiumRate2.setRecordStatus("A"); policyProductPremiumRates.add(policyProductPremiumRate1); policyProductPremiumRates.add(policyProductPremiumRate2); return policyProductPremiumRates; } private PolicyProduct inputProduct1() { PolicyProduct policyProduct = new PolicyProduct(); int productId = 4; policyProduct.setProductId(productId); policyProduct.setStatus("A"); policyProduct.setEffectiveDate(EffectiveDateAll); policyProduct.setExpireDate(ExpireDateAll); policyProduct.setTransactionDate(TransactionDateAll); policyProduct.setTransactionDate(DateTimeUtil.getCurrentDate()); policyProduct.setInitialEffectiveDate(TransactionDateAll); policyProduct.setCurrencyId(13); policyProduct.setAccountId(1); policyProduct.setBillPlanId(2); policyProduct.setBillType("A"); policyProduct.setBillMode("A"); policyProduct.setPremiumRateType("A"); policyProduct.setCommissionId(18); policyProduct.setBizSource("A"); policyProduct.setBizType("NER"); policyProduct.setEnrollPeriodDay(new BigDecimal(30)); // policyProduct.setEnrollPeriodDay(new BigDecimal("12")); policyProduct.setCollectOfficeId(1); policyProduct.setReinsuranceSchemeId(1); policyProduct.setRenewType("A"); policyProduct.setRecordChangedBy("Mark"); policyProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProduct.setRecordStatus("A"); List<PolicyProductPlan> policyProductPlans = new ArrayList<PolicyProductPlan>(); policyProductPlans.add(inputPlan(productId, "001", 378, inputPolicyProductPremiumRates(4), "M", productId)); policyProductPlans.add(inputPlan(productId, "002", 378, inputPolicyProductPremiumRates(4), "M", productId)); policyProductPlans.add(inputPlan(productId, "003", 378, inputPolicyProductPremiumRates(4), "M", productId)); policyProduct.setPolicyProductPlans(policyProductPlans); policyProduct.setPolicyProductAges(inputPolicyProductAges(productId)); policyProduct.setPolicyProductProducers(inputPolicyProductProducers(productId)); PolicyProductAttachment policyProductAttachment = new PolicyProductAttachment(); // policyProductAttachment.setRLOBCode(1); policyProductAttachment.setRlobId(1); policyProductAttachment.setCoverageTerrmMonth(1); // policyProductAttachment.setStatus("A"); policyProductAttachment.setRetireeCoverageInd("Y"); policyProduct.setPolicyProductAttachment(policyProductAttachment); return policyProduct; } private PolicyProduct inputProduct2() { PolicyProduct policyProduct = new PolicyProduct(); int productId = 30; policyProduct.setProductId(productId); policyProduct.setStatus("A"); policyProduct.setEffectiveDate(EffectiveDateAll); policyProduct.setExpireDate(ExpireDateAll); policyProduct.setTransactionDate(TransactionDateAll); policyProduct.setInitialEffectiveDate(TransactionDateAll); policyProduct.setTransactionDate(DateTimeUtil.getCurrentDate()); policyProduct.setCurrencyId(13); policyProduct.setAccountId(1); policyProduct.setBillPlanId(2); policyProduct.setBillType("A"); policyProduct.setBillMode("A"); policyProduct.setPremiumRateType("A"); policyProduct.setBizSource("A"); policyProduct.setBizType("NER"); policyProduct.setEnrollPeriodDay(new BigDecimal(30)); policyProduct.setCommissionId(18); policyProduct.setCollectOfficeId(1); policyProduct.setReinsuranceSchemeId(1); // policyProduct.setEnrollPeriodDay(new BigDecimal("12")); policyProduct.setRenewType("A"); policyProduct.setRecordChangedBy("Mark"); policyProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProduct.setRecordStatus("A"); List<PolicyProductPlan> policyProductPlans = new ArrayList<PolicyProductPlan>(); policyProductPlans .add(inputPlan(productId, "001", 379, inputPolicyProductPremiumRates(productId), "M", 637)); policyProductPlans .add(inputPlan(productId, "002", 379, inputPolicyProductPremiumRates(productId), "M", 637)); policyProductPlans .add(inputPlan(productId, "003", 379, inputPolicyProductPremiumRates(productId), "M", 637)); policyProduct.setPolicyProductPlans(policyProductPlans); policyProduct.setPolicyProductAges(inputPolicyProductAges(productId)); policyProduct.setPolicyProductProducers(inputPolicyProductProducers(productId)); PolicyProductAttachment policyProductAttachment = new PolicyProductAttachment(); // policyProductAttachment.setRLOBCode(1); policyProductAttachment.setRlobId(1); policyProductAttachment.setCoverageTerrmMonth(1); policyProductAttachment.setRetireeCoverageInd("Y"); policyProduct.setPolicyProductAttachment(policyProductAttachment); return policyProduct; } private PolicyProduct inputProduct3() { PolicyProduct policyProduct = new PolicyProduct(); int productId = 99; policyProduct.setProductId(productId); policyProduct.setStatus("A"); policyProduct.setEffectiveDate(EffectiveDateAll); policyProduct.setExpireDate(ExpireDateAll); policyProduct.setTransactionDate(TransactionDateAll); policyProduct.setInitialEffectiveDate(TransactionDateAll); policyProduct.setTransactionDate(DateTimeUtil.getCurrentDate()); policyProduct.setCurrencyId(13); policyProduct.setAccountId(1); policyProduct.setBillPlanId(2); policyProduct.setBillType("A"); policyProduct.setBillMode("A"); policyProduct.setPremiumRateType("A"); policyProduct.setBizSource("A"); policyProduct.setBizType("NER"); policyProduct.setEnrollPeriodDay(new BigDecimal(30)); policyProduct.setCommissionId(18); policyProduct.setCollectOfficeId(1); policyProduct.setReinsuranceSchemeId(1); // policyProduct.setEnrollPeriodDay(new BigDecimal("12")); policyProduct.setRenewType("A"); policyProduct.setRecordChangedBy("Mark"); policyProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProduct.setRecordStatus("A"); List<PolicyProductPlan> policyProductPlans = new ArrayList<PolicyProductPlan>(); policyProductPlans.add(inputPlan(productId, "001", null, inputPolicyProductPremiumRates(4), "M", 491)); policyProductPlans.add(inputPlan(productId, "002", null, inputPolicyProductPremiumRates(4), "M", 491)); policyProductPlans.add(inputPlan(productId, "003", null, inputPolicyProductPremiumRates(4), "M", 491)); policyProduct.setPolicyProductPlans(policyProductPlans); policyProduct.setPolicyProductAges(inputPolicyProductAges(productId)); policyProduct.setPolicyProductProducers(inputPolicyProductProducers(productId)); PolicyProductAttachment policyProductAttachment = new PolicyProductAttachment(); // policyProductAttachment.setRLOBCode(1); policyProductAttachment.setRlobId(1); policyProductAttachment.setCoverageTerrmMonth(1); policyProductAttachment.setRetireeCoverageInd("Y"); policyProduct.setPolicyProductAttachment(policyProductAttachment); return policyProduct; } private Policy inputPolicy() { Policy policy = new Policy(); policy.setPolicyNo(genPolicyNO()); policy.setPolicyOwnerId(1); policy.setPolicyDesc("Test Policy for Pkg product for Ran"); policy.setCompanyId(1); policy.setInitialEffectiveDate(InitialEffectiveDateAll); policy.setEffectiveDate(EffectiveDateAll); policy.setExpireDate(ExpireDateAll); policy.setTransactionDate(TransactionDateAll); policy.setStatus("A"); policy.setAnniversaryDate(DateTimeUtil.getCurrentDate()); policy.setNoOfMember(1); policy.setNoOfDependent(1); policy.setTeamId(01); policy.setServiceAeUserId(1); policy.setServicingOfficerUserId(2); policy.setAgeRefInd("A"); policy.setAgeCalculateBase("R"); policy.setAgencyForceClaimInd("N"); policy.setAgencyForcePremiumInd("N"); policy.setWaitingPeriod("A"); policy.setEnrollPeriodDays(3); policy.setAutoRenewInd("N"); policy.setRenewalDays(3); policy.setRecordStatus("A"); policy.setClaimOfficerUserId(3); policy.setBillingOfficerUserId(4); policy.setRecordChangedBy("RanZhang"); policy.setRecordChangedTime(DateTimeUtil.getCurrentDate()); PolicyAttachment policyAttachment = new PolicyAttachment(); policyAttachment.setPolicyType("GL/GHS"); policyAttachment.setMmcrType("A"); policyAttachment.setMmcrCycleDay(1); policyAttachment.setMmcrSort("A"); policyAttachment.setBatchBillCycleDay(1); policyAttachment.setBatchAdjBillCycleDay(1); policyAttachment.setBatchBillMode("4"); policyAttachment.setBillWithMemberListInd("5"); policyAttachment.setSuppressBillPrinting("N"); policyAttachment.setSuppressBillInd("N"); policyAttachment.setSuppressReceiptInd("N"); policyAttachment.setAnnualizeClaimsLimitsInd("P"); policyAttachment.setClaimPayeeType("A"); policyAttachment.setExamptHoldClaimPremium(""); policyAttachment.setExemptHoldClaimShortfall("A"); policyAttachment.setMonthlyEobInd("A"); policyAttachment.setMonthlyEobCycleDay(1); policyAttachment.setClaimAutoPayControlReport("A"); policyAttachment.setAnnualizeClaimsLimitsInd("A"); policyAttachment.setClaimAutoPayControlReport("A"); policyAttachment.setRecordChangedBy("RanZhang"); policyAttachment.setRecordStatus("A"); policyAttachment.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policy.setPolicyAttachment(policyAttachment); return policy; } private List<PolicyProductProducer> inputPolicyProductProducers(Integer productId) { List<PolicyProductProducer> policyProductProducers = new ArrayList<PolicyProductProducer>(); // policyProductProducer.setPolicyProductProducerId(50); { PolicyProductProducer policyProductProducer = new PolicyProductProducer(); policyProductProducer.setProductId(productId); policyProductProducer.setProducerId(1); policyProductProducer.setEffectiveDate(EffectiveDateAll); policyProductProducer.setExpireDate(ExpireDateAll); policyProductProducer.setTransactionDate(TransactionDateAll); policyProductProducer.setProducerSharePct(new BigDecimal("0.4")); policyProductProducer.setOriginalAgencyId(1); policyProductProducer.setSevicingProducerInd("1"); policyProductProducer.setReceiveCorrespondenceInd("1"); policyProductProducer.setStatus("A"); policyProductProducer.setRecordStatus("A"); policyProductProducer.setRecordChangedBy("RanZhang"); policyProductProducer.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductProducers.add(policyProductProducer); } { PolicyProductProducer policyProductProducer = new PolicyProductProducer(); policyProductProducer.setProductId(productId); policyProductProducer.setProducerId(2); policyProductProducer.setEffectiveDate(EffectiveDateAll); policyProductProducer.setExpireDate(ExpireDateAll); policyProductProducer.setTransactionDate(TransactionDateAll); policyProductProducer.setProducerSharePct(new BigDecimal("0.6")); policyProductProducer.setOriginalAgencyId(1); policyProductProducer.setSevicingProducerInd("1"); policyProductProducer.setReceiveCorrespondenceInd("1"); policyProductProducer.setStatus("A"); policyProductProducer.setRecordStatus("A"); policyProductProducer.setRecordChangedBy("RanZhang"); policyProductProducer.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProductProducers.add(policyProductProducer); } return policyProductProducers; } private List<PolicyProduct> inputPolicyProductsFromStandardProducts() { // Policy policy = inputPolicy(); Product product = productService.findProductDetail(4); log(product.getProductCode()); productService.findProductDetail(30); productService.findProductDetail(99); return null; } private void log(String str) { System.out.println(str); } private PolicyProduct inputProduct(Product product) { PolicyProduct policyProduct = new PolicyProduct(); int productId = product.getProductId(); policyProduct.setProductId(productId); policyProduct.setStatus("A"); policyProduct.setEffectiveDate(EffectiveDateAll); policyProduct.setExpireDate(ExpireDateAll); policyProduct.setTransactionDate(TransactionDateAll); policyProduct.setTransactionDate(DateTimeUtil.getCurrentDate()); // policyProduct.setCurrencyId(inputCurrency()); // policyProduct.setAccountId(inputAccountCode()); // policyProduct.setBillPlanId(inputBillPlan()); policyProduct.setBillType("A"); policyProduct.setBillMode("A"); policyProduct.setPremiumRateType("A"); policyProduct.setCommissionId(18); policyProduct.setBizSource("A"); policyProduct.setBizType("NER"); policyProduct.setEnrollPeriodDay(new BigDecimal(30)); // policyProduct.setEnrollPeriodDay(new BigDecimal("12")); policyProduct.setRenewType("A"); // policyProduct.setRecordChangedBy("Mark"); // policyProduct.setRecordChangedTime(DateTimeUtil.getCurrentDate()); policyProduct.setRecordStatus("A"); policyProduct.setPolicyProductPlans(inputPlans(product)); policyProduct.setPolicyProductAges(inputPolicyProductAges(product)); policyProduct.setPolicyProductProducers(inputPolicyProductProducers(productId)); PolicyProductAttachment policyProductAttachment = new PolicyProductAttachment(); // policyProductAttachment.setRLOBCode(1); policyProductAttachment.setRlobId(1); policyProductAttachment.setCoverageTerrmMonth(1); // policyProductAttachment.setStatus("A"); policyProductAttachment.setRetireeCoverageInd("Y"); policyProduct.setPolicyProductAttachment(policyProductAttachment); return policyProduct; } private List<PolicyProductAge> inputPolicyProductAges(Product product) { // TODO Auto-generated method stub return null; } private List<PolicyProductPlan> inputPlans(Product product) { List<PolicyProductPlan> list = new ArrayList<PolicyProductPlan>(); for (ProductPlan productPlan : product.getProductPlans()) { PolicyProductPlan PolicyProductPlan = new PolicyProductPlan(); list.add(PolicyProductPlan); } return null; } private String genPolicyNO() { Random r = new Random(); Long a = r.nextLong(); return String.valueOf(a).substring(1, 11); } private String inputCurrency() { // List<LookupBean> a = lookupAppService.findLookupsByType(""); CurrencyBean a = currencyAppService.findCurrency("001"); return a.getCurrencyCode(); } @Autowired @Qualifier(value = "accountCodeAppService") private AccountCodeAppService accountCodeAppService; private String inputAccountCode() { // List<LookupBean> a = lookupAppService.findLookupsByType(""); AccountBean a = accountCodeAppService.findAccountByAccountCode("00000"); return a.getAccountCode(); } @Autowired @Qualifier(value = "billPlanAppService") private BillPlanAppService billPlanAppService; private String inputBillPlan() { // List<LookupBean> a = lookupAppService.findLookupsByType(""); BillPlanBean a = billPlanAppService.findBillPlanByCode("00000"); return a.getBillPlanCode(); } @Test public void testUpdatePolicyBasic() { Policy policy = policyService.findPolicyById(84); policy.setEffectiveDate(EffectiveDateAll); updatePolicyService.updatePolicy(policy); } @Autowired @Qualifier(value = "organizationService") OrganizationService organizationService; @Transactional @Test public void testUpdateAddress() { Policy policy = policyService.findPolicyById(84); policy.setEffectiveDate(EffectiveDateAll); Integer organizationPartyId = 23; Organization org = organizationService.findOrganizationDetailById(organizationPartyId); List<Address> addresses = org.getAddresses(); Address address = addresses.get(0); if (StringUtils.isBlank(address.getAddress1())) { address.setAddress1("dongfengdonglu"); } address.setAddress1(address.getAddress1() + "1"); organizationService.updateAddress(address); } @Test public void termintePolicy() { Date terminateDate = DateUtil.parseYYYYMMDDDate("2016/03/10"); this.terminatePolicyService.terminatePolicy("3741180233", terminateDate); } @Test public void findPolicyProductCode() { Date terminateDate = DateUtil.parseYYYYMMDDDate("2016/03/10"); System.out.println("~~~~~~~~~~~~~~~~~~:" + this.policyService.findProductCodes(1, terminateDate).size()); } @Test public void findBenefitPlanCodes() { Date terminateDate = DateUtil.parseYYYYMMDDDate("2016/03/09"); System.out .println("~~~~~~~~~~~~~~~~~~:" + this.policyService.findBenefitPlanCodes(1, terminateDate).get(0)); } @Test public void findPolicyProductHist() { Date terminateDate = DateUtil.parseYYYYMMDDDate("2016/03/09"); PolicyProduct a = this.policyProductRepository.findPolicyProductByProductIdAndPolicyIdAndRangDate(1, 4, terminateDate); System.out.println("~~~~~~~~~~~~~~~~~~:" + a.getStatus()); } }