@Test public void updatePoliciesNotFoundTest() throws Exception { UpdatePolicyDetails policiesDetails = getUpdatePolicyDetails(); when(policyRepository.existsById(policiesDetails.getPolicyId())).thenReturn(false); assertThat(policyService.updatePolicies(policiesDetails), is("Policy does not exits!!")); }
@Override public String updatePolicies(final UpdatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(isPolicyExits) { Policy policyToUpdate = policyRepository.findById(policyDetails.getPolicyId()).get(); policyToUpdate.setPolicyDesc(policyDetails.getPolicyDesc()); policyToUpdate.setPolicyUrl(policyDetails.getPolicyUrl()); policyToUpdate.setPolicyVersion(policyDetails.getPolicyVersion()); policyToUpdate.setResolution(policyDetails.getResolution()); policyToUpdate.setModifiedDate(new Date()); policyRepository.save(policyToUpdate); return "Updated Successfully"; } else { return "Policy does not exits!!"; } }
PolicyServiceImpl implements PolicyService, Constants { @Override public String updatePolicies(final UpdatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(isPolicyExits) { Policy policyToUpdate = policyRepository.findById(policyDetails.getPolicyId()).get(); policyToUpdate.setPolicyDesc(policyDetails.getPolicyDesc()); policyToUpdate.setPolicyUrl(policyDetails.getPolicyUrl()); policyToUpdate.setPolicyVersion(policyDetails.getPolicyVersion()); policyToUpdate.setResolution(policyDetails.getResolution()); policyToUpdate.setModifiedDate(new Date()); policyRepository.save(policyToUpdate); return "Updated Successfully"; } else { return "Policy does not exits!!"; } } }
PolicyServiceImpl implements PolicyService, Constants { @Override public String updatePolicies(final UpdatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(isPolicyExits) { Policy policyToUpdate = policyRepository.findById(policyDetails.getPolicyId()).get(); policyToUpdate.setPolicyDesc(policyDetails.getPolicyDesc()); policyToUpdate.setPolicyUrl(policyDetails.getPolicyUrl()); policyToUpdate.setPolicyVersion(policyDetails.getPolicyVersion()); policyToUpdate.setResolution(policyDetails.getResolution()); policyToUpdate.setModifiedDate(new Date()); policyRepository.save(policyToUpdate); return "Updated Successfully"; } else { return "Policy does not exits!!"; } }  }
PolicyServiceImpl implements PolicyService, Constants { @Override public String updatePolicies(final UpdatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(isPolicyExits) { Policy policyToUpdate = policyRepository.findById(policyDetails.getPolicyId()).get(); policyToUpdate.setPolicyDesc(policyDetails.getPolicyDesc()); policyToUpdate.setPolicyUrl(policyDetails.getPolicyUrl()); policyToUpdate.setPolicyVersion(policyDetails.getPolicyVersion()); policyToUpdate.setResolution(policyDetails.getResolution()); policyToUpdate.setModifiedDate(new Date()); policyRepository.save(policyToUpdate); return "Updated Successfully"; } else { return "Policy does not 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 updatePolicies(final UpdatePolicyDetails policyDetails) throws Exception { boolean isPolicyExits = policyRepository.existsById(policyDetails.getPolicyId()); if(isPolicyExits) { Policy policyToUpdate = policyRepository.findById(policyDetails.getPolicyId()).get(); policyToUpdate.setPolicyDesc(policyDetails.getPolicyDesc()); policyToUpdate.setPolicyUrl(policyDetails.getPolicyUrl()); policyToUpdate.setPolicyVersion(policyDetails.getPolicyVersion()); policyToUpdate.setResolution(policyDetails.getResolution()); policyToUpdate.setModifiedDate(new Date()); policyRepository.save(policyToUpdate); return "Updated Successfully"; } else { return "Policy does not 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);  }