mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-30 20:59:57 +00:00
ISSUE-792: Move checkUserFollowing method to TestUtils
This commit is contained in:
parent
8ccb8624e4
commit
7ced33c069
@ -75,6 +75,7 @@ import static org.openmetadata.catalog.util.TestUtils.adminAuthHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertEntityPagination;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.catalog.util.TestUtils.authHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.checkUserFollowing;
|
||||
import static org.openmetadata.catalog.util.TestUtils.userAuthHeaders;
|
||||
|
||||
public class ChartResourceTest extends CatalogApplicationTest {
|
||||
@ -722,21 +723,6 @@ public class ChartResourceTest extends CatalogApplicationTest {
|
||||
checkUserFollowing(userId, chart.getId(), true, authHeaders);
|
||||
}
|
||||
|
||||
private static void checkUserFollowing(UUID userId, UUID chartId, boolean expectedFollowing,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
// GET .../users/{userId} shows user as following table
|
||||
boolean following = false;
|
||||
User user = UserResourceTest.getUser(userId, "follows", authHeaders);
|
||||
for (EntityReference follows : user.getFollows()) {
|
||||
TestUtils.validateEntityReference(follows);
|
||||
if (follows.getId().equals(chartId)) {
|
||||
following = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(expectedFollowing, following, "Follower list for the user is invalid");
|
||||
}
|
||||
|
||||
private void deleteAndCheckFollower(Chart chart, UUID userId, int totalFollowerCount,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
WebTarget target = CatalogApplicationTest.getResource(String.format("charts/%s/followers/%s",
|
||||
|
@ -103,6 +103,7 @@ import static org.openmetadata.catalog.util.TestUtils.adminAuthHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertEntityPagination;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.catalog.util.TestUtils.authHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.checkUserFollowing;
|
||||
import static org.openmetadata.catalog.util.TestUtils.userAuthHeaders;
|
||||
import static org.openmetadata.common.utils.CommonUtil.getDateStringByOffset;
|
||||
|
||||
@ -1466,21 +1467,6 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkUserFollowing(UUID userId, UUID tableId, boolean expectedFollowing,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
// GET .../users/{userId} shows user as following table
|
||||
boolean following = false;
|
||||
User user = UserResourceTest.getUser(userId, "follows", authHeaders);
|
||||
for (EntityReference follows : user.getFollows()) {
|
||||
TestUtils.validateEntityReference(follows);
|
||||
if (follows.getId().equals(tableId)) {
|
||||
following = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(expectedFollowing, following, "Follower list for the user is invalid");
|
||||
}
|
||||
|
||||
private static int getTagUsageCount(String tagFQN, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
return TagResourceTest.getTag(tagFQN, "usageCount", authHeaders).getUsageCount();
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ import static org.openmetadata.catalog.util.TestUtils.adminAuthHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertEntityPagination;
|
||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.catalog.util.TestUtils.authHeaders;
|
||||
import static org.openmetadata.catalog.util.TestUtils.checkUserFollowing;
|
||||
import static org.openmetadata.catalog.util.TestUtils.userAuthHeaders;
|
||||
|
||||
public class TopicResourceTest extends CatalogApplicationTest {
|
||||
@ -742,21 +743,6 @@ public class TopicResourceTest extends CatalogApplicationTest {
|
||||
checkUserFollowing(userId, topic.getId(), true, authHeaders);
|
||||
}
|
||||
|
||||
private static void checkUserFollowing(UUID userId, UUID topicId, boolean expectedFollowing,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
// GET .../users/{userId} shows user as following table
|
||||
boolean following = false;
|
||||
User user = UserResourceTest.getUser(userId, "follows", authHeaders);
|
||||
for (EntityReference follows : user.getFollows()) {
|
||||
TestUtils.validateEntityReference(follows);
|
||||
if (follows.getId().equals(topicId)) {
|
||||
following = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(expectedFollowing, following, "Follower list for the user is invalid");
|
||||
}
|
||||
|
||||
private void deleteAndCheckFollower(Topic topic, UUID userId, int totalFollowerCount,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
WebTarget target = CatalogApplicationTest.getResource(String.format("topics/%s/followers/%s",
|
||||
|
@ -19,8 +19,10 @@ package org.openmetadata.catalog.util;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
import org.openmetadata.catalog.entity.teams.User;
|
||||
import org.openmetadata.catalog.resources.databases.TableResourceTest.TagLabelComparator;
|
||||
import org.openmetadata.catalog.resources.tags.TagResourceTest;
|
||||
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
||||
import org.openmetadata.catalog.security.CatalogOpenIdAuthorizationRequestFilter;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.JdbcInfo;
|
||||
@ -258,4 +260,19 @@ public final class TestUtils {
|
||||
public static Map<String, String> userAuthHeaders() {
|
||||
return authHeaders("test@open-metadata.org");
|
||||
}
|
||||
|
||||
public static void checkUserFollowing(UUID userId, UUID chartId, boolean expectedFollowing,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
// GET .../users/{userId} shows user as following table
|
||||
boolean following = false;
|
||||
User user = UserResourceTest.getUser(userId, "follows", authHeaders);
|
||||
for (EntityReference follows : user.getFollows()) {
|
||||
TestUtils.validateEntityReference(follows);
|
||||
if (follows.getId().equals(chartId)) {
|
||||
following = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(expectedFollowing, following, "Follower list for the user is invalid");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user