diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java index 67c3f9ad9b..2bcb22b33d 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java @@ -583,7 +583,18 @@ public APIKeyGenerateResponseDto generateAPIKey(String partnerId, APIKeyGenerate throw new PartnerManagerServiceException(ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorCode(), ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorMessage()); } - AuthPolicy validPolicy = authPolicyRepository.findByPolicyName(requestDto.getPolicyName()); + Optional partnerFromDb = partnerRepository.findById(partnerId); + if (partnerFromDb.isEmpty()) { + auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); + throw new PartnerManagerServiceException(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode(), + ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorMessage()); + } + if (!partnerFromDb.get().getIsActive()) { + auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); + throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(), + ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage()); + } + AuthPolicy validPolicy = authPolicyRepository.findByPolicyGroupIdAndName(partnerFromDb.get().getPolicyGroupId(),requestDto.getPolicyName()); if(validPolicy == null) { auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); throw new PartnerManagerServiceException(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode(), @@ -597,17 +608,6 @@ public APIKeyGenerateResponseDto generateAPIKey(String partnerId, APIKeyGenerate throw new PartnerManagerServiceException(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode(), ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorMessage()); } - Optional partnerFromDb = partnerRepository.findById(partnerId); - if (partnerFromDb.isEmpty()) { - auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); - throw new PartnerManagerServiceException(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode(), - ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorMessage()); - } - if (!partnerFromDb.get().getIsActive()) { - auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); - throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(), - ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage()); - } PartnerPolicy policyByLabel = partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel( partnerFromDb.get().getId(), validPolicy.getId(), requestDto.getLabel()); if(policyByLabel != null) { diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java index 78feaf5f24..562583d6e9 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java @@ -518,7 +518,7 @@ public PartnerResponse updatePartnerDetails(PartnerUpdateDto partnerUpdateReques } private AuthPolicy validatePolicyGroupAndPolicy(String policyGroupId, String policyName) { - AuthPolicy authPolicyFromDb = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, policyName); + AuthPolicy authPolicyFromDb = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, policyName); if (authPolicyFromDb == null) { auditUtil.setAuditRequestDto(PartnerServiceAuditEnum.SUBMIT_API_REQUEST_FAILURE, policyName, "policyName"); throw new PartnerServiceException(ErrorCode.POLICY_GROUP_POLICY_NOT_EXISTS.getErrorCode(), diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java index 40b26308dc..671e76e244 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java @@ -948,10 +948,11 @@ public void approveRejectPartnerPolicyMappingTest05() { public void generateAPIKeyTest() { APIKeyGenerateRequestDto request = new APIKeyGenerateRequestDto(); request.setLabel("unique"); - request.setPolicyName("policyName"); - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + request.setPolicyName("policyName"); + Optional newPartner = Optional.of(getPartner()); + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(newPartner.get().getPolicyGroupId(),request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.of(getPartner())); Mockito.when(partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel("partner","234","unique")).thenReturn(getPartnerPolicy()); Map response = new HashMap<>(); response.put("response", getCertResponse()); @@ -964,39 +965,36 @@ public void generateAPIKeyTest() { }catch (PartnerManagerServiceException e) { assertTrue(e.getErrorCode().equals(ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorCode())); } - - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(null); + Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.empty()); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(Collections.emptyList()); + Optional partner = Optional.of(getPartner()); + partner.get().setIsActive(false); + Mockito.when(partnerRepository.findById("partner")).thenReturn(partner); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.empty()); + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(request.getPolicyName(),newPartner.get().getPolicyGroupId())).thenReturn(null); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode())); - } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Optional partner = Optional.of(getPartner()); - partner.get().setIsActive(false); - Mockito.when(partnerRepository.findById("partner")).thenReturn(partner); + assertTrue(e.getErrorCode().equals(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode())); + } + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(newPartner.get().getPolicyGroupId(),request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(Collections.emptyList()); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(request.getPolicyName(),newPartner.get().getPolicyGroupId())).thenReturn(getAuthPolicies().get(0)); Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.of(getPartner())); Mockito.when(partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel("123456","234","unique")).thenReturn(getPartnerPolicy()); diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java index e67bbb27d5..65f8edc990 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java @@ -789,7 +789,7 @@ public void mapPartnerPolicyCredentialType_001() { Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); Mockito.when(authPolicyRepository.findById("12345")).thenReturn(Optional.of(createAuthPolicy())); Mockito.when(authPolicyRepository - .findByPolicyGroupAndName(Mockito.anyString(), Mockito.anyString())).thenReturn(createAuthPolicy()); + .findByPolicyGroupIdAndName(Mockito.anyString(), Mockito.anyString())).thenReturn(createAuthPolicy()); pserviceImpl.mapPartnerPolicyCredentialType("euin", "12345", "12345"); } @@ -879,7 +879,7 @@ public void requestForPolicyMappingTest() { Optional partner = Optional.of(createPartner(true)); partner.get().setPartnerTypeCode("Auth_Partner"); Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(createAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(createAuthPolicy()); Mockito.when(partnerPolicyRequestRepository.findByPartnerIdAndPolicyId("12345","123")).thenReturn(List.of(createPartnerPolicyRequest("approved"))); pserviceImpl.requestForPolicyMapping(request, "12345"); partner.get().setPolicyGroupId(null); @@ -921,7 +921,7 @@ public void requestForPolicyMappingTest() { } partner.get().setIsActive(true); Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(null); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(null); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -929,7 +929,7 @@ public void requestForPolicyMappingTest() { } AuthPolicy authPolicy = createAuthPolicy(); authPolicy.setIsActive(false); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -938,7 +938,7 @@ public void requestForPolicyMappingTest() { authPolicy = createAuthPolicy(); authPolicy.setIsActive(true); authPolicy.setValidToDate(LocalDateTime.now().minusMonths(3)); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -947,7 +947,7 @@ public void requestForPolicyMappingTest() { authPolicy = createAuthPolicy(); authPolicy.setIsActive(true); authPolicy.getPolicyGroup().setIsActive(false); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -1264,4 +1264,4 @@ private String caCertResponse() { } -} \ No newline at end of file +} diff --git a/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java b/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java index 65344ae87b..1447139201 100644 --- a/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java @@ -13,7 +13,7 @@ public interface AuthPolicyRepository extends JpaRepository{ @Query(value = "select * from auth_policy ap where ap.policy_group_id=?1 and ap.name = ?2",nativeQuery = true) - AuthPolicy findByPolicyGroupAndName(String policyGroupId, String name); + AuthPolicy findByPolicyGroupIdAndName(String policyGroupId, String name); @Query(value = "select * from auth_policy ap where ap.policy_group_id=?1 and ap.id = ?2",nativeQuery = true) AuthPolicy findByPolicyGroupAndId(String policyGroupId, String policyId); diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java index aac9f31e14..95ab0c591c 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java @@ -294,7 +294,7 @@ public PolicyCreateResponseDto updatePolicies(PolicyUpdateRequestDto requestDto, throw new PolicyManagementServiceException(ErrorMessages.PUBLISHED_POLICY_NOT_UPDATED.getErrorCode(), ErrorMessages.PUBLISHED_POLICY_NOT_UPDATED.getErrorMessage()); } - AuthPolicy mappedPolicy = authPolicyRepository.findByPolicyGroupAndName(policyGroup.getId(), + AuthPolicy mappedPolicy = authPolicyRepository.findByPolicyGroupIdAndName(policyGroup.getId(), requestDto.getName()); if (mappedPolicy != null && !mappedPolicy.getName().equals(authPolicy.getName())) { auditUtil.setAuditRequestDto(PolicyManageEnum.UPDATE_POLICY_FAILURE, requestDto.getName(), "policyName"); @@ -354,7 +354,7 @@ private PolicyGroupCreateResponseDto savePolicyGroup(PolicyGroup policyGroup) { * @return */ private void validateAuthPolicyName(String policyGroupId, String auth_policy_name) { - AuthPolicy auth_policy_by_name = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, auth_policy_name); + AuthPolicy auth_policy_by_name = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, auth_policy_name); if (auth_policy_by_name != null) { auditUtil.setAuditRequestDto(PolicyManageEnum.CREATE_POLICY_FAILURE, auth_policy_name, "policyName"); throw new PolicyManagementServiceException( @@ -445,7 +445,7 @@ private PolicyResponseDto mapPolicyAndPolicyGroup(AuthPolicy authPolicy) private PolicyCreateResponseDto savePolicy(JSONObject policyJson, String oldPolicyName, String newPolicyName, String policyDesc, String policyGroupId, String policyType, String policyGroupName, String version, String authPolicyId) throws PolicyManagementServiceException, Exception { - AuthPolicy authPolicy = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, oldPolicyName); + AuthPolicy authPolicy = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, oldPolicyName); if (authPolicy != null) { authPolicy.setId(authPolicy.getId()); authPolicy.setDescr(policyDesc); diff --git a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java index 30155ea3c9..a2456cec2a 100644 --- a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java +++ b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java @@ -338,7 +338,7 @@ public void createPoliciesTest_S004() throws PolicyManagementServiceException, E PolicyCreateRequestDto request = createPoliciesRequest(); request.setPolicyType("Data_Share"); Mockito.when(policyGroupRepository.findByName("Test_Policy_Group_001")).thenReturn(policyGroupData()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","Test_001")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","Test_001")).thenReturn(getAuthPolicy()); service.createPolicies(request); } @@ -376,7 +376,7 @@ public void createPoliciesTest_S007() throws PolicyManagementServiceException, E Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); Mockito.when(policyGroupRepository.findByName("Test_Policy_Group_001")).thenReturn(policyGroupData()); Mockito.when(authPolicyRepository.findByName("Test")).thenReturn(getAuthPolicy()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","Test")).thenReturn(getAuthPolicy()); try { service.createPolicies(request); }catch (PolicyManagementServiceException e) { @@ -571,7 +571,7 @@ public void updatePolicies_PolicyNameDuplicateTest() throws PolicyManagementServ AuthPolicy authPolicyName = getAuthPolicy(); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -597,7 +597,7 @@ public void updatePolicies_Test_01() throws PolicyManagementServiceException, Ex AuthPolicy authPolicyName = getAuthPolicy(); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -625,7 +625,7 @@ public void updatePolicies_Test_02() throws PolicyManagementServiceException, Ex authPolicyName.setPolicySchema("localhost"); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -654,7 +654,7 @@ public void updatePolicies_Test_03() throws PolicyManagementServiceException, Ex authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); authPolicyName.setPolicy_type("Auth"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualObj = objectMapper.readTree(authPolicySchema); Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); @@ -686,7 +686,7 @@ public void updatePolicies_Test_04() throws PolicyManagementServiceException, Ex authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); authPolicyName.setPolicy_type("Auth"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test_01")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test_01")).thenReturn(authPolicyName); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualObj = objectMapper.readTree(authPolicySchema); Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); @@ -738,7 +738,7 @@ public void publishPolicy_PolicyPublishedTest() throws JsonParseException, JsonM Mockito.when(authPolicyRepository.findByName("Test")).thenReturn(authPolicy); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findByName("Test")).thenReturn(policy.get()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); service.publishPolicy("Test", "Test"); } @@ -762,7 +762,7 @@ public void publishPolicyTest() throws JsonParseException, JsonMappingException, Mockito.when(authPolicyRepository.findById("Test")).thenReturn(Optional.of(authPolicy)); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findById("Test")).thenReturn(policy); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); service.publishPolicy("Test", "Test"); } @@ -788,7 +788,7 @@ public void publishPolicyTest_02() throws JsonParseException, JsonMappingExcepti Mockito.when(authPolicyRepository.findById("Test")).thenReturn(Optional.of(authPolicy)); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findById("Test")).thenReturn(policy); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); try { service.publishPolicy("Test", "Test"); @@ -821,7 +821,7 @@ public void publishPolicyTest_01() throws JsonParseException, JsonMappingExcepti AuthPolicy authPolicy01 = getAuthPolicy(); authPolicy01.setIsActive(false); authPolicy01.setPolicySchema("localhost"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicy01); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicy01); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); service.publishPolicy("Test", "Test"); }