mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-26 08:13:11 +00:00
Clean up code warnings - remove unused method, exceptions declared not thrown, and others (#5088)
This commit is contained in:
parent
bec87bb1b1
commit
eab5bf9a0e
@ -31,7 +31,6 @@ import io.federecio.dropwizard.swagger.SwaggerBundle;
|
|||||||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.ws.rs.container.ContainerRequestFilter;
|
import javax.ws.rs.container.ContainerRequestFilter;
|
||||||
@ -78,7 +77,7 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
@Override
|
@Override
|
||||||
public void run(CatalogApplicationConfig catalogConfig, Environment environment)
|
public void run(CatalogApplicationConfig catalogConfig, Environment environment)
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
|
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
|
||||||
InvocationTargetException, IOException, SQLException {
|
InvocationTargetException, IOException {
|
||||||
final Jdbi jdbi = new JdbiFactory().build(environment, catalogConfig.getDataSourceFactory(), "database");
|
final Jdbi jdbi = new JdbiFactory().build(environment, catalogConfig.getDataSourceFactory(), "database");
|
||||||
|
|
||||||
SqlLogger sqlLogger =
|
SqlLogger sqlLogger =
|
||||||
@ -191,12 +190,14 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
AuthorizerConfiguration authorizerConf = catalogConfig.getAuthorizerConfiguration();
|
AuthorizerConfiguration authorizerConf = catalogConfig.getAuthorizerConfiguration();
|
||||||
AuthenticationConfiguration authenticationConfiguration = catalogConfig.getAuthenticationConfiguration();
|
AuthenticationConfiguration authenticationConfiguration = catalogConfig.getAuthenticationConfiguration();
|
||||||
if (authorizerConf != null) {
|
if (authorizerConf != null) {
|
||||||
authorizer = ((Class<Authorizer>) Class.forName(authorizerConf.getClassName())).getConstructor().newInstance();
|
authorizer =
|
||||||
|
Class.forName(authorizerConf.getClassName()).asSubclass(Authorizer.class).getConstructor().newInstance();
|
||||||
String filterClazzName = authorizerConf.getContainerRequestFilter();
|
String filterClazzName = authorizerConf.getContainerRequestFilter();
|
||||||
ContainerRequestFilter filter;
|
ContainerRequestFilter filter;
|
||||||
if (!StringUtils.isEmpty(filterClazzName)) {
|
if (!StringUtils.isEmpty(filterClazzName)) {
|
||||||
filter =
|
filter =
|
||||||
((Class<ContainerRequestFilter>) Class.forName(filterClazzName))
|
Class.forName(filterClazzName)
|
||||||
|
.asSubclass(ContainerRequestFilter.class)
|
||||||
.getConstructor(AuthenticationConfiguration.class)
|
.getConstructor(AuthenticationConfiguration.class)
|
||||||
.newInstance(authenticationConfiguration);
|
.newInstance(authenticationConfiguration);
|
||||||
LOG.info("Registering ContainerRequestFilter: {}", filter.getClass().getCanonicalName());
|
LOG.info("Registering ContainerRequestFilter: {}", filter.getClass().getCanonicalName());
|
||||||
@ -204,8 +205,8 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Authorizer config not set, setting noop authorizer");
|
LOG.info("Authorizer config not set, setting noop authorizer");
|
||||||
authorizer = NoopAuthorizer.class.getConstructor().newInstance();
|
authorizer = new NoopAuthorizer();
|
||||||
ContainerRequestFilter filter = NoopFilter.class.getConstructor().newInstance();
|
ContainerRequestFilter filter = new NoopFilter(authenticationConfiguration);
|
||||||
environment.jersey().register(filter);
|
environment.jersey().register(filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,12 +257,12 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
public static class ManagedShutdown implements Managed {
|
public static class ManagedShutdown implements Managed {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() throws Exception {
|
public void start() {
|
||||||
LOG.info("Starting the application");
|
LOG.info("Starting the application");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() throws Exception {
|
public void stop() throws InterruptedException {
|
||||||
EventPubSub.shutdown();
|
EventPubSub.shutdown();
|
||||||
LOG.info("Stopping the application");
|
LOG.info("Stopping the application");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class CatalogHealthCheck extends HealthCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result check() throws Exception {
|
protected Result check() {
|
||||||
try {
|
try {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter();
|
||||||
userRepository.listAfter(null, Fields.EMPTY_FIELDS, filter, 1, null);
|
userRepository.listAfter(null, Fields.EMPTY_FIELDS, filter, 1, null);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public interface CreateEntity {
|
|||||||
|
|
||||||
default Object getExtension() {
|
default Object getExtension() {
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
<K extends CreateEntity> K withName(String name);
|
<K extends CreateEntity> K withName(String name);
|
||||||
|
|
||||||
@ -42,5 +42,5 @@ public interface CreateEntity {
|
|||||||
|
|
||||||
default <K extends CreateEntity> K withExtension(Object extension) {
|
default <K extends CreateEntity> K withExtension(Object extension) {
|
||||||
return (K) this;
|
return (K) this;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,8 +85,6 @@ public final class Entity {
|
|||||||
public static final String REPORT = "report";
|
public static final String REPORT = "report";
|
||||||
public static final String TOPIC = "topic";
|
public static final String TOPIC = "topic";
|
||||||
public static final String MLMODEL = "mlmodel";
|
public static final String MLMODEL = "mlmodel";
|
||||||
// Not deleted to ensure the ordinal value of the entities after this remains the same
|
|
||||||
public static final String UNUSED = "unused";
|
|
||||||
public static final String BOT = "bot";
|
public static final String BOT = "bot";
|
||||||
public static final String THREAD = "THREAD";
|
public static final String THREAD = "THREAD";
|
||||||
public static final String LOCATION = "location";
|
public static final String LOCATION = "location";
|
||||||
@ -146,22 +144,10 @@ public final class Entity {
|
|||||||
entityRepository.getClass().getSimpleName());
|
entityRepository.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateEntity(String entityType) {
|
|
||||||
String canonicalEntity = CANONICAL_ENTITY_NAME_MAP.get(entityType.toLowerCase());
|
|
||||||
if (canonicalEntity == null) {
|
|
||||||
throw new IllegalArgumentException(CatalogExceptionMessage.invalidEntity(entityType));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityReference getEntityReference(EntityReference ref) throws IOException {
|
public static EntityReference getEntityReference(EntityReference ref) throws IOException {
|
||||||
return ref == null ? null : getEntityReferenceById(ref.getType(), ref.getId(), Include.NON_DELETED);
|
return ref == null ? null : getEntityReferenceById(ref.getType(), ref.getId(), Include.NON_DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityReference getEntityReferenceById(@NonNull String entityType, @NonNull UUID id)
|
|
||||||
throws IOException {
|
|
||||||
return getEntityReferenceById(entityType, id, Include.NON_DELETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityReference getEntityReferenceById(@NonNull String entityType, @NonNull UUID id, Include include)
|
public static EntityReference getEntityReferenceById(@NonNull String entityType, @NonNull UUID id, Include include)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
EntityRepository<?> repository = ENTITY_REPOSITORY_MAP.get(entityType);
|
EntityRepository<?> repository = ENTITY_REPOSITORY_MAP.get(entityType);
|
||||||
@ -173,7 +159,7 @@ public final class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EntityReference getEntityReferenceByName(
|
public static EntityReference getEntityReferenceByName(
|
||||||
@NonNull String entityType, @NonNull String fqn, Include include) throws IOException {
|
@NonNull String entityType, @NonNull String fqn, Include include) {
|
||||||
EntityDAO<?> dao = DAO_MAP.get(entityType);
|
EntityDAO<?> dao = DAO_MAP.get(entityType);
|
||||||
if (dao == null) {
|
if (dao == null) {
|
||||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityTypeNotFound(entityType));
|
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityTypeNotFound(entityType));
|
||||||
@ -190,14 +176,14 @@ public final class Entity {
|
|||||||
listOrEmpty(list).forEach(ref -> withHref(uriInfo, ref));
|
listOrEmpty(list).forEach(ref -> withHref(uriInfo, ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityReference withHref(UriInfo uriInfo, EntityReference ref) {
|
public static void withHref(UriInfo uriInfo, EntityReference ref) {
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
String entityType = ref.getType();
|
String entityType = ref.getType();
|
||||||
EntityRepository<?> entityRepository = getEntityRepository(entityType);
|
EntityRepository<?> entityRepository = getEntityRepository(entityType);
|
||||||
URI href = entityRepository.getHref(uriInfo, ref.getId());
|
URI href = entityRepository.getHref(uriInfo, ref.getId());
|
||||||
return ref.withHref(href);
|
ref.withHref(href);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldHaveOwner(@NonNull String entityType) {
|
public static boolean shouldHaveOwner(@NonNull String entityType) {
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
package org.openmetadata.catalog.airflow;
|
package org.openmetadata.catalog.airflow;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
@ -49,7 +48,7 @@ public class AirflowRESTClient extends PipelineServiceClient {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public String authenticate() throws IOException {
|
public String authenticate() {
|
||||||
AirflowAuthRequest authRequest =
|
AirflowAuthRequest authRequest =
|
||||||
AirflowAuthRequest.builder().username(this.username).password(this.password).build();
|
AirflowAuthRequest.builder().username(this.username).password(this.password).build();
|
||||||
String authPayload = JsonUtils.pojoToJson(authRequest);
|
String authPayload = JsonUtils.pojoToJson(authRequest);
|
||||||
|
|||||||
@ -12,8 +12,4 @@ public class ElasticSearchRetriableException extends RetriableException {
|
|||||||
public ElasticSearchRetriableException(String message) {
|
public ElasticSearchRetriableException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElasticSearchRetriableException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public abstract class AbstractEventPublisher implements EventPublisher {
|
|||||||
private int currentBackoffTime = BACKOFF_NORMAL;
|
private int currentBackoffTime = BACKOFF_NORMAL;
|
||||||
private final List<ChangeEvent> batch = new ArrayList<>();
|
private final List<ChangeEvent> batch = new ArrayList<>();
|
||||||
private final ConcurrentHashMap<EventType, List<String>> filter = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<EventType, List<String>> filter = new ConcurrentHashMap<>();
|
||||||
private int batchSize = 10;
|
private final int batchSize;
|
||||||
|
|
||||||
protected AbstractEventPublisher(int batchSize, List<EventFilter> filters) {
|
protected AbstractEventPublisher(int batchSize, List<EventFilter> filters) {
|
||||||
filters.forEach(f -> filter.put(f.getEventType(), f.getEntities()));
|
filters.forEach(f -> filter.put(f.getEventType(), f.getEntities()));
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import org.slf4j.Marker;
|
|||||||
|
|
||||||
@JsonTypeName("audit-exclude-filter-factory")
|
@JsonTypeName("audit-exclude-filter-factory")
|
||||||
public class AuditExcludeFilterFactory implements FilterFactory<ILoggingEvent> {
|
public class AuditExcludeFilterFactory implements FilterFactory<ILoggingEvent> {
|
||||||
private static Filter<ILoggingEvent> auditFilter =
|
private static final Filter<ILoggingEvent> auditFilter =
|
||||||
new Filter<ILoggingEvent>() {
|
new Filter<>() {
|
||||||
@Override
|
@Override
|
||||||
public FilterReply decide(final ILoggingEvent event) {
|
public FilterReply decide(final ILoggingEvent event) {
|
||||||
Marker marker = event.getMarker();
|
Marker marker = event.getMarker();
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import org.slf4j.Marker;
|
|||||||
|
|
||||||
@JsonTypeName("audit-only-filter-factory")
|
@JsonTypeName("audit-only-filter-factory")
|
||||||
public class AuditOnlyFilterFactory implements FilterFactory<ILoggingEvent> {
|
public class AuditOnlyFilterFactory implements FilterFactory<ILoggingEvent> {
|
||||||
private static Filter<ILoggingEvent> auditFilter =
|
private static final Filter<ILoggingEvent> auditFilter =
|
||||||
new Filter<ILoggingEvent>() {
|
new Filter<>() {
|
||||||
@Override
|
@Override
|
||||||
public FilterReply decide(final ILoggingEvent event) {
|
public FilterReply decide(final ILoggingEvent event) {
|
||||||
Marker marker = event.getMarker();
|
Marker marker = event.getMarker();
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.openmetadata.catalog.type.ChangeEvent;
|
import org.openmetadata.catalog.type.ChangeEvent;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
/** Change event PubSub built based on LMAX Disruptor. */
|
/** Change event PubSub built based on LMAX Disruptor. */
|
||||||
|
@Slf4j
|
||||||
public class EventPubSub {
|
public class EventPubSub {
|
||||||
private static Disruptor<ChangeEventHolder> disruptor;
|
private static Disruptor<ChangeEventHolder> disruptor;
|
||||||
private static ExecutorService executor;
|
private static ExecutorService executor;
|
||||||
|
|||||||
@ -17,41 +17,12 @@ import javax.ws.rs.core.Response;
|
|||||||
|
|
||||||
public final class BadRequestException extends WebServiceException {
|
public final class BadRequestException extends WebServiceException {
|
||||||
private static final String DEFAULT_MESSAGE = "Bad request.";
|
private static final String DEFAULT_MESSAGE = "Bad request.";
|
||||||
private static final String PARAMETER_MISSING_MESSAGE = "Bad request. Param [%s] is missing or empty.";
|
|
||||||
|
|
||||||
private BadRequestException(String message) {
|
private BadRequestException(String message) {
|
||||||
super(Response.Status.BAD_REQUEST, message);
|
super(Response.Status.BAD_REQUEST, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BadRequestException(String message, Throwable cause) {
|
|
||||||
super(Response.Status.BAD_REQUEST, message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BadRequestException message(String message) {
|
|
||||||
return new BadRequestException(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BadRequestException message(String message, Throwable cause) {
|
|
||||||
return new BadRequestException(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BadRequestException of() {
|
public static BadRequestException of() {
|
||||||
return new BadRequestException(DEFAULT_MESSAGE);
|
return new BadRequestException(DEFAULT_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BadRequestException of(Throwable cause) {
|
|
||||||
return new BadRequestException(DEFAULT_MESSAGE, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BadRequestException missingParameter(String parameterName) {
|
|
||||||
return new BadRequestException(buildParameterMissingMessage(parameterName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BadRequestException missingParameter(String parameterName, Throwable cause) {
|
|
||||||
return new BadRequestException(buildParameterMissingMessage(parameterName), cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String buildParameterMissingMessage(String parameterName) {
|
|
||||||
return String.format(PARAMETER_MISSING_MESSAGE, parameterName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,12 +53,8 @@ public final class CatalogExceptionMessage {
|
|||||||
return String.format("Entity type %s not found", entityType);
|
return String.format("Entity type %s not found", entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String fieldIsNull(String field) {
|
public static String deletedUser(UUID id) {
|
||||||
return String.format("Field %s is null", field);
|
return String.format("User %s is deleted", id);
|
||||||
}
|
|
||||||
|
|
||||||
public static String deactivatedUser(UUID id) {
|
|
||||||
return String.format("User %s is deactivated", id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String userAlreadyPartOfTeam(String userName, String teamName) {
|
public static String userAlreadyPartOfTeam(String userName, String teamName) {
|
||||||
|
|||||||
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Collate
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openmetadata.catalog.exception;
|
|
||||||
|
|
||||||
public class DuplicateEntityException extends RuntimeException {
|
|
||||||
public DuplicateEntityException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Collate
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openmetadata.catalog.exception;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
public class WebserviceAuthorizationException extends WebServiceException {
|
|
||||||
public WebserviceAuthorizationException(String msg) {
|
|
||||||
super(Response.Status.FORBIDDEN, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -306,7 +306,7 @@ public interface CollectionDAO {
|
|||||||
List<ExtensionRecord> getExtensions(@Bind("id") String id, @Bind("extensionPrefix") String extensionPrefix);
|
List<ExtensionRecord> getExtensions(@Bind("id") String id, @Bind("extensionPrefix") String extensionPrefix);
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM entity_extension WHERE id = :id")
|
@SqlUpdate("DELETE FROM entity_extension WHERE id = :id")
|
||||||
int deleteAll(@Bind("id") String id);
|
void deleteAll(@Bind("id") String id);
|
||||||
}
|
}
|
||||||
|
|
||||||
class EntityVersionPair {
|
class EntityVersionPair {
|
||||||
@ -336,9 +336,23 @@ public interface CollectionDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FromEntityReferenceMapper implements RowMapper<EntityReference> {
|
||||||
|
@Override
|
||||||
|
public EntityReference map(ResultSet rs, org.jdbi.v3.core.statement.StatementContext ctx) throws SQLException {
|
||||||
|
return new EntityReference().withId(UUID.fromString(rs.getString("fromId"))).withType(rs.getString("fromEntity"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ToEntityReferenceMapper implements RowMapper<EntityReference> {
|
||||||
|
@Override
|
||||||
|
public EntityReference map(ResultSet rs, org.jdbi.v3.core.statement.StatementContext ctx) throws SQLException {
|
||||||
|
return new EntityReference().withId(UUID.fromString(rs.getString("toId"))).withType(rs.getString("toEntity"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface EntityRelationshipDAO {
|
interface EntityRelationshipDAO {
|
||||||
default int insert(UUID fromId, UUID toId, String fromEntity, String toEntity, int relation) {
|
default void insert(UUID fromId, UUID toId, String fromEntity, String toEntity, int relation) {
|
||||||
return insert(fromId, toId, fromEntity, toEntity, relation, null);
|
insert(fromId, toId, fromEntity, toEntity, relation, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int insert(UUID fromId, UUID toId, String fromEntity, String toEntity, int relation, String json) {
|
default int insert(UUID fromId, UUID toId, String fromEntity, String toEntity, int relation, String json) {
|
||||||
@ -453,7 +467,7 @@ public interface CollectionDAO {
|
|||||||
@SqlUpdate(
|
@SqlUpdate(
|
||||||
"DELETE from entity_relationship WHERE fromId = :fromId AND fromEntity = :fromEntity "
|
"DELETE from entity_relationship WHERE fromId = :fromId AND fromEntity = :fromEntity "
|
||||||
+ "AND relation = :relation AND toEntity = :toEntity")
|
+ "AND relation = :relation AND toEntity = :toEntity")
|
||||||
int deleteFrom(
|
void deleteFrom(
|
||||||
@Bind("fromId") String fromId,
|
@Bind("fromId") String fromId,
|
||||||
@Bind("fromEntity") String fromEntity,
|
@Bind("fromEntity") String fromEntity,
|
||||||
@Bind("relation") int relation,
|
@Bind("relation") int relation,
|
||||||
@ -463,7 +477,7 @@ public interface CollectionDAO {
|
|||||||
@SqlUpdate(
|
@SqlUpdate(
|
||||||
"DELETE from entity_relationship WHERE toId = :toId AND toEntity = :toEntity AND relation = :relation "
|
"DELETE from entity_relationship WHERE toId = :toId AND toEntity = :toEntity AND relation = :relation "
|
||||||
+ "AND fromEntity = :fromEntity")
|
+ "AND fromEntity = :fromEntity")
|
||||||
int deleteTo(
|
void deleteTo(
|
||||||
@Bind("toId") String toId,
|
@Bind("toId") String toId,
|
||||||
@Bind("toEntity") String toEntity,
|
@Bind("toEntity") String toEntity,
|
||||||
@Bind("relation") int relation,
|
@Bind("relation") int relation,
|
||||||
@ -472,7 +486,7 @@ public interface CollectionDAO {
|
|||||||
@SqlUpdate(
|
@SqlUpdate(
|
||||||
"DELETE from entity_relationship WHERE (toId = :id AND toEntity = :entity) OR "
|
"DELETE from entity_relationship WHERE (toId = :id AND toEntity = :entity) OR "
|
||||||
+ "(fromId = :id AND fromEntity = :entity)")
|
+ "(fromId = :id AND fromEntity = :entity)")
|
||||||
int deleteAll(@Bind("id") String id, @Bind("entity") String entity);
|
void deleteAll(@Bind("id") String id, @Bind("entity") String entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FeedDAO {
|
interface FeedDAO {
|
||||||
@ -721,7 +735,7 @@ public interface CollectionDAO {
|
|||||||
+ "VALUES (:fromFQN, :toFQN, :fromType, :toType, :relation, (:json :: jsonb)) "
|
+ "VALUES (:fromFQN, :toFQN, :fromType, :toType, :relation, (:json :: jsonb)) "
|
||||||
+ "ON CONFLICT (fromFQN, toFQN, relation) DO NOTHING",
|
+ "ON CONFLICT (fromFQN, toFQN, relation) DO NOTHING",
|
||||||
connectionType = POSTGRES)
|
connectionType = POSTGRES)
|
||||||
int insert(
|
void insert(
|
||||||
@Bind("fromFQN") String fromFQN,
|
@Bind("fromFQN") String fromFQN,
|
||||||
@Bind("toFQN") String toFQN,
|
@Bind("toFQN") String toFQN,
|
||||||
@Bind("fromType") String fromType,
|
@Bind("fromType") String fromType,
|
||||||
@ -1379,7 +1393,7 @@ public interface CollectionDAO {
|
|||||||
UsageDetails getLatestUsage(@Bind("id") String id);
|
UsageDetails getLatestUsage(@Bind("id") String id);
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM entity_usage WHERE id = :id")
|
@SqlUpdate("DELETE FROM entity_usage WHERE id = :id")
|
||||||
int delete(@Bind("id") String id);
|
void delete(@Bind("id") String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Not sure I get what the next comment means, but tests now use mysql 8 so maybe tests can be improved here
|
* TODO: Not sure I get what the next comment means, but tests now use mysql 8 so maybe tests can be improved here
|
||||||
@ -1453,9 +1467,6 @@ public interface CollectionDAO {
|
|||||||
return "name";
|
return "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity WHERE email = :email")
|
|
||||||
String findByEmail(@Bind("email") String email);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default int listCount(ListFilter filter) {
|
default int listCount(ListFilter filter) {
|
||||||
String team = filter.getQueryParam("team");
|
String team = filter.getQueryParam("team");
|
||||||
|
|||||||
@ -178,22 +178,6 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
|||||||
return chartRefs.isEmpty() ? null : chartRefs;
|
return chartRefs.isEmpty() ? null : chartRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCharts(Dashboard original, Dashboard updated, EntityUpdater updater)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
// Remove all charts associated with this dashboard
|
|
||||||
deleteFrom(updated.getId(), Entity.DASHBOARD, Relationship.HAS, Entity.CHART);
|
|
||||||
|
|
||||||
// Add relationship from dashboard to chart
|
|
||||||
if (updated.getCharts() != null) {
|
|
||||||
for (EntityReference chart : updated.getCharts()) {
|
|
||||||
addRelationship(updated.getId(), chart.getId(), Entity.DASHBOARD, Entity.CHART, Relationship.HAS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<UUID> origChartIds = EntityUtil.getIDList(original.getCharts());
|
|
||||||
List<UUID> updatedChartIds = EntityUtil.getIDList(updated.getCharts());
|
|
||||||
updater.recordChange("charts", origChartIds, updatedChartIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Handles entity updated from PUT and POST operation. */
|
/** Handles entity updated from PUT and POST operation. */
|
||||||
public class DashboardUpdater extends EntityUpdater {
|
public class DashboardUpdater extends EntityUpdater {
|
||||||
public DashboardUpdater(Dashboard original, Dashboard updated, Operation operation) {
|
public DashboardUpdater(Dashboard original, Dashboard updated, Operation operation) {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
import org.openmetadata.catalog.Entity;
|
import org.openmetadata.catalog.Entity;
|
||||||
import org.openmetadata.catalog.entity.data.Database;
|
import org.openmetadata.catalog.entity.data.Database;
|
||||||
import org.openmetadata.catalog.entity.data.DatabaseSchema;
|
import org.openmetadata.catalog.entity.data.DatabaseSchema;
|
||||||
import org.openmetadata.catalog.resources.databases.DatabaseResource;
|
import org.openmetadata.catalog.resources.databases.DatabaseSchemaResource;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.type.Relationship;
|
import org.openmetadata.catalog.type.Relationship;
|
||||||
@ -36,7 +36,7 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
|
|||||||
|
|
||||||
public DatabaseSchemaRepository(CollectionDAO dao) {
|
public DatabaseSchemaRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
DatabaseResource.COLLECTION_PATH,
|
DatabaseSchemaResource.COLLECTION_PATH,
|
||||||
Entity.DATABASE_SCHEMA,
|
Entity.DATABASE_SCHEMA,
|
||||||
DatabaseSchema.class,
|
DatabaseSchema.class,
|
||||||
dao.databaseSchemaDAO(),
|
dao.databaseSchemaDAO(),
|
||||||
|
|||||||
@ -130,17 +130,7 @@ public interface EntityDAO<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default T findEntityById(UUID id, Include include) throws IOException {
|
default T findEntityById(UUID id, Include include) throws IOException {
|
||||||
Class<T> clz = getEntityClass();
|
return jsonToEntity(findById(getTableName(), id.toString(), getCondition(include)), id.toString());
|
||||||
String json = findById(getTableName(), id.toString(), getCondition(include));
|
|
||||||
T entity = null;
|
|
||||||
if (json != null) {
|
|
||||||
entity = JsonUtils.readValue(json, clz);
|
|
||||||
}
|
|
||||||
if (entity == null) {
|
|
||||||
String entityType = Entity.getEntityTypeFromClass(clz);
|
|
||||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(entityType, id));
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default T findEntityById(UUID id) throws IOException {
|
default T findEntityById(UUID id) throws IOException {
|
||||||
@ -153,15 +143,18 @@ public interface EntityDAO<T extends EntityInterface> {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
default T findEntityByName(String fqn, Include include) {
|
default T findEntityByName(String fqn, Include include) {
|
||||||
|
return jsonToEntity(findByName(getTableName(), getNameColumn(), fqn, getCondition(include)), fqn);
|
||||||
|
}
|
||||||
|
|
||||||
|
default T jsonToEntity(String json, String identity) throws IOException {
|
||||||
Class<T> clz = getEntityClass();
|
Class<T> clz = getEntityClass();
|
||||||
String json = findByName(getTableName(), getNameColumn(), fqn, getCondition(include));
|
|
||||||
T entity = null;
|
T entity = null;
|
||||||
if (json != null) {
|
if (json != null) {
|
||||||
entity = JsonUtils.readValue(json, clz);
|
entity = JsonUtils.readValue(json, clz);
|
||||||
}
|
}
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
String entityType = Entity.getEntityTypeFromClass(clz);
|
String entityType = Entity.getEntityTypeFromClass(clz);
|
||||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(entityType, fqn));
|
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(entityType, identity));
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@ -170,7 +163,7 @@ public interface EntityDAO<T extends EntityInterface> {
|
|||||||
return findEntityById(id).getEntityReference();
|
return findEntityById(id).getEntityReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
default EntityReference findEntityReferenceByName(String fqn) throws IOException {
|
default EntityReference findEntityReferenceByName(String fqn) {
|
||||||
return findEntityByName(fqn).getEntityReference();
|
return findEntityByName(fqn).getEntityReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +171,7 @@ public interface EntityDAO<T extends EntityInterface> {
|
|||||||
return findEntityById(id, include).getEntityReference();
|
return findEntityById(id, include).getEntityReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
default EntityReference findEntityReferenceByName(String fqn, Include include) throws IOException {
|
default EntityReference findEntityReferenceByName(String fqn, Include include) {
|
||||||
return findEntityByName(fqn, include).getEntityReference();
|
return findEntityByName(fqn, include).getEntityReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -480,7 +480,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
// Validate follower
|
// Validate follower
|
||||||
User user = daoCollection.userDAO().findEntityById(userId);
|
User user = daoCollection.userDAO().findEntityById(userId);
|
||||||
if (Boolean.TRUE.equals(user.getDeleted())) {
|
if (Boolean.TRUE.equals(user.getDeleted())) {
|
||||||
throw new IllegalArgumentException(CatalogExceptionMessage.deactivatedUser(userId));
|
throw new IllegalArgumentException(CatalogExceptionMessage.deletedUser(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add relationship
|
// Add relationship
|
||||||
@ -814,11 +814,6 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
return addRelationship(fromId, toId, fromEntity, toEntity, relationship, false);
|
return addRelationship(fromId, toId, fromEntity, toEntity, relationship, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addRelationship(
|
|
||||||
UUID fromId, UUID toId, String fromEntity, String toEntity, Relationship relationship, String json) {
|
|
||||||
return addRelationship(fromId, toId, fromEntity, toEntity, relationship, json, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int addRelationship(
|
public int addRelationship(
|
||||||
UUID fromId, UUID toId, String fromEntity, String toEntity, Relationship relationship, boolean bidirectional) {
|
UUID fromId, UUID toId, String fromEntity, String toEntity, Relationship relationship, boolean bidirectional) {
|
||||||
return addRelationship(fromId, toId, fromEntity, toEntity, relationship, null, bidirectional);
|
return addRelationship(fromId, toId, fromEntity, toEntity, relationship, null, bidirectional);
|
||||||
@ -943,12 +938,12 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
return getOwner(entity);
|
return getOwner(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityReference populateOwner(EntityReference owner) throws IOException {
|
public void populateOwner(EntityReference owner) throws IOException {
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
EntityReference ref = Entity.getEntityReferenceById(owner.getType(), owner.getId(), ALL);
|
EntityReference ref = Entity.getEntityReferenceById(owner.getType(), owner.getId(), ALL);
|
||||||
return EntityUtil.copy(ref, owner);
|
EntityUtil.copy(ref, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void storeOwner(T entity, EntityReference owner) {
|
protected void storeOwner(T entity, EntityReference owner) {
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import java.util.stream.Collectors;
|
|||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||||
@ -213,7 +214,7 @@ public class FeedRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
public ThreadCount getThreadsCount(String link, boolean isResolved) throws IOException {
|
public ThreadCount getThreadsCount(String link, boolean isResolved) {
|
||||||
ThreadCount threadCount = new ThreadCount();
|
ThreadCount threadCount = new ThreadCount();
|
||||||
List<List<String>> result;
|
List<List<String>> result;
|
||||||
List<EntityLinkThreadCount> entityLinkThreadCounts = new ArrayList<>();
|
List<EntityLinkThreadCount> entityLinkThreadCounts = new ArrayList<>();
|
||||||
@ -512,20 +513,12 @@ public class FeedRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FilteredThreads {
|
public static class FilteredThreads {
|
||||||
List<Thread> threads;
|
@Getter private final List<Thread> threads;
|
||||||
int totalCount;
|
@Getter private final int totalCount;
|
||||||
|
|
||||||
public FilteredThreads(List<Thread> threads, int totalCount) {
|
public FilteredThreads(List<Thread> threads, int totalCount) {
|
||||||
this.threads = threads;
|
this.threads = threads;
|
||||||
this.totalCount = totalCount;
|
this.totalCount = totalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Thread> getThreads() {
|
|
||||||
return threads;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalCount() {
|
|
||||||
return totalCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Collate
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openmetadata.catalog.jdbi3;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.jdbi.v3.core.mapper.RowMapper;
|
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
|
||||||
|
|
||||||
public class FromEntityReferenceMapper implements RowMapper<EntityReference> {
|
|
||||||
@Override
|
|
||||||
public EntityReference map(ResultSet rs, org.jdbi.v3.core.statement.StatementContext ctx) throws SQLException {
|
|
||||||
return new EntityReference().withId(UUID.fromString(rs.getString("fromId"))).withType(rs.getString("fromEntity"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,7 @@ import org.openmetadata.catalog.type.Include;
|
|||||||
|
|
||||||
public class ListFilter {
|
public class ListFilter {
|
||||||
private final Include include;
|
private final Include include;
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
private final Map<String, String> queryParams = new HashMap<>();
|
||||||
|
|
||||||
public ListFilter() {
|
public ListFilter() {
|
||||||
this(Include.NON_DELETED);
|
this(Include.NON_DELETED);
|
||||||
|
|||||||
@ -101,9 +101,7 @@ public class MessagingServiceRepository extends EntityRepository<MessagingServic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entitySpecificUpdate() throws IOException {
|
public void entitySpecificUpdate() throws IOException {
|
||||||
MessagingService origService = original;
|
recordChange("connection", original.getConnection(), updated.getConnection(), true);
|
||||||
MessagingService updatedService = updated;
|
|
||||||
recordChange("connection", origService.getConnection(), updatedService.getConnection(), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,10 +192,6 @@ public class MlModelRepository extends EntityRepository<MlModel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDashboard(MlModel mlModel) {
|
|
||||||
deleteTo(mlModel.getId(), Entity.MLMODEL, Relationship.USES, Entity.DASHBOARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Handles entity updated from PUT and POST operation. */
|
/** Handles entity updated from PUT and POST operation. */
|
||||||
public class MlModelUpdater extends EntityUpdater {
|
public class MlModelUpdater extends EntityUpdater {
|
||||||
public MlModelUpdater(MlModel original, MlModel updated, Operation operation) {
|
public MlModelUpdater(MlModel original, MlModel updated, Operation operation) {
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public class TagCategoryRepository extends EntityRepository<TagCategory> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(TagCategory entity) throws IOException {
|
public void prepare(TagCategory entity) {
|
||||||
setFullyQualifiedName(entity);
|
setFullyQualifiedName(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(Tag entity) throws IOException {
|
public void prepare(Tag entity) {
|
||||||
String[] split = FullyQualifiedName.split(entity.getFullyQualifiedName());
|
String[] split = FullyQualifiedName.split(entity.getFullyQualifiedName());
|
||||||
String category = split[0];
|
String category = split[0];
|
||||||
daoCollection.tagCategoryDAO().existsByName(category);
|
daoCollection.tagCategoryDAO().existsByName(category);
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Collate
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openmetadata.catalog.jdbi3;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.jdbi.v3.core.mapper.RowMapper;
|
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
|
||||||
|
|
||||||
public class ToEntityReferenceMapper implements RowMapper<EntityReference> {
|
|
||||||
@Override
|
|
||||||
public EntityReference map(ResultSet rs, org.jdbi.v3.core.statement.StatementContext ctx) throws SQLException {
|
|
||||||
return new EntityReference().withId(UUID.fromString(rs.getString("toId"))).withType(rs.getString("toEntity"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -56,7 +56,7 @@ public class TypeRepository extends EntityRepository<Type> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(Type type) throws IOException {
|
public void prepare(Type type) {
|
||||||
setFullyQualifiedName(type);
|
setFullyQualifiedName(type);
|
||||||
TypeRegistry.instance().validateCustomFields(type);
|
TypeRegistry.instance().validateCustomFields(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class UsageRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
public EntityUsage getByName(String entityType, String fqn, String date, int days) throws IOException {
|
public EntityUsage getByName(String entityType, String fqn, String date, int days) {
|
||||||
EntityReference ref = Entity.getEntityReferenceByName(entityType, fqn, Include.NON_DELETED);
|
EntityReference ref = Entity.getEntityReferenceByName(entityType, fqn, Include.NON_DELETED);
|
||||||
List<UsageDetails> usageDetails = dao.usageDAO().getUsageById(ref.getId().toString(), date, days - 1);
|
List<UsageDetails> usageDetails = dao.usageDAO().getUsageById(ref.getId().toString(), date, days - 1);
|
||||||
return new EntityUsage().withUsage(usageDetails).withEntity(ref);
|
return new EntityUsage().withUsage(usageDetails).withEntity(ref);
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
|
||||||
import org.openmetadata.catalog.Entity;
|
import org.openmetadata.catalog.Entity;
|
||||||
import org.openmetadata.catalog.entity.teams.AuthenticationMechanism;
|
import org.openmetadata.catalog.entity.teams.AuthenticationMechanism;
|
||||||
import org.openmetadata.catalog.entity.teams.Team;
|
import org.openmetadata.catalog.entity.teams.Team;
|
||||||
@ -55,14 +54,14 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityReference getOriginalOwner(User entity) throws IOException {
|
public EntityReference getOriginalOwner(User entity) {
|
||||||
// For User entity, the entity and the owner are the same
|
// For User entity, the entity and the owner are the same
|
||||||
return entity.getEntityReference();
|
return entity.getEntityReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ensures that the default roles are added for POST, PUT and PATCH operations. */
|
/** Ensures that the default roles are added for POST, PUT and PATCH operations. */
|
||||||
@Override
|
@Override
|
||||||
public void prepare(User user) throws IOException {
|
public void prepare(User user) {
|
||||||
setFullyQualifiedName(user);
|
setFullyQualifiedName(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +115,6 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
return new UserUpdater(original, updated, operation);
|
return new UserUpdater(original, updated, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
|
||||||
public User getByEmail(String email, Fields fields) throws IOException {
|
|
||||||
User user = EntityUtil.validate(email, daoCollection.userDAO().findByEmail(email), User.class);
|
|
||||||
return setFields(user, fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User setFields(User user, Fields fields) throws IOException {
|
public User setFields(User user, Fields fields) throws IOException {
|
||||||
user.setProfile(fields.contains("profile") ? user.getProfile() : null);
|
user.setProfile(fields.contains("profile") ? user.getProfile() : null);
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import javax.ws.rs.client.Invocation.Builder;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
|
||||||
import org.openmetadata.catalog.Entity;
|
import org.openmetadata.catalog.Entity;
|
||||||
import org.openmetadata.catalog.events.EventPubSub;
|
import org.openmetadata.catalog.events.EventPubSub;
|
||||||
import org.openmetadata.catalog.events.EventPubSub.ChangeEventHolder;
|
import org.openmetadata.catalog.events.EventPubSub.ChangeEventHolder;
|
||||||
@ -63,12 +62,12 @@ public class WebhookRepository extends EntityRepository<Webhook> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Webhook setFields(Webhook entity, Fields fields) throws IOException {
|
public Webhook setFields(Webhook entity, Fields fields) {
|
||||||
return entity; // No fields to set
|
return entity; // No fields to set
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(Webhook entity) throws IOException {
|
public void prepare(Webhook entity) {
|
||||||
setFullyQualifiedName(entity);
|
setFullyQualifiedName(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,11 +145,6 @@ public class WebhookRepository extends EntityRepository<Webhook> {
|
|||||||
webhookPublisherMap.remove(id);
|
webhookPublisherMap.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
|
||||||
public boolean delete(String id) {
|
|
||||||
return daoCollection.webhookDAO().delete(id) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebhookPublisher publishes events to the webhook endpoint using POST http requests. There is one instance of
|
* WebhookPublisher publishes events to the webhook endpoint using POST http requests. There is one instance of
|
||||||
* WebhookPublisher per webhook subscription. Each WebhookPublish is an EventHandler that runs in a separate thread
|
* WebhookPublisher per webhook subscription. Each WebhookPublish is an EventHandler that runs in a separate thread
|
||||||
|
|||||||
@ -76,9 +76,8 @@ public class FeedResource {
|
|||||||
private final FeedRepository dao;
|
private final FeedRepository dao;
|
||||||
private final Authorizer authorizer;
|
private final Authorizer authorizer;
|
||||||
|
|
||||||
public static List<Thread> addHref(UriInfo uriInfo, List<Thread> threads) {
|
public static void addHref(UriInfo uriInfo, List<Thread> threads) {
|
||||||
threads.forEach(t -> addHref(uriInfo, t));
|
threads.forEach(t -> addHref(uriInfo, t));
|
||||||
return threads;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread addHref(UriInfo uriInfo, Thread thread) {
|
public static Thread addHref(UriInfo uriInfo, Thread thread) {
|
||||||
@ -178,8 +177,7 @@ public class FeedResource {
|
|||||||
} else { // Forward paging or first page
|
} else { // Forward paging or first page
|
||||||
threads = dao.list(entityLink, limitPosts, userId, filterType, limitParam, after, resolved, PaginationType.AFTER);
|
threads = dao.list(entityLink, limitPosts, userId, filterType, limitParam, after, resolved, PaginationType.AFTER);
|
||||||
}
|
}
|
||||||
threads.getData().forEach(thread -> addHref(uriInfo, thread));
|
addHref(uriInfo, threads.getData());
|
||||||
|
|
||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +247,7 @@ public class FeedResource {
|
|||||||
@Parameter(description = "Filter threads by whether it is active or resolved", schema = @Schema(type = "boolean"))
|
@Parameter(description = "Filter threads by whether it is active or resolved", schema = @Schema(type = "boolean"))
|
||||||
@DefaultValue("false")
|
@DefaultValue("false")
|
||||||
@QueryParam("isResolved")
|
@QueryParam("isResolved")
|
||||||
Boolean isResolved)
|
Boolean isResolved) {
|
||||||
throws IOException {
|
|
||||||
return dao.getThreadsCount(entityLink, isResolved);
|
return dao.getThreadsCount(entityLink, isResolved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,8 +136,7 @@ public class UsageResource {
|
|||||||
description =
|
description =
|
||||||
"Usage for number of days going back from this date in ISO 8601 format " + "(default = currentDate)")
|
"Usage for number of days going back from this date in ISO 8601 format " + "(default = currentDate)")
|
||||||
@QueryParam("date")
|
@QueryParam("date")
|
||||||
String date)
|
String date) {
|
||||||
throws IOException {
|
|
||||||
// TODO add href
|
// TODO add href
|
||||||
int actualDays = Math.min(Math.max(days, 1), 30);
|
int actualDays = Math.min(Math.max(days, 1), 30);
|
||||||
String actualDate = date == null ? RestUtil.DATE_FORMAT.format(new Date()) : date;
|
String actualDate = date == null ? RestUtil.DATE_FORMAT.format(new Date()) : date;
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
package org.openmetadata.catalog.security;
|
package org.openmetadata.catalog.security;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jdbi.v3.core.Jdbi;
|
import org.jdbi.v3.core.Jdbi;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
@ -22,7 +21,7 @@ import org.openmetadata.catalog.type.MetadataOperation;
|
|||||||
public interface Authorizer {
|
public interface Authorizer {
|
||||||
|
|
||||||
/** Initialize the authorizer */
|
/** Initialize the authorizer */
|
||||||
void init(AuthorizerConfiguration config, Jdbi jdbi) throws IOException;
|
void init(AuthorizerConfiguration config, Jdbi jdbi);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the authenticated user has given permission on the target entity identified by the given resourceType and
|
* Check if the authenticated user has given permission on the target entity identified by the given resourceType and
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
private String principalDomain;
|
private String principalDomain;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AuthorizerConfiguration config, Jdbi dbi) throws IOException {
|
public void init(AuthorizerConfiguration config, Jdbi dbi) {
|
||||||
LOG.debug("Initializing DefaultAuthorizer with config {}", config);
|
LOG.debug("Initializing DefaultAuthorizer with config {}", config);
|
||||||
this.adminUsers = new HashSet<>(config.getAdminPrincipals());
|
this.adminUsers = new HashSet<>(config.getAdminPrincipals());
|
||||||
this.botUsers = new HashSet<>(config.getBotPrincipals());
|
this.botUsers = new HashSet<>(config.getBotPrincipals());
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class JwtFilter implements ContainerRequestFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if expired
|
// Check if expired
|
||||||
// if the expiresAt set to null, treat it as never expiring token
|
// If expiresAt is set to null, treat it as never expiring token
|
||||||
if (jwt.getExpiresAt() != null
|
if (jwt.getExpiresAt() != null
|
||||||
&& jwt.getExpiresAt().before(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime())) {
|
&& jwt.getExpiresAt().before(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime())) {
|
||||||
throw new AuthenticationException("Expired token!");
|
throw new AuthenticationException("Expired token!");
|
||||||
|
|||||||
@ -17,8 +17,8 @@ import java.security.Principal;
|
|||||||
import javax.ws.rs.core.SecurityContext;
|
import javax.ws.rs.core.SecurityContext;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
/** Holds authenticated principal and security context which is passed to the JAX-RS request methods */
|
/** Holds authenticated principal and security context which is passed to the JAX-RS request methods */
|
||||||
|
@Slf4j
|
||||||
public class CatalogSecurityContext implements SecurityContext {
|
public class CatalogSecurityContext implements SecurityContext {
|
||||||
private final Principal principal;
|
private final Principal principal;
|
||||||
private final String scheme;
|
private final String scheme;
|
||||||
|
|||||||
@ -28,7 +28,6 @@ final class CommonFields {
|
|||||||
static final String ENTITY_TAGS = "entityTags";
|
static final String ENTITY_TAGS = "entityTags";
|
||||||
static final String ENTITY_TYPE = "entityType";
|
static final String ENTITY_TYPE = "entityType";
|
||||||
static final String OPERATION = "operation";
|
static final String OPERATION = "operation";
|
||||||
static final String USER_ROLES = "userRoles";
|
|
||||||
|
|
||||||
// By default, if no rule matches, do not grant access.
|
// By default, if no rule matches, do not grant access.
|
||||||
static final boolean DEFAULT_ACCESS = false;
|
static final boolean DEFAULT_ACCESS = false;
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public class PolicyEvaluator {
|
|||||||
LOG.info("Finished loading Access Control policies");
|
LOG.info("Finished loading Access Control policies");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if the policy has rules that gives permission to perform an operation on the given entity. */
|
/** Checks if the policy has rules that give permission to perform an operation on the given entity. */
|
||||||
public boolean hasPermission(@NonNull UUID policyId, EntityInterface entity, @NonNull MetadataOperation operation) {
|
public boolean hasPermission(@NonNull UUID policyId, EntityInterface entity, @NonNull MetadataOperation operation) {
|
||||||
AttributeBasedFacts facts =
|
AttributeBasedFacts facts =
|
||||||
new AttributeBasedFacts.AttributeBasedFactsBuilder()
|
new AttributeBasedFacts.AttributeBasedFactsBuilder()
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class SetAllowedOperationAction implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Facts facts) throws Exception {
|
public void execute(Facts facts) {
|
||||||
if (Boolean.FALSE.equals(rule.getAllow())) {
|
if (Boolean.FALSE.equals(rule.getAllow())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class SetPermissionAction implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Facts facts) throws Exception {
|
public void execute(Facts facts) {
|
||||||
facts.put(CommonFields.ALLOW, this.rule.getAllow());
|
facts.put(CommonFields.ALLOW, this.rule.getAllow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,7 +152,7 @@ public class SlackWebhookEventPublisher extends AbstractEventPublisher {
|
|||||||
&& changeDescription.getFieldsUpdated() != null
|
&& changeDescription.getFieldsUpdated() != null
|
||||||
&& !changeDescription.getFieldsUpdated().isEmpty()) {
|
&& !changeDescription.getFieldsUpdated().isEmpty()) {
|
||||||
for (FieldChange fieldChange : changeDescription.getFieldsUpdated()) {
|
for (FieldChange fieldChange : changeDescription.getFieldsUpdated()) {
|
||||||
// when the entity is deleted we will get deleted set as true. We do not need to parse this for slack messages.
|
// when the entity is deleted we will get deleted set as true. We do not need to parse this for Slack messages.
|
||||||
if (!fieldChange.getName().equals(FIELD_DELETED)) {
|
if (!fieldChange.getName().equals(FIELD_DELETED)) {
|
||||||
SlackAttachment attachment = new SlackAttachment();
|
SlackAttachment attachment = new SlackAttachment();
|
||||||
attachment.setTitle("Updated " + fieldChange.getName());
|
attachment.setTitle("Updated " + fieldChange.getName());
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.joda.time.Period;
|
import org.joda.time.Period;
|
||||||
import org.joda.time.format.ISOPeriodFormat;
|
import org.joda.time.format.ISOPeriodFormat;
|
||||||
import org.openmetadata.catalog.Entity;
|
import org.openmetadata.catalog.Entity;
|
||||||
import org.openmetadata.catalog.EntityInterface;
|
|
||||||
import org.openmetadata.catalog.api.data.TermReference;
|
import org.openmetadata.catalog.api.data.TermReference;
|
||||||
import org.openmetadata.catalog.entity.data.GlossaryTerm;
|
import org.openmetadata.catalog.entity.data.GlossaryTerm;
|
||||||
import org.openmetadata.catalog.entity.data.Table;
|
import org.openmetadata.catalog.entity.data.Table;
|
||||||
@ -88,9 +87,6 @@ public final class EntityUtil {
|
|||||||
//
|
//
|
||||||
public static final BiPredicate<Object, Object> objectMatch = Object::equals;
|
public static final BiPredicate<Object, Object> objectMatch = Object::equals;
|
||||||
|
|
||||||
public static final BiPredicate<EntityInterface, EntityInterface> entityMatch =
|
|
||||||
(ref1, ref2) -> ref1.getId().equals(ref2.getId());
|
|
||||||
|
|
||||||
public static final BiPredicate<EntityReference, EntityReference> entityReferenceMatch =
|
public static final BiPredicate<EntityReference, EntityReference> entityReferenceMatch =
|
||||||
(ref1, ref2) -> ref1.getId().equals(ref2.getId()) && ref1.getType().equals(ref2.getType());
|
(ref1, ref2) -> ref1.getId().equals(ref2.getId()) && ref1.getType().equals(ref2.getType());
|
||||||
|
|
||||||
@ -195,7 +191,7 @@ public final class EntityUtil {
|
|||||||
return refs;
|
return refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityReference validateEntityLink(EntityLink entityLink) throws IOException {
|
public static EntityReference validateEntityLink(EntityLink entityLink) {
|
||||||
String entityType = entityLink.getEntityType();
|
String entityType = entityLink.getEntityType();
|
||||||
String fqn = entityLink.getEntityFQN();
|
String fqn = entityLink.getEntityFQN();
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class FullyQualifiedName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class SplitListener extends FqnBaseListener {
|
private static class SplitListener extends FqnBaseListener {
|
||||||
List<String> list = new ArrayList<>();
|
final List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
public String[] split() {
|
public String[] split() {
|
||||||
return list.toArray(new String[0]);
|
return list.toArray(new String[0]);
|
||||||
|
|||||||
@ -16,11 +16,9 @@ package org.openmetadata.catalog.util;
|
|||||||
import static org.openmetadata.catalog.util.RestUtil.DATE_TIME_FORMAT;
|
import static org.openmetadata.catalog.util.RestUtil.DATE_TIME_FORMAT;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.io.JsonStringEncoder;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||||
import com.fasterxml.jackson.datatype.jsr353.JSR353Module;
|
import com.fasterxml.jackson.datatype.jsr353.JSR353Module;
|
||||||
import com.networknt.schema.JsonSchema;
|
import com.networknt.schema.JsonSchema;
|
||||||
@ -45,7 +43,6 @@ import javax.json.JsonPatch;
|
|||||||
import javax.json.JsonReader;
|
import javax.json.JsonReader;
|
||||||
import javax.json.JsonStructure;
|
import javax.json.JsonStructure;
|
||||||
import javax.json.JsonValue;
|
import javax.json.JsonValue;
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.openmetadata.catalog.entity.Type;
|
import org.openmetadata.catalog.entity.Type;
|
||||||
import org.openmetadata.catalog.entity.type.Category;
|
import org.openmetadata.catalog.entity.type.Category;
|
||||||
@ -54,7 +51,6 @@ import org.openmetadata.catalog.entity.type.Category;
|
|||||||
public final class JsonUtils {
|
public final class JsonUtils {
|
||||||
public static final String FIELD_TYPE_ANNOTATION = "@om-field-type";
|
public static final String FIELD_TYPE_ANNOTATION = "@om-field-type";
|
||||||
public static final String ENTITY_TYPE_ANNOTATION = "@om-entity-type";
|
public static final String ENTITY_TYPE_ANNOTATION = "@om-entity-type";
|
||||||
public static final MediaType DEFAULT_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
|
|
||||||
public static final String JSON_FILE_EXTENSION = ".json";
|
public static final String JSON_FILE_EXTENSION = ".json";
|
||||||
private static final ObjectMapper OBJECT_MAPPER;
|
private static final ObjectMapper OBJECT_MAPPER;
|
||||||
private static final JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V7);
|
private static final JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V7);
|
||||||
@ -210,10 +206,6 @@ public final class JsonUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String jsonToString(String json) {
|
|
||||||
return String.valueOf(JsonStringEncoder.getInstance().quoteAsString(json));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonSchema getJsonSchema(String schema) {
|
public static JsonSchema getJsonSchema(String schema) {
|
||||||
return schemaFactory.getSchema(schema);
|
return schemaFactory.getSchema(schema);
|
||||||
}
|
}
|
||||||
@ -222,10 +214,6 @@ public final class JsonUtils {
|
|||||||
return OBJECT_MAPPER.valueToTree(object);
|
return OBJECT_MAPPER.valueToTree(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectNode createObject() {
|
|
||||||
return OBJECT_MAPPER.createObjectNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasAnnotation(JsonNode jsonNode, String annotation) {
|
public static boolean hasAnnotation(JsonNode jsonNode, String annotation) {
|
||||||
String comment = String.valueOf(jsonNode.get("$comment"));
|
String comment = String.valueOf(jsonNode.get("$comment"));
|
||||||
return comment != null && comment.contains(annotation);
|
return comment != null && comment.contains(annotation);
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import org.openmetadata.catalog.services.connections.metadata.OpenMetadataServer
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public final class OpenMetadataClientSecurityUtil {
|
public final class OpenMetadataClientSecurityUtil {
|
||||||
public static final String CLIENT_ID = "clientId";
|
public static final String CLIENT_ID = "clientId";
|
||||||
public static final String AUDIENCE = "audience";
|
|
||||||
public static final String DOMAIN = "domain";
|
public static final String DOMAIN = "domain";
|
||||||
public static final String EMAIL = "email";
|
public static final String EMAIL = "email";
|
||||||
public static final String SCOPES = "scopes";
|
public static final String SCOPES = "scopes";
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import org.openmetadata.catalog.exception.PipelineServiceClientException;
|
|||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>A PipelineService is a service such as AirFlow to which a pipeline can be deployed
|
* <li>A PipelineService is a service such as AirFlow to which a pipeline can be deployed
|
||||||
* <li>A Pipeline is a workflow for performing certain taks. Example - ingestion pipeline is a workflow that connects
|
* <li>A Pipeline is a workflow for performing certain tasks. Example - ingestion pipeline is a workflow that connects
|
||||||
* to a database service or other services and collect metadata.
|
* to a database service or other services and collect metadata.
|
||||||
* <li>Pipeline uses `Connection` to a service as dependency. A Pipeline might need to connection to database service
|
* <li>Pipeline uses `Connection` to a service as dependency. A Pipeline might need to connection to database service
|
||||||
* to collect metadata, OpenMetadata to user metadata over APIs, etc.
|
* to collect metadata, OpenMetadata to user metadata over APIs, etc.
|
||||||
@ -67,7 +67,7 @@ public abstract class PipelineServiceClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Authenticate with the service */
|
/* Authenticate with the service */
|
||||||
public abstract String authenticate() throws IOException;
|
public abstract String authenticate();
|
||||||
|
|
||||||
/* Check the status of pipeline service to ensure it is healthy */
|
/* Check the status of pipeline service to ensure it is healthy */
|
||||||
public abstract HttpResponse<String> getServiceStatus();
|
public abstract HttpResponse<String> getServiceStatus();
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import static org.openmetadata.catalog.exception.CatalogExceptionMessage.noPermi
|
|||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.notAdmin;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.notAdmin;
|
||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.readOnlyAttribute;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.readOnlyAttribute;
|
||||||
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
||||||
|
import static org.openmetadata.catalog.security.SecurityUtil.getPrincipalName;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ENTITY_NAME_LENGTH_ERROR;
|
import static org.openmetadata.catalog.util.TestUtils.ENTITY_NAME_LENGTH_ERROR;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.LONG_ENTITY_NAME;
|
import static org.openmetadata.catalog.util.TestUtils.LONG_ENTITY_NAME;
|
||||||
@ -123,6 +124,7 @@ import org.openmetadata.catalog.resources.tags.TagResourceTest;
|
|||||||
import org.openmetadata.catalog.resources.teams.RoleResourceTest;
|
import org.openmetadata.catalog.resources.teams.RoleResourceTest;
|
||||||
import org.openmetadata.catalog.resources.teams.TeamResourceTest;
|
import org.openmetadata.catalog.resources.teams.TeamResourceTest;
|
||||||
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
||||||
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.ChangeDescription;
|
import org.openmetadata.catalog.type.ChangeDescription;
|
||||||
import org.openmetadata.catalog.type.ChangeEvent;
|
import org.openmetadata.catalog.type.ChangeEvent;
|
||||||
import org.openmetadata.catalog.type.Column;
|
import org.openmetadata.catalog.type.Column;
|
||||||
@ -329,12 +331,14 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
// Entity specific validate for entity create using PUT
|
// Entity specific validate for entity create using PUT
|
||||||
public void validateUpdatedEntity(T updatedEntity, K request, Map<String, String> authHeaders)
|
public void validateUpdatedEntity(T updatedEntity, K request, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
|
validateCommonEntityFields(updatedEntity, request, authHeaders);
|
||||||
validateCreatedEntity(updatedEntity, request, authHeaders);
|
validateCreatedEntity(updatedEntity, request, authHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateDeletedEntity(
|
protected void validateDeletedEntity(
|
||||||
K create, T entityBeforeDeletion, T entityAfterDeletion, Map<String, String> authHeaders)
|
K create, T entityBeforeDeletion, T entityAfterDeletion, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
|
validateCommonEntityFields(entityAfterDeletion, create, authHeaders);
|
||||||
validateCreatedEntity(entityAfterDeletion, create, authHeaders);
|
validateCreatedEntity(entityAfterDeletion, create, authHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1382,23 +1386,23 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
/** Helper function to create an entity, submit POST API request and validate response. */
|
/** Helper function to create an entity, submit POST API request and validate response. */
|
||||||
public final T createAndCheckEntity(K create, Map<String, String> authHeaders, K created) throws IOException {
|
public final T createAndCheckEntity(K create, Map<String, String> authHeaders, K created) throws IOException {
|
||||||
// Validate an entity that is created has all the information set in create request
|
// Validate an entity that is created has all the information set in create request
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = SecurityUtil.getPrincipalName(authHeaders);
|
||||||
T entity = createEntity(create, authHeaders);
|
T entity = createEntity(create, authHeaders);
|
||||||
|
|
||||||
assertEquals(updatedBy, entity.getUpdatedBy());
|
assertEquals(updatedBy, entity.getUpdatedBy());
|
||||||
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
||||||
assertEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension()));
|
validateCommonEntityFields(entity, created, authHeaders);
|
||||||
validateCreatedEntity(entity, created, authHeaders);
|
validateCreatedEntity(entity, created, authHeaders);
|
||||||
|
|
||||||
// GET the entity created and ensure it has all the information set in create request
|
// GET the entity created and ensure it has all the information set in create request
|
||||||
T getEntity = getEntity(entity.getId(), authHeaders);
|
T getEntity = getEntity(entity.getId(), authHeaders);
|
||||||
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
||||||
assertEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(getEntity.getExtension()));
|
validateCommonEntityFields(entity, created, authHeaders);
|
||||||
validateCreatedEntity(getEntity, created, authHeaders);
|
validateCreatedEntity(getEntity, created, authHeaders);
|
||||||
|
|
||||||
getEntity = getEntityByName(entity.getFullyQualifiedName(), allFields, authHeaders);
|
getEntity = getEntityByName(entity.getFullyQualifiedName(), allFields, authHeaders);
|
||||||
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
assertEquals(0.1, entity.getVersion()); // First version of the entity
|
||||||
assertEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(getEntity.getExtension()));
|
validateCommonEntityFields(entity, created, authHeaders);
|
||||||
validateCreatedEntity(getEntity, created, authHeaders);
|
validateCreatedEntity(getEntity, created, authHeaders);
|
||||||
|
|
||||||
// Validate that change event was created
|
// Validate that change event was created
|
||||||
@ -1481,6 +1485,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
// Validate information returned in patch response has the updates
|
// Validate information returned in patch response has the updates
|
||||||
T returned = patchEntity(updated.getId(), originalJson, updated, authHeaders);
|
T returned = patchEntity(updated.getId(), originalJson, updated, authHeaders);
|
||||||
|
|
||||||
|
validateCommonEntityFields(updated, returned, authHeaders);
|
||||||
compareEntities(updated, returned, authHeaders);
|
compareEntities(updated, returned, authHeaders);
|
||||||
validateChangeDescription(returned, updateType, expectedChange);
|
validateChangeDescription(returned, updateType, expectedChange);
|
||||||
validateEntityHistory(returned.getId(), updateType, expectedChange, authHeaders);
|
validateEntityHistory(returned.getId(), updateType, expectedChange, authHeaders);
|
||||||
@ -1488,6 +1493,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
|
|
||||||
// GET the entity and Validate information returned
|
// GET the entity and Validate information returned
|
||||||
T getEntity = getEntity(returned.getId(), authHeaders);
|
T getEntity = getEntity(returned.getId(), authHeaders);
|
||||||
|
validateCommonEntityFields(updated, returned, authHeaders);
|
||||||
compareEntities(updated, getEntity, authHeaders);
|
compareEntities(updated, getEntity, authHeaders);
|
||||||
validateChangeDescription(getEntity, updateType, expectedChange);
|
validateChangeDescription(getEntity, updateType, expectedChange);
|
||||||
|
|
||||||
@ -1525,12 +1531,24 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
entity, originalJson, authHeaders(userName + "@open-metadata.org"), MINOR_UPDATE, change);
|
entity, originalJson, authHeaders(userName + "@open-metadata.org"), MINOR_UPDATE, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void validateCommonEntityFields(
|
protected final void validateCommonEntityFields(T entity, CreateEntity create, Map<String, String> authHeaders) {
|
||||||
T entity, String expectedDescription, String expectedUpdatedByUser, EntityReference expectedOwner) {
|
|
||||||
assertListNotNull(entity.getId(), entity.getHref(), entity.getFullyQualifiedName());
|
assertListNotNull(entity.getId(), entity.getHref(), entity.getFullyQualifiedName());
|
||||||
assertEquals(expectedDescription, entity.getDescription());
|
assertEquals(create.getName(), entity.getName());
|
||||||
assertEquals(expectedUpdatedByUser, entity.getUpdatedBy());
|
assertEquals(create.getDisplayName(), entity.getDisplayName());
|
||||||
assertReference(expectedOwner, entity.getOwner());
|
assertEquals(create.getDescription(), entity.getDescription());
|
||||||
|
assertEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension()));
|
||||||
|
assertEquals(create.getOwner(), entity.getOwner());
|
||||||
|
assertEquals(getPrincipalName(authHeaders), entity.getUpdatedBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void validateCommonEntityFields(T expected, T actual, Map<String, String> authHeaders) {
|
||||||
|
assertListNotNull(actual.getId(), actual.getHref(), actual.getFullyQualifiedName());
|
||||||
|
assertEquals(expected.getName(), actual.getName());
|
||||||
|
assertEquals(expected.getDisplayName(), actual.getDisplayName());
|
||||||
|
assertEquals(expected.getDescription(), actual.getDescription());
|
||||||
|
assertEquals(JsonUtils.valueToTree(expected.getExtension()), JsonUtils.valueToTree(actual.getExtension()));
|
||||||
|
assertEquals(expected.getOwner(), actual.getOwner());
|
||||||
|
assertEquals(getPrincipalName(authHeaders), actual.getUpdatedBy());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void validateChangeDescription(T updated, UpdateType updateType, ChangeDescription expectedChange)
|
protected final void validateChangeDescription(T updated, UpdateType updateType, ChangeDescription expectedChange)
|
||||||
@ -1621,7 +1639,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
assertEquals(entityType, changeEvent.getEntityType());
|
assertEquals(entityType, changeEvent.getEntityType());
|
||||||
assertEquals(entity.getId(), changeEvent.getEntityId());
|
assertEquals(entity.getId(), changeEvent.getEntityId());
|
||||||
assertEquals(entity.getVersion(), changeEvent.getCurrentVersion());
|
assertEquals(entity.getVersion(), changeEvent.getCurrentVersion());
|
||||||
assertEquals(TestUtils.getPrincipal(authHeaders), changeEvent.getUserName());
|
assertEquals(SecurityUtil.getPrincipalName(authHeaders), changeEvent.getUserName());
|
||||||
|
|
||||||
//
|
//
|
||||||
// previous, entity, changeDescription
|
// previous, entity, changeDescription
|
||||||
@ -1630,7 +1648,9 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
assertEquals(EventType.ENTITY_CREATED, changeEvent.getEventType());
|
assertEquals(EventType.ENTITY_CREATED, changeEvent.getEventType());
|
||||||
assertEquals(0.1, changeEvent.getPreviousVersion());
|
assertEquals(0.1, changeEvent.getPreviousVersion());
|
||||||
assertNull(changeEvent.getChangeDescription());
|
assertNull(changeEvent.getChangeDescription());
|
||||||
compareEntities(entity, JsonUtils.readValue((String) changeEvent.getEntity(), entityClass), authHeaders);
|
T changeEventEntity = JsonUtils.readValue((String) changeEvent.getEntity(), entityClass);
|
||||||
|
validateCommonEntityFields(entity, changeEventEntity, authHeaders);
|
||||||
|
compareEntities(entity, changeEventEntity, authHeaders);
|
||||||
} else if (expectedEventType == EventType.ENTITY_UPDATED) {
|
} else if (expectedEventType == EventType.ENTITY_UPDATED) {
|
||||||
assertChangeDescription(expectedChangeDescription, changeEvent.getChangeDescription());
|
assertChangeDescription(expectedChangeDescription, changeEvent.getChangeDescription());
|
||||||
} else if (expectedEventType == EventType.ENTITY_DELETED) {
|
} else if (expectedEventType == EventType.ENTITY_DELETED) {
|
||||||
@ -1641,7 +1661,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
private void validateDeletedEvent(
|
private void validateDeletedEvent(
|
||||||
UUID id, long timestamp, EventType expectedEventType, Double expectedVersion, Map<String, String> authHeaders)
|
UUID id, long timestamp, EventType expectedEventType, Double expectedVersion, Map<String, String> authHeaders)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = SecurityUtil.getPrincipalName(authHeaders);
|
||||||
ResultList<ChangeEvent> changeEvents;
|
ResultList<ChangeEvent> changeEvents;
|
||||||
ChangeEvent changeEvent = null;
|
ChangeEvent changeEvent = null;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package org.openmetadata.catalog.resources.bots;
|
package org.openmetadata.catalog.resources.bots;
|
||||||
|
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.getPrincipal;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -20,7 +19,6 @@ import org.openmetadata.catalog.resources.EntityResourceTest;
|
|||||||
import org.openmetadata.catalog.resources.bots.BotResource.BotList;
|
import org.openmetadata.catalog.resources.bots.BotResource.BotList;
|
||||||
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.util.TestUtils;
|
|
||||||
|
|
||||||
public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||||
public static User botUser;
|
public static User botUser;
|
||||||
@ -65,13 +63,11 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Bot entity, CreateBot request, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Bot entity, CreateBot request, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(entity, request.getDescription(), getPrincipal(authHeaders), null);
|
|
||||||
assertReference(request.getBotUser(), entity.getBotUser());
|
assertReference(request.getBotUser(), entity.getBotUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Bot expected, Bot updated, Map<String, String> authHeaders) throws HttpResponseException {
|
public void compareEntities(Bot expected, Bot updated, Map<String, String> authHeaders) throws HttpResponseException {
|
||||||
validateCommonEntityFields(updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
assertReference(expected.getBotUser(), updated.getBotUser());
|
assertReference(expected.getBotUser(), updated.getBotUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,6 @@ import org.openmetadata.catalog.resources.charts.ChartResource.ChartList;
|
|||||||
import org.openmetadata.catalog.type.ChartType;
|
import org.openmetadata.catalog.type.ChartType;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.util.ResultList;
|
import org.openmetadata.catalog.util.ResultList;
|
||||||
import org.openmetadata.catalog.util.TestUtils;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
||||||
@ -117,16 +116,12 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Chart chart, CreateChart createRequest, Map<String, String> authHeaders) {
|
public void validateCreatedEntity(Chart chart, CreateChart createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
chart, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertNotNull(chart.getServiceType());
|
assertNotNull(chart.getServiceType());
|
||||||
assertReference(createRequest.getService(), chart.getService());
|
assertReference(createRequest.getService(), chart.getService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Chart expected, Chart patched, Map<String, String> authHeaders) {
|
public void compareEntities(Chart expected, Chart patched, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
assertReference(expected.getService(), patched.getService());
|
assertReference(expected.getService(), patched.getService());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,8 +215,6 @@ public class DashboardResourceTest extends EntityResourceTest<Dashboard, CreateD
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Dashboard dashboard, CreateDashboard createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Dashboard dashboard, CreateDashboard createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
dashboard, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertNotNull(dashboard.getServiceType());
|
assertNotNull(dashboard.getServiceType());
|
||||||
assertReference(createRequest.getService(), dashboard.getService());
|
assertReference(createRequest.getService(), dashboard.getService());
|
||||||
validateDashboardCharts(dashboard, createRequest.getCharts());
|
validateDashboardCharts(dashboard, createRequest.getCharts());
|
||||||
|
|||||||
@ -155,9 +155,6 @@ public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Database database, CreateDatabase createRequest, Map<String, String> authHeaders) {
|
public void validateCreatedEntity(Database database, CreateDatabase createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
database, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
// Validate service
|
// Validate service
|
||||||
assertNotNull(database.getServiceType());
|
assertNotNull(database.getServiceType());
|
||||||
assertReference(createRequest.getService(), database.getService());
|
assertReference(createRequest.getService(), database.getService());
|
||||||
@ -167,9 +164,6 @@ public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Database expected, Database updated, Map<String, String> authHeaders) {
|
public void compareEntities(Database expected, Database updated, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
// Validate service
|
|
||||||
assertReference(expected.getService(), updated.getService());
|
assertReference(expected.getService(), updated.getService());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
FullyQualifiedName.add(updated.getService().getName(), updated.getName()), updated.getFullyQualifiedName());
|
FullyQualifiedName.add(updated.getService().getName(), updated.getName()), updated.getFullyQualifiedName());
|
||||||
|
|||||||
@ -117,9 +117,6 @@ public class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchem
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
DatabaseSchema schema, CreateDatabaseSchema createRequest, Map<String, String> authHeaders) {
|
DatabaseSchema schema, CreateDatabaseSchema createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
schema, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
// Validate service
|
// Validate service
|
||||||
assertNotNull(schema.getServiceType());
|
assertNotNull(schema.getServiceType());
|
||||||
assertReference(createRequest.getDatabase(), schema.getDatabase());
|
assertReference(createRequest.getDatabase(), schema.getDatabase());
|
||||||
@ -130,8 +127,6 @@ public class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(DatabaseSchema expected, DatabaseSchema updated, Map<String, String> authHeaders) {
|
public void compareEntities(DatabaseSchema expected, DatabaseSchema updated, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
// Validate service
|
// Validate service
|
||||||
assertReference(expected.getDatabase(), updated.getDatabase());
|
assertReference(expected.getDatabase(), updated.getDatabase());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
|||||||
@ -2047,9 +2047,6 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Table createdEntity, CreateTable createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Table createdEntity, CreateTable createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
createdEntity, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validation
|
// Entity specific validation
|
||||||
assertEquals(createRequest.getTableType(), createdEntity.getTableType());
|
assertEquals(createRequest.getTableType(), createdEntity.getTableType());
|
||||||
assertColumns(createRequest.getColumns(), createdEntity.getColumns());
|
assertColumns(createRequest.getColumns(), createdEntity.getColumns());
|
||||||
@ -2085,9 +2082,6 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(Table expected, Table patched, Map<String, String> authHeaders)
|
public void compareEntities(Table expected, Table patched, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validation
|
// Entity specific validation
|
||||||
assertEquals(expected.getTableType(), patched.getTableType());
|
assertEquals(expected.getTableType(), patched.getTableType());
|
||||||
assertColumns(expected.getColumns(), patched.getColumns());
|
assertColumns(expected.getColumns(), patched.getColumns());
|
||||||
|
|||||||
@ -46,7 +46,6 @@ import org.openmetadata.catalog.type.Webhook;
|
|||||||
import org.openmetadata.catalog.type.Webhook.Status;
|
import org.openmetadata.catalog.type.Webhook.Status;
|
||||||
import org.openmetadata.catalog.util.EntityUtil;
|
import org.openmetadata.catalog.util.EntityUtil;
|
||||||
import org.openmetadata.catalog.util.JsonUtils;
|
import org.openmetadata.catalog.util.JsonUtils;
|
||||||
import org.openmetadata.catalog.util.TestUtils;
|
|
||||||
import org.openmetadata.catalog.util.TestUtils.UpdateType;
|
import org.openmetadata.catalog.util.TestUtils.UpdateType;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -232,7 +231,6 @@ public class WebhookResourceTest extends EntityResourceTest<Webhook, CreateWebho
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Webhook webhook, CreateWebhook createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Webhook webhook, CreateWebhook createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(webhook, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
assertEquals(createRequest.getName(), webhook.getName());
|
assertEquals(createRequest.getName(), webhook.getName());
|
||||||
ArrayList<EventFilter> filters = new ArrayList<>(createRequest.getEventFilters());
|
ArrayList<EventFilter> filters = new ArrayList<>(createRequest.getEventFilters());
|
||||||
EntityUtil.addSoftDeleteFilter(filters);
|
EntityUtil.addSoftDeleteFilter(filters);
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.noPermission;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.noPermission;
|
||||||
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
||||||
|
import static org.openmetadata.catalog.security.SecurityUtil.getPrincipalName;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_USER_NAME;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_USER_NAME;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.NON_EXISTENT_ENTITY;
|
import static org.openmetadata.catalog.util.TestUtils.NON_EXISTENT_ENTITY;
|
||||||
@ -121,7 +122,8 @@ public class FeedResourceTest extends CatalogApplicationTest {
|
|||||||
.withDescription("Team2 description")
|
.withDescription("Team2 description")
|
||||||
.withUsers(List.of(USER2.getId()));
|
.withUsers(List.of(USER2.getId()));
|
||||||
TEAM2 = teamResourceTest.createAndCheckEntity(createTeam, ADMIN_AUTH_HEADERS);
|
TEAM2 = teamResourceTest.createAndCheckEntity(createTeam, ADMIN_AUTH_HEADERS);
|
||||||
EntityReference TEAM2_REF = new EntityReference().withId(TEAM2.getId()).withType(Entity.TEAM);
|
EntityReference TEAM2_REF = TEAM2.getEntityReference();
|
||||||
|
|
||||||
CreateTable createTable2 = tableResourceTest.createRequest(test);
|
CreateTable createTable2 = tableResourceTest.createRequest(test);
|
||||||
createTable2.withName("table2").withOwner(TEAM2_REF);
|
createTable2.withName("table2").withOwner(TEAM2_REF);
|
||||||
TABLE2 = tableResourceTest.createAndCheckEntity(createTable2, ADMIN_AUTH_HEADERS);
|
TABLE2 = tableResourceTest.createAndCheckEntity(createTable2, ADMIN_AUTH_HEADERS);
|
||||||
@ -780,6 +782,6 @@ public class FeedResourceTest extends CatalogApplicationTest {
|
|||||||
assertListNotNull(patched.getId(), patched.getHref(), patched.getAbout());
|
assertListNotNull(patched.getId(), patched.getHref(), patched.getAbout());
|
||||||
assertEquals(expected.getMessage(), patched.getMessage());
|
assertEquals(expected.getMessage(), patched.getMessage());
|
||||||
assertEquals(expected.getResolved(), patched.getResolved());
|
assertEquals(expected.getResolved(), patched.getResolved());
|
||||||
assertEquals(TestUtils.getPrincipal(authHeaders), patched.getUpdatedBy());
|
assertEquals(getPrincipalName(authHeaders), patched.getUpdatedBy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,19 +133,12 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
|
|||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
Glossary createdEntity, CreateGlossary createRequest, Map<String, String> authHeaders)
|
Glossary createdEntity, CreateGlossary createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
createdEntity, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validation
|
|
||||||
TestUtils.validateTags(createRequest.getTags(), createdEntity.getTags());
|
TestUtils.validateTags(createRequest.getTags(), createdEntity.getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Glossary expected, Glossary patched, Map<String, String> authHeaders)
|
public void compareEntities(Glossary expected, Glossary patched, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validation
|
// Entity specific validation
|
||||||
TestUtils.validateTags(expected.getTags(), patched.getTags());
|
TestUtils.validateTags(expected.getTags(), patched.getTags());
|
||||||
TestUtils.assertEntityReferenceList(expected.getReviewers(), patched.getReviewers());
|
TestUtils.assertEntityReferenceList(expected.getReviewers(), patched.getReviewers());
|
||||||
|
|||||||
@ -312,7 +312,6 @@ public class GlossaryTermResourceTest extends EntityResourceTest<GlossaryTerm, C
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(GlossaryTerm entity, CreateGlossaryTerm request, Map<String, String> authHeaders)
|
public void validateCreatedEntity(GlossaryTerm entity, CreateGlossaryTerm request, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(entity, request.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
assertReference(request.getParent(), entity.getParent());
|
assertReference(request.getParent(), entity.getParent());
|
||||||
assertReference(request.getGlossary(), entity.getGlossary());
|
assertReference(request.getGlossary(), entity.getGlossary());
|
||||||
|
|
||||||
@ -343,8 +342,6 @@ public class GlossaryTermResourceTest extends EntityResourceTest<GlossaryTerm, C
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(GlossaryTerm expected, GlossaryTerm patched, Map<String, String> authHeaders)
|
public void compareEntities(GlossaryTerm expected, GlossaryTerm patched, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
assertReference(expected.getGlossary(), patched.getGlossary());
|
assertReference(expected.getGlossary(), patched.getGlossary());
|
||||||
assertReference(expected.getParent(), patched.getParent());
|
assertReference(expected.getParent(), patched.getParent());
|
||||||
assertEquals(expected.getFullyQualifiedName(), patched.getFullyQualifiedName());
|
assertEquals(expected.getFullyQualifiedName(), patched.getFullyQualifiedName());
|
||||||
|
|||||||
@ -75,8 +75,6 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Location location, CreateLocation createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Location location, CreateLocation createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
location, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getPath(), location.getPath());
|
assertEquals(createRequest.getPath(), location.getPath());
|
||||||
// Validate service
|
// Validate service
|
||||||
EntityReference expectedService = createRequest.getService();
|
EntityReference expectedService = createRequest.getService();
|
||||||
@ -91,9 +89,6 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(Location expected, Location patched, Map<String, String> authHeaders)
|
public void compareEntities(Location expected, Location patched, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
// Entity specific validation
|
|
||||||
assertEquals(expected.getDisplayName(), patched.getDisplayName());
|
assertEquals(expected.getDisplayName(), patched.getDisplayName());
|
||||||
assertEquals(expected.getFullyQualifiedName(), patched.getFullyQualifiedName());
|
assertEquals(expected.getFullyQualifiedName(), patched.getFullyQualifiedName());
|
||||||
assertEquals(expected.getLocationType(), patched.getLocationType());
|
assertEquals(expected.getLocationType(), patched.getLocationType());
|
||||||
|
|||||||
@ -137,10 +137,6 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Type createdEntity, CreateType createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Type createdEntity, CreateType createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
createdEntity, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
// Entity specific validation
|
|
||||||
assertEquals(createRequest.getSchema(), createdEntity.getSchema());
|
assertEquals(createRequest.getSchema(), createdEntity.getSchema());
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@ -148,9 +144,6 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(Type expected, Type patched, Map<String, String> authHeaders)
|
public void compareEntities(Type expected, Type patched, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(patched, expected.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
// Entity specific validation
|
|
||||||
assertEquals(expected.getSchema(), patched.getSchema());
|
assertEquals(expected.getSchema(), patched.getSchema());
|
||||||
// TODO more checks
|
// TODO more checks
|
||||||
}
|
}
|
||||||
|
|||||||
@ -379,9 +379,6 @@ public class MlModelResourceTest extends EntityResourceTest<MlModel, CreateMlMod
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(MlModel expected, MlModel updated, Map<String, String> authHeaders)
|
public void compareEntities(MlModel expected, MlModel updated, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validations
|
// Entity specific validations
|
||||||
assertEquals(expected.getAlgorithm(), updated.getAlgorithm());
|
assertEquals(expected.getAlgorithm(), updated.getAlgorithm());
|
||||||
assertEquals(expected.getDashboard(), updated.getDashboard());
|
assertEquals(expected.getDashboard(), updated.getDashboard());
|
||||||
@ -435,10 +432,6 @@ public class MlModelResourceTest extends EntityResourceTest<MlModel, CreateMlMod
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(MlModel createdEntity, CreateMlModel createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(MlModel createdEntity, CreateMlModel createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
createdEntity, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
// Entity specific validations
|
|
||||||
assertEquals(createRequest.getAlgorithm(), createdEntity.getAlgorithm());
|
assertEquals(createRequest.getAlgorithm(), createdEntity.getAlgorithm());
|
||||||
assertEquals(createRequest.getDashboard(), createdEntity.getDashboard());
|
assertEquals(createRequest.getDashboard(), createdEntity.getDashboard());
|
||||||
assertListProperty(createRequest.getMlFeatures(), createdEntity.getMlFeatures(), assertMlFeature);
|
assertListProperty(createRequest.getMlFeatures(), createdEntity.getMlFeatures(), assertMlFeature);
|
||||||
|
|||||||
@ -105,8 +105,6 @@ public class PipelineResourceTest extends EntityResourceTest<Pipeline, CreatePip
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Pipeline pipeline, CreatePipeline createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Pipeline pipeline, CreatePipeline createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
pipeline, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertNotNull(pipeline.getServiceType());
|
assertNotNull(pipeline.getServiceType());
|
||||||
assertReference(createRequest.getService(), pipeline.getService());
|
assertReference(createRequest.getService(), pipeline.getService());
|
||||||
validateTasks(createRequest.getTasks(), pipeline.getTasks());
|
validateTasks(createRequest.getTasks(), pipeline.getTasks());
|
||||||
@ -132,8 +130,6 @@ public class PipelineResourceTest extends EntityResourceTest<Pipeline, CreatePip
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(Pipeline expected, Pipeline updated, Map<String, String> authHeaders)
|
public void compareEntities(Pipeline expected, Pipeline updated, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
||||||
assertReference(expected.getService(), updated.getService());
|
assertReference(expected.getService(), updated.getService());
|
||||||
validateTasks(expected.getTasks(), updated.getTasks());
|
validateTasks(expected.getTasks(), updated.getTasks());
|
||||||
|
|||||||
@ -78,8 +78,6 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Policy policy, CreatePolicy createRequest, Map<String, String> authHeaders) {
|
public void validateCreatedEntity(Policy policy, CreatePolicy createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
policy, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getPolicyUrl(), policy.getPolicyUrl());
|
assertEquals(createRequest.getPolicyUrl(), policy.getPolicyUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import static javax.ws.rs.core.Response.Status.OK;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.getPrincipal;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -148,8 +147,6 @@ public class DashboardServiceResourceTest extends EntityResourceTest<DashboardSe
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
DashboardService service, CreateDashboardService createRequest, Map<String, String> authHeaders) {
|
DashboardService service, CreateDashboardService createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
service, createRequest.getDescription(), getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getName(), service.getName());
|
assertEquals(createRequest.getName(), service.getName());
|
||||||
DashboardConnection expectedConnection = createRequest.getConnection();
|
DashboardConnection expectedConnection = createRequest.getConnection();
|
||||||
DashboardConnection actualConnection = service.getConnection();
|
DashboardConnection actualConnection = service.getConnection();
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import static javax.ws.rs.core.Response.Status.OK;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponseContains;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponseContains;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.getPrincipal;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -262,10 +261,7 @@ public class DatabaseServiceResourceTest extends EntityResourceTest<DatabaseServ
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
DatabaseService service, CreateDatabaseService createRequest, Map<String, String> authHeaders) {
|
DatabaseService service, CreateDatabaseService createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
service, createRequest.getDescription(), getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getName(), service.getName());
|
assertEquals(createRequest.getName(), service.getName());
|
||||||
|
|
||||||
validateDatabaseConnection(createRequest.getConnection(), service.getConnection(), service.getServiceType());
|
validateDatabaseConnection(createRequest.getConnection(), service.getConnection(), service.getServiceType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -198,8 +198,6 @@ public class MessagingServiceResourceTest extends EntityResourceTest<MessagingSe
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
MessagingService service, CreateMessagingService createRequest, Map<String, String> authHeaders) {
|
MessagingService service, CreateMessagingService createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
service, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
MessagingConnection expectedMessagingConnection = createRequest.getConnection();
|
MessagingConnection expectedMessagingConnection = createRequest.getConnection();
|
||||||
MessagingConnection actualMessagingConnection = service.getConnection();
|
MessagingConnection actualMessagingConnection = service.getConnection();
|
||||||
validateConnection(expectedMessagingConnection, actualMessagingConnection, service.getServiceType());
|
validateConnection(expectedMessagingConnection, actualMessagingConnection, service.getServiceType());
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponseContains;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponseContains;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.getPrincipal;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -224,8 +223,6 @@ public class PipelineServiceResourceTest extends EntityResourceTest<PipelineServ
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
PipelineService service, CreatePipelineService createRequest, Map<String, String> authHeaders) {
|
PipelineService service, CreatePipelineService createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
service, createRequest.getDescription(), getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getName(), service.getName());
|
assertEquals(createRequest.getName(), service.getName());
|
||||||
|
|
||||||
Schedule expectedIngestion = createRequest.getIngestionSchedule();
|
Schedule expectedIngestion = createRequest.getIngestionSchedule();
|
||||||
|
|||||||
@ -15,7 +15,6 @@ package org.openmetadata.catalog.resources.services;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.getPrincipal;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -76,8 +75,6 @@ public class StorageServiceResourceTest extends EntityResourceTest<StorageServic
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
StorageService service, CreateStorageService createRequest, Map<String, String> authHeaders) {
|
StorageService service, CreateStorageService createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
service, createRequest.getDescription(), getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getName(), service.getName());
|
assertEquals(createRequest.getName(), service.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -138,8 +138,6 @@ public class IngestionPipelineResourceTest extends EntityResourceTest<IngestionP
|
|||||||
public void validateCreatedEntity(
|
public void validateCreatedEntity(
|
||||||
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders)
|
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
ingestion, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertEquals(createRequest.getAirflowConfig().getConcurrency(), ingestion.getAirflowConfig().getConcurrency());
|
assertEquals(createRequest.getAirflowConfig().getConcurrency(), ingestion.getAirflowConfig().getConcurrency());
|
||||||
validateSourceConfig(createRequest.getSourceConfig(), ingestion.getSource().getSourceConfig(), ingestion);
|
validateSourceConfig(createRequest.getSourceConfig(), ingestion.getSource().getSourceConfig(), ingestion);
|
||||||
}
|
}
|
||||||
@ -147,8 +145,6 @@ public class IngestionPipelineResourceTest extends EntityResourceTest<IngestionP
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders)
|
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
||||||
assertReference(expected.getService(), updated.getService());
|
assertReference(expected.getService(), updated.getService());
|
||||||
assertEquals(expected.getSource().getSourceConfig(), updated.getSource().getSourceConfig());
|
assertEquals(expected.getSource().getSourceConfig(), updated.getSource().getSourceConfig());
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
||||||
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
import static org.openmetadata.catalog.security.SecurityUtil.authHeaders;
|
||||||
|
import static org.openmetadata.catalog.security.SecurityUtil.getPrincipalName;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||||
@ -438,7 +439,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
private TagCategory createAndCheckCategory(CreateTagCategory create, Map<String, String> authHeaders)
|
private TagCategory createAndCheckCategory(CreateTagCategory create, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
WebTarget target = getResource("tags");
|
WebTarget target = getResource("tags");
|
||||||
TagCategory tagCategory = TestUtils.post(target, create, TagCategory.class, authHeaders);
|
TagCategory tagCategory = TestUtils.post(target, create, TagCategory.class, authHeaders);
|
||||||
TagCategory category =
|
TagCategory category =
|
||||||
@ -452,7 +453,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
private Tag createPrimaryTag(String category, CreateTag create, Map<String, String> authHeaders)
|
private Tag createPrimaryTag(String category, CreateTag create, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
WebTarget target = getResource("tags/" + category);
|
WebTarget target = getResource("tags/" + category);
|
||||||
|
|
||||||
// Ensure POST returns the primary tag as expected
|
// Ensure POST returns the primary tag as expected
|
||||||
@ -472,7 +473,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
private Tag createSecondaryTag(String category, String primaryTag, CreateTag create, Map<String, String> authHeaders)
|
private Tag createSecondaryTag(String category, String primaryTag, CreateTag create, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
WebTarget target = getResource("tags/" + category + "/" + primaryTag);
|
WebTarget target = getResource("tags/" + category + "/" + primaryTag);
|
||||||
|
|
||||||
// Ensure POST returns the secondary tag as expected
|
// Ensure POST returns the secondary tag as expected
|
||||||
@ -492,7 +493,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private void updateCategory(String category, CreateTagCategory update, Map<String, String> authHeaders) {
|
private void updateCategory(String category, CreateTagCategory update, Map<String, String> authHeaders) {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
WebTarget target = getResource("tags/" + category);
|
WebTarget target = getResource("tags/" + category);
|
||||||
|
|
||||||
// Ensure PUT returns the updated tag category
|
// Ensure PUT returns the updated tag category
|
||||||
@ -506,7 +507,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
private void updatePrimaryTag(String category, String primaryTag, CreateTag update, Map<String, String> authHeaders)
|
private void updatePrimaryTag(String category, String primaryTag, CreateTag update, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
String parentHref = getResource("tags/" + category).getUri().toString();
|
String parentHref = getResource("tags/" + category).getUri().toString();
|
||||||
WebTarget target = getResource("tags/" + category + "/" + primaryTag);
|
WebTarget target = getResource("tags/" + category + "/" + primaryTag);
|
||||||
|
|
||||||
@ -526,7 +527,7 @@ public class TagResourceTest extends CatalogApplicationTest {
|
|||||||
private void updateSecondaryTag(
|
private void updateSecondaryTag(
|
||||||
String category, String primaryTag, String secondaryTag, CreateTag update, Map<String, String> authHeaders)
|
String category, String primaryTag, String secondaryTag, CreateTag update, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
String updatedBy = TestUtils.getPrincipal(authHeaders);
|
String updatedBy = getPrincipalName(authHeaders);
|
||||||
String parentHref = getResource("tags/" + category + "/" + primaryTag).getUri().toString();
|
String parentHref = getResource("tags/" + category + "/" + primaryTag).getUri().toString();
|
||||||
WebTarget target = getResource("tags/" + category + "/" + primaryTag + "/" + secondaryTag);
|
WebTarget target = getResource("tags/" + category + "/" + primaryTag + "/" + secondaryTag);
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.noPermission;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.noPermission;
|
||||||
|
import static org.openmetadata.catalog.security.SecurityUtil.getPrincipalName;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
||||||
@ -201,7 +202,7 @@ public class RoleResourceTest extends EntityResourceTest<Role, CreateRole> {
|
|||||||
ADMIN_AUTH_HEADERS);
|
ADMIN_AUTH_HEADERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
String updatedBy = TestUtils.getPrincipal(ADMIN_AUTH_HEADERS);
|
String updatedBy = getPrincipalName(ADMIN_AUTH_HEADERS);
|
||||||
role =
|
role =
|
||||||
byName
|
byName
|
||||||
? getEntityByName(role.getName(), null, null, ADMIN_AUTH_HEADERS)
|
? getEntityByName(role.getName(), null, null, ADMIN_AUTH_HEADERS)
|
||||||
@ -229,14 +230,11 @@ public class RoleResourceTest extends EntityResourceTest<Role, CreateRole> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Role role, CreateRole createRequest, Map<String, String> authHeaders) {
|
public void validateCreatedEntity(Role role, CreateRole createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(role, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
assertEntityReferenceList(role.getPolicies(), createRequest.getPolicies());
|
assertEntityReferenceList(role.getPolicies(), createRequest.getPolicies());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Role expected, Role updated, Map<String, String> authHeaders) {
|
public void compareEntities(Role expected, Role updated, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import static javax.ws.rs.core.Response.Status.FORBIDDEN;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.openmetadata.catalog.security.SecurityUtil.getPrincipalName;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
||||||
@ -346,7 +347,7 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
|||||||
userResourceTest.createEntity(create, ADMIN_AUTH_HEADERS);
|
userResourceTest.createEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
String updatedBy = TestUtils.getPrincipal(ADMIN_AUTH_HEADERS);
|
String updatedBy = getPrincipalName(ADMIN_AUTH_HEADERS);
|
||||||
String fields = "";
|
String fields = "";
|
||||||
Team getTeam =
|
Team getTeam =
|
||||||
byName
|
byName
|
||||||
@ -383,9 +384,6 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Team team, CreateTeam createRequest, Map<String, String> authHeaders) {
|
public void validateCreatedEntity(Team team, CreateTeam createRequest, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
team, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
|
|
||||||
assertEquals(createRequest.getProfile(), team.getProfile());
|
assertEquals(createRequest.getProfile(), team.getProfile());
|
||||||
TestUtils.validateEntityReferences(team.getOwns());
|
TestUtils.validateEntityReferences(team.getOwns());
|
||||||
|
|
||||||
@ -404,11 +402,6 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
|||||||
TestUtils.assertEntityReferenceList(expectedDefaultRoles, team.getDefaultRoles());
|
TestUtils.assertEntityReferenceList(expectedDefaultRoles, team.getDefaultRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateUpdatedEntity(Team updatedEntity, CreateTeam request, Map<String, String> authHeaders) {
|
|
||||||
validateCreatedEntity(updatedEntity, request, authHeaders);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateDeletedEntity(
|
protected void validateDeletedEntity(
|
||||||
CreateTeam create, Team teamBeforeDeletion, Team teamAfterDeletion, Map<String, String> authHeaders)
|
CreateTeam create, Team teamBeforeDeletion, Team teamAfterDeletion, Map<String, String> authHeaders)
|
||||||
@ -424,9 +417,6 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(Team expected, Team updated, Map<String, String> authHeaders) {
|
public void compareEntities(Team expected, Team updated, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
|
|
||||||
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
||||||
assertEquals(expected.getProfile(), updated.getProfile());
|
assertEquals(expected.getProfile(), updated.getProfile());
|
||||||
TestUtils.validateEntityReferences(updated.getOwns());
|
TestUtils.validateEntityReferences(updated.getOwns());
|
||||||
|
|||||||
@ -793,8 +793,6 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(User user, CreateUser createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(User user, CreateUser createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(user, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
assertEquals(createRequest.getName(), user.getName());
|
assertEquals(createRequest.getName(), user.getName());
|
||||||
assertEquals(createRequest.getDisplayName(), user.getDisplayName());
|
assertEquals(createRequest.getDisplayName(), user.getDisplayName());
|
||||||
assertEquals(createRequest.getTimezone(), user.getTimezone());
|
assertEquals(createRequest.getTimezone(), user.getTimezone());
|
||||||
@ -820,8 +818,6 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compareEntities(User expected, User updated, Map<String, String> authHeaders) {
|
public void compareEntities(User expected, User updated, Map<String, String> authHeaders) {
|
||||||
validateCommonEntityFields(expected, expected.getDescription(), TestUtils.getPrincipal(authHeaders), null);
|
|
||||||
|
|
||||||
assertEquals(expected.getName(), expected.getName());
|
assertEquals(expected.getName(), expected.getName());
|
||||||
assertEquals(expected.getDisplayName(), expected.getDisplayName());
|
assertEquals(expected.getDisplayName(), expected.getDisplayName());
|
||||||
assertEquals(expected.getTimezone(), expected.getTimezone());
|
assertEquals(expected.getTimezone(), expected.getTimezone());
|
||||||
|
|||||||
@ -280,8 +280,6 @@ public class TopicResourceTest extends EntityResourceTest<Topic, CreateTopic> {
|
|||||||
@Override
|
@Override
|
||||||
public void validateCreatedEntity(Topic topic, CreateTopic createRequest, Map<String, String> authHeaders)
|
public void validateCreatedEntity(Topic topic, CreateTopic createRequest, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
topic, createRequest.getDescription(), TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
|
||||||
assertReference(createRequest.getService(), topic.getService());
|
assertReference(createRequest.getService(), topic.getService());
|
||||||
// TODO add other fields
|
// TODO add other fields
|
||||||
TestUtils.validateTags(createRequest.getTags(), topic.getTags());
|
TestUtils.validateTags(createRequest.getTags(), topic.getTags());
|
||||||
@ -290,8 +288,6 @@ public class TopicResourceTest extends EntityResourceTest<Topic, CreateTopic> {
|
|||||||
@Override
|
@Override
|
||||||
public void compareEntities(Topic expected, Topic updated, Map<String, String> authHeaders)
|
public void compareEntities(Topic expected, Topic updated, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
validateCommonEntityFields(
|
|
||||||
updated, expected.getDescription(), TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
|
||||||
assertReference(expected.getService(), expected.getService());
|
assertReference(expected.getService(), expected.getService());
|
||||||
// TODO add other fields
|
// TODO add other fields
|
||||||
TestUtils.validateTags(expected.getTags(), updated.getTags());
|
TestUtils.validateTags(expected.getTags(), updated.getTags());
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class JsonUtilsTest {
|
|||||||
users.add(user2);
|
users.add(user2);
|
||||||
teamJson.add("id", teamId).add("name", "finance").add("users", users);
|
teamJson.add("id", teamId).add("name", "finance").add("users", users);
|
||||||
|
|
||||||
Team original = EntityUtil.validate(teamId, teamJson.build().toString(), Team.class);
|
Team original = JsonUtils.readValue(teamJson.build().toString(), Team.class);
|
||||||
JsonPatchBuilder patchBuilder = Json.createPatchBuilder();
|
JsonPatchBuilder patchBuilder = Json.createPatchBuilder();
|
||||||
|
|
||||||
// Add two users to the team
|
// Add two users to the team
|
||||||
|
|||||||
@ -49,7 +49,6 @@ import org.openmetadata.catalog.entity.teams.User;
|
|||||||
import org.openmetadata.catalog.resources.glossary.GlossaryTermResourceTest;
|
import org.openmetadata.catalog.resources.glossary.GlossaryTermResourceTest;
|
||||||
import org.openmetadata.catalog.resources.tags.TagResourceTest;
|
import org.openmetadata.catalog.resources.tags.TagResourceTest;
|
||||||
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
import org.openmetadata.catalog.resources.teams.UserResourceTest;
|
||||||
import org.openmetadata.catalog.security.CatalogOpenIdAuthorizationRequestFilter;
|
|
||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.services.connections.dashboard.SupersetConnection;
|
import org.openmetadata.catalog.services.connections.dashboard.SupersetConnection;
|
||||||
import org.openmetadata.catalog.services.connections.database.BigQueryConnection;
|
import org.openmetadata.catalog.services.connections.database.BigQueryConnection;
|
||||||
@ -345,15 +344,6 @@ public final class TestUtils {
|
|||||||
existsInEntityReferenceList(user.getFollows(), entityId, expectedFollowing);
|
existsInEntityReferenceList(user.getFollows(), entityId, expectedFollowing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrincipal(Map<String, String> authHeaders) {
|
|
||||||
// Get username from the email address
|
|
||||||
if (authHeaders == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String principal = authHeaders.get(CatalogOpenIdAuthorizationRequestFilter.X_AUTH_PARAMS_EMAIL_HEADER);
|
|
||||||
return principal == null ? null : principal.split("@")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO remove this
|
// TODO remove this
|
||||||
public static void validateUpdate(Double previousVersion, Double newVersion, UpdateType updateType) {
|
public static void validateUpdate(Double previousVersion, Double newVersion, UpdateType updateType) {
|
||||||
if (updateType == UpdateType.CREATED) {
|
if (updateType == UpdateType.CREATED) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user