From bd0ccc1f2c5a7784cf14196f0c9a2404040c0445 Mon Sep 17 00:00:00 2001 From: tharikaGitHub Date: Tue, 6 Aug 2024 16:14:08 +0530 Subject: [PATCH] Fix test failure of ELKAnalyticsWithRespondMediatorTestCase --- .../test/impl/RestAPIPublisherImpl.java | 29 +++++++++++++++++++ ...KAnalyticsWithRespondMediatorTestCase.java | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java index 0e0b354dbf..bde33b788f 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java @@ -2418,6 +2418,35 @@ public Map getAllCommonOperationPolicies() throws ApiException { return null; } + /** + * Method to get all common operation policies passing limit, offset and query as parameters + * + * @param limit limit + * @param offset offset + * @param query query + * @return A map of policy name and policy UUID + * @throws ApiException - Throws if policy information cannot be retrieved. + */ + public Map getAllCommonOperationPolicies(Integer limit, Integer offset, String query) + throws ApiException { + + setActivityID(); + if (limit == null) { + limit = 50; + } + if (offset == null) { + offset = 0; + } + ApiResponse apiResponse = operationPoliciesApi.getAllCommonOperationPoliciesWithHttpInfo( + limit, offset, query); + Assert.assertEquals(apiResponse.getStatusCode(), HttpStatus.SC_OK, + "Unable to retrieve common policies " + apiResponse.getData()); + if (apiResponse != null && apiResponse.getData().getCount() >= 0) { + return mapPolicyNameToId(apiResponse.getData()); + } + return null; + } + public Map getAllCommonOperationPolicies(int limit) throws ApiException { setActivityID(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/analytics/ELKAnalyticsWithRespondMediatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/analytics/ELKAnalyticsWithRespondMediatorTestCase.java index fc4b31f750..3061611c19 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/analytics/ELKAnalyticsWithRespondMediatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/analytics/ELKAnalyticsWithRespondMediatorTestCase.java @@ -115,7 +115,7 @@ public void testELKAnalyticsWithRespondMediator() throws Exception { // Add common operation policy with respond mediator addNewOperationPolicy(); - Map updatedCommonPolicyMap = restAPIPublisher.getAllCommonOperationPolicies(); + Map updatedCommonPolicyMap = restAPIPublisher.getAllCommonOperationPolicies(60, 0, null); Assert.assertNotNull(updatedCommonPolicyMap.get("respondMediatorPolicy"), "Unable to find the newly added common policy");