policy/src/main/java/com/stackroute.pie/service/PolicyServiceImpl.java
//Method for adding the policy for insurer
Method for adding the policy for insurer
Method for adding the policy for insurer
@Override
    public Policy addPolicy(Policy policy) throws PolicyAlreadyExistsException {
        if(policyRepository.existsByPolicyIdAndInsurerName(policy.getPolicyId(),policy.getInsurerName())) {
            new PolicyAlreadyExistsException();
        }
        Policy policy1 = new Policy(policy.getInsurerName(),policy.getInsurerLicense(),policy.getPolicyName(),
                policy.getPolicyId(),policy.getMinAge(),policy.getMaxAge(),policy.getMinSumInsured(),
                policy.getMaxSumInsured(), policy.getPolicyDescription(), policy.getPolicyType(),
                policy.getGenderAvail(), policy.getWaitingPeriod(),policy.getPolicyTerm(), new ArrayList<>());
        policyRepository.save(policy1);
        Policy policy2 = policyRepository.findByUniqueId(policy1.getUniqueId()).get();
        System.out.println(policy2);
        kafkaTemplate.send("policy_added",policy2);
        return policy2;
    }
@ Override public Policy addPolicy ( Policy policy ) throws PolicyAlreadyExistsException { if ( policyRepository . existsByPolicyIdAndInsurerName ( policy . getPolicyId ( ) , policy . getInsurerName ( ) ) ) { new PolicyAlreadyExistsException ( ) ; } Policy policy1 = new Policy ( policy . getInsurerName ( ) , policy . getInsurerLicense ( ) , policy . getPolicyName ( ) , policy . getPolicyId ( ) , policy . getMinAge ( ) , policy . getMaxAge ( ) , policy . getMinSumInsured ( ) , policy . getMaxSumInsured ( ) , policy . getPolicyDescription ( ) , policy . getPolicyType ( ) , policy . getGenderAvail ( ) , policy . getWaitingPeriod ( ) , policy . getPolicyTerm ( ) , new ArrayList < > ( ) ) ; policyRepository . save ( policy1 ) ; Policy policy2 = policyRepository . findByUniqueId ( policy1 . getUniqueId ( ) ) . get ( ) ; System . out . println ( policy2 ) ; kafkaTemplate . send ( "policy_added" , policy2 ) ; return policy2 ; }
Method for adding the policy for insurer
Method for adding the policy for insurer