diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java index 3d06ba39ec1..833f2aae321 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java @@ -115,7 +115,7 @@ public class ListFilter extends Filter { String apiCollection = queryParams.get("apiCollection"); return apiCollection == null ? "" - : getFqnPrefixCondition(apiEndpoint, apiEndpoint, "apiCollection"); + : getFqnPrefixCondition(apiEndpoint, apiCollection, "apiCollection"); } private String getEntityFQNHashCondition() { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/apis/APIEndpointResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/apis/APIEndpointResourceTest.java index 00773418846..4b2693d02e0 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/apis/APIEndpointResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/apis/APIEndpointResourceTest.java @@ -26,8 +26,12 @@ import java.util.UUID; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; import org.apache.http.client.HttpResponseException; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.openmetadata.schema.api.data.CreateAPIEndpoint; import org.openmetadata.schema.entity.data.APIEndpoint; import org.openmetadata.schema.type.APIRequestMethod; @@ -42,6 +46,8 @@ import org.openmetadata.service.util.FullyQualifiedName; import org.openmetadata.service.util.ResultList; import org.openmetadata.service.util.TestUtils; +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class APIEndpointResourceTest extends EntityResourceTest { public static final List api_request_fields = @@ -88,27 +94,37 @@ public class APIEndpointResourceTest extends EntityResourceTest omAPIEndpoints = new ArrayList<>(); + List sampleAPIEndpoints = new ArrayList<>(); - // Create topic for each service and test APIs - for (String apiCollection : differentAPICollections) { - createAndCheckEntity( - createRequest(test).withApiCollection(apiCollection), ADMIN_AUTH_HEADERS); - - // List topics by filtering on service name and ensure right endPoints in the response - Map queryParams = new HashMap<>(); - queryParams.put("apiCollection", apiCollection); - - ResultList list = listEntities(queryParams, ADMIN_AUTH_HEADERS); - for (APIEndpoint endpoint : list.getData()) { - assertEquals(apiCollection, endpoint.getApiCollection().getFullyQualifiedName()); - } + // Create API Endpoints for each service and test APIs + for (int i = 0; i < 5; i++) { + omAPIEndpoints.add( + createAndCheckEntity( + createRequest(String.format("%s%d", test.getDisplayName(), i)) + .withApiCollection(OPENMETADATA_API_COLLECTION_REFERENCE.getFullyQualifiedName()), + ADMIN_AUTH_HEADERS)); } + + for (int i = 0; i < 3; i++) { + sampleAPIEndpoints.add( + createAndCheckEntity( + createRequest(String.format("%s%s%d", test.getDisplayName(), "S", i)) + .withApiCollection(SAMPLE_API_COLLECTION_REFERENCE.getFullyQualifiedName()), + ADMIN_AUTH_HEADERS)); + } + + Map queryParams = new HashMap<>(); + queryParams.put("apiCollection", OPENMETADATA_API_COLLECTION_REFERENCE.getFullyQualifiedName()); + ResultList list = listEntities(queryParams, ADMIN_AUTH_HEADERS); + assertEquals(omAPIEndpoints.size(), list.getPaging().getTotal()); + + queryParams.put("apiCollection", SAMPLE_API_COLLECTION_REFERENCE.getFullyQualifiedName()); + list = listEntities(queryParams, ADMIN_AUTH_HEADERS); + assertEquals(sampleAPIEndpoints.size(), list.getPaging().getTotal()); } @Test