@Test public void createPoliciesNotFoundTest() throws Exception { CreatePolicyDetails policyDetails = getCreatePolicyDetails(); when(policyRepository.existsById(policyDetails.getPolicyId())).thenReturn(true); assertThat(policyService.createPolicies(policyDetails), is("Policy already exits!!")); }
@Override public String createPolicies(final CreatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(!isPolicyExits) { Date date = new Date(); Policy newPolicy = new Policy(); newPolicy.setPolicyId(policyDetails.getPolicyId()); newPolicy.setPolicyName(policyDetails.getPolicyName()); newPolicy.setPolicyDesc(policyDetails.getPolicyDesc()); newPolicy.setPolicyUrl(policyDetails.getPolicyUrl()); newPolicy.setPolicyVersion(policyDetails.getPolicyVersion()); newPolicy.setResolution(policyDetails.getResolution()); newPolicy.setCreatedDate(date); newPolicy.setModifiedDate(date); policyRepository.save(newPolicy); return "Created Successfully"; } else { return "Policy already exits!!"; } }
PolicyServiceImpl implements PolicyService, Constants { @Override public String createPolicies(final CreatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(!isPolicyExits) { Date date = new Date(); Policy newPolicy = new Policy(); newPolicy.setPolicyId(policyDetails.getPolicyId()); newPolicy.setPolicyName(policyDetails.getPolicyName()); newPolicy.setPolicyDesc(policyDetails.getPolicyDesc()); newPolicy.setPolicyUrl(policyDetails.getPolicyUrl()); newPolicy.setPolicyVersion(policyDetails.getPolicyVersion()); newPolicy.setResolution(policyDetails.getResolution()); newPolicy.setCreatedDate(date); newPolicy.setModifiedDate(date); policyRepository.save(newPolicy); return "Created Successfully"; } else { return "Policy already exits!!"; } } }
PolicyServiceImpl implements PolicyService, Constants { @Override public String createPolicies(final CreatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(!isPolicyExits) { Date date = new Date(); Policy newPolicy = new Policy(); newPolicy.setPolicyId(policyDetails.getPolicyId()); newPolicy.setPolicyName(policyDetails.getPolicyName()); newPolicy.setPolicyDesc(policyDetails.getPolicyDesc()); newPolicy.setPolicyUrl(policyDetails.getPolicyUrl()); newPolicy.setPolicyVersion(policyDetails.getPolicyVersion()); newPolicy.setResolution(policyDetails.getResolution()); newPolicy.setCreatedDate(date); newPolicy.setModifiedDate(date); policyRepository.save(newPolicy); return "Created Successfully"; } else { return "Policy already exits!!"; } }  }
PolicyServiceImpl implements PolicyService, Constants { @Override public String createPolicies(final CreatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(!isPolicyExits) { Date date = new Date(); Policy newPolicy = new Policy(); newPolicy.setPolicyId(policyDetails.getPolicyId()); newPolicy.setPolicyName(policyDetails.getPolicyName()); newPolicy.setPolicyDesc(policyDetails.getPolicyDesc()); newPolicy.setPolicyUrl(policyDetails.getPolicyUrl()); newPolicy.setPolicyVersion(policyDetails.getPolicyVersion()); newPolicy.setResolution(policyDetails.getResolution()); newPolicy.setCreatedDate(date); newPolicy.setModifiedDate(date); policyRepository.save(newPolicy); return "Created Successfully"; } else { return "Policy already exits!!"; } }  @Override Page<Object[]> getPolicies(final int page, final int size, final String searchTerm); @Override Collection<String> getAllPolicyIds(); @Override String updatePolicies(final UpdatePolicyDetails policyDetails); @Override String createPolicies(final CreatePolicyDetails policyDetails); @Override Policy getByPolicyId(String policyId); }
PolicyServiceImpl implements PolicyService, Constants { @Override public String createPolicies(final CreatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(!isPolicyExits) { Date date = new Date(); Policy newPolicy = new Policy(); newPolicy.setPolicyId(policyDetails.getPolicyId()); newPolicy.setPolicyName(policyDetails.getPolicyName()); newPolicy.setPolicyDesc(policyDetails.getPolicyDesc()); newPolicy.setPolicyUrl(policyDetails.getPolicyUrl()); newPolicy.setPolicyVersion(policyDetails.getPolicyVersion()); newPolicy.setResolution(policyDetails.getResolution()); newPolicy.setCreatedDate(date); newPolicy.setModifiedDate(date); policyRepository.save(newPolicy); return "Created Successfully"; } else { return "Policy already exits!!"; } }  @Override Page<Object[]> getPolicies(final int page, final int size, final String searchTerm); @Override Collection<String> getAllPolicyIds(); @Override String updatePolicies(final UpdatePolicyDetails policyDetails); @Override String createPolicies(final CreatePolicyDetails policyDetails); @Override Policy getByPolicyId(String policyId);  }