mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-03 12:08:31 +00:00
Code cleanup changes (#9361)
This commit is contained in:
parent
0055ca2d1c
commit
1430e7e9c0
@ -77,9 +77,7 @@ public class OpenMetadata {
|
||||
}
|
||||
|
||||
public <K> void updateRequestType(Class<K> requestClass) {
|
||||
if (apiClient.getApiAuthorizations().containsKey(REQUEST_INTERCEPTOR_KEY)) {
|
||||
apiClient.getApiAuthorizations().remove(REQUEST_INTERCEPTOR_KEY);
|
||||
}
|
||||
apiClient.getApiAuthorizations().remove(REQUEST_INTERCEPTOR_KEY);
|
||||
CustomRequestInterceptor<K> newInterceptor =
|
||||
new CustomRequestInterceptor<>(apiClient.getObjectMapper(), requestClass);
|
||||
apiClient.addAuthorization(REQUEST_INTERCEPTOR_KEY, newInterceptor);
|
||||
|
||||
@ -55,7 +55,7 @@ public class AccessTokenResponse {
|
||||
*
|
||||
* @return ExpiresIn
|
||||
*/
|
||||
@Schema(description = "")
|
||||
@Schema()
|
||||
public Long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class AccessTokenResponse {
|
||||
*
|
||||
* @return AccessToken
|
||||
*/
|
||||
@Schema(description = "")
|
||||
@Schema()
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class AccessTokenResponse {
|
||||
*
|
||||
* @return Scope
|
||||
*/
|
||||
@Schema(description = "")
|
||||
@Schema()
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public class OktaSSOConfig {
|
||||
private String authorizationServerURL;
|
||||
|
||||
/** Okta client scopes. */
|
||||
private List<String> scopes = new ArrayList<String>();
|
||||
private List<String> scopes = new ArrayList<>();
|
||||
|
||||
/** Okta Client ID. (Required) */
|
||||
public String getClientId() {
|
||||
|
||||
@ -220,7 +220,7 @@ public final class Entity {
|
||||
return !ACTIVITY_FEED_EXCLUDED_ENTITIES.contains(entityType);
|
||||
}
|
||||
|
||||
public static <T> Fields getFields(String entityType, String fields) throws IOException {
|
||||
public static <T> Fields getFields(String entityType, String fields) {
|
||||
EntityRepository<?> entityRepository = Entity.getEntityRepository(entityType);
|
||||
return entityRepository.getFields(fields);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class OpenMetadataApplication extends Application<OpenMetadataApplication
|
||||
registerAuthorizer(catalogConfig, environment);
|
||||
|
||||
// Register Authenticator
|
||||
registerAuthenticator(catalogConfig, jdbi);
|
||||
registerAuthenticator(catalogConfig);
|
||||
|
||||
// Unregister dropwizard default exception mappers
|
||||
((DefaultServerFactory) catalogConfig.getServerFactory()).setRegisterDefaultExceptionMappers(false);
|
||||
@ -276,7 +276,7 @@ public class OpenMetadataApplication extends Application<OpenMetadataApplication
|
||||
}
|
||||
}
|
||||
|
||||
private void registerAuthenticator(OpenMetadataApplicationConfig catalogConfig, Jdbi jdbi) {
|
||||
private void registerAuthenticator(OpenMetadataApplicationConfig catalogConfig) {
|
||||
AuthenticationConfiguration authenticationConfiguration = catalogConfig.getAuthenticationConfiguration();
|
||||
switch (authenticationConfiguration.getProvider()) {
|
||||
case "basic":
|
||||
|
||||
@ -171,8 +171,7 @@ public class AirflowRESTClient extends PipelineServiceClient {
|
||||
response =
|
||||
getRequestAuthenticatedForJsonContent(statusEndPoint, serviceURL, API_ENDPOINT, ingestionPipeline.getName());
|
||||
if (response.statusCode() == 200) {
|
||||
List<PipelineStatus> pipelineStatusList = JsonUtils.readObjects(response.body(), PipelineStatus.class);
|
||||
return pipelineStatusList;
|
||||
return JsonUtils.readObjects(response.body(), PipelineStatus.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw PipelineServiceClientException.byMessage(ingestionPipeline.getName(), e.getMessage());
|
||||
|
||||
@ -25,13 +25,13 @@ public class DailyActiveUsersAggregator extends DataInsightAggregatorInterface<D
|
||||
@Override
|
||||
List<DailyActiveUsers> aggregate() throws ParseException {
|
||||
Histogram timestampBuckets = this.aggregations.get(TIMESTAMP);
|
||||
List<DailyActiveUsers> data = new ArrayList();
|
||||
List<DailyActiveUsers> data = new ArrayList<>();
|
||||
for (Histogram.Bucket timestampBucket : timestampBuckets.getBuckets()) {
|
||||
String dateTimeString = timestampBucket.getKeyAsString();
|
||||
Long timestamp = this.convertDatTimeStringToTimestamp(dateTimeString);
|
||||
Long activeUsers = timestampBucket.getDocCount();
|
||||
long activeUsers = timestampBucket.getDocCount();
|
||||
|
||||
data.add(new DailyActiveUsers().withTimestamp(timestamp).withActiveUsers(activeUsers.intValue()));
|
||||
data.add(new DailyActiveUsers().withTimestamp(timestamp).withActiveUsers((int) activeUsers));
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@ -2,7 +2,6 @@ package org.openmetadata.service.dataInsight;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
import org.openmetadata.schema.dataInsight.DataInsightChartResult;
|
||||
@ -14,8 +13,8 @@ public abstract class DataInsightAggregatorInterface<T> {
|
||||
protected static final String ENTITY_COUNT = "entityCount";
|
||||
protected static final String TIMESTAMP = "timestamp";
|
||||
protected static final String ENTITY_TIER = "entityTier";
|
||||
protected Aggregations aggregations;
|
||||
protected DataInsightChartResult.DataInsightChartType dataInsightChartType;
|
||||
protected final Aggregations aggregations;
|
||||
protected final DataInsightChartResult.DataInsightChartType dataInsightChartType;
|
||||
|
||||
protected DataInsightAggregatorInterface(
|
||||
Aggregations aggregations, DataInsightChartResult.DataInsightChartType dataInsightChartType) {
|
||||
@ -29,8 +28,6 @@ public abstract class DataInsightAggregatorInterface<T> {
|
||||
|
||||
public Long convertDatTimeStringToTimestamp(String dateTimeString) throws ParseException {
|
||||
SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
Date dateTimeObject = dateTimeFormat.parse(dateTimeString);
|
||||
Long timestamp = dateTimeObject.getTime();
|
||||
return timestamp;
|
||||
return dateTimeFormat.parse(dateTimeString).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.dataInsight;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
@ -18,14 +17,14 @@ public class MostActiveUsersAggregator extends DataInsightAggregatorInterface<Mo
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataInsightChartResult process() throws ParseException {
|
||||
public DataInsightChartResult process() {
|
||||
List data = this.aggregate();
|
||||
DataInsightChartResult dataInsightChartResult = new DataInsightChartResult();
|
||||
return dataInsightChartResult.withData(data).withChartType(this.dataInsightChartType);
|
||||
}
|
||||
|
||||
@Override
|
||||
List<MostActiveUsers> aggregate() throws ParseException {
|
||||
List<MostActiveUsers> aggregate() {
|
||||
MultiBucketsAggregation userNameBuckets = this.aggregations.get("userName");
|
||||
List<MostActiveUsers> data = new ArrayList();
|
||||
for (MultiBucketsAggregation.Bucket userNameBucket : userNameBuckets.getBuckets()) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.dataInsight;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
@ -17,14 +16,14 @@ public class MostViewedEntitiesAggregator extends DataInsightAggregatorInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataInsightChartResult process() throws ParseException {
|
||||
public DataInsightChartResult process() {
|
||||
List data = this.aggregate();
|
||||
DataInsightChartResult dataInsightChartResult = new DataInsightChartResult();
|
||||
return dataInsightChartResult.withData(data).withChartType(this.dataInsightChartType);
|
||||
}
|
||||
|
||||
@Override
|
||||
List<MostViewedEntities> aggregate() throws ParseException {
|
||||
List<MostViewedEntities> aggregate() {
|
||||
MultiBucketsAggregation entityFqnBuckets = this.aggregations.get("entityFqn");
|
||||
List<MostViewedEntities> data = new ArrayList();
|
||||
for (MultiBucketsAggregation.Bucket entityFqnBucket : entityFqnBuckets.getBuckets()) {
|
||||
|
||||
@ -25,10 +25,10 @@ public class TotalEntitiesAggregator extends DataInsightAggregatorInterface<Tota
|
||||
}
|
||||
|
||||
@Override
|
||||
List aggregate() throws ParseException {
|
||||
List<TotalEntitiesByType> aggregate() throws ParseException {
|
||||
Histogram timestampBuckets = this.aggregations.get(TIMESTAMP);
|
||||
List<TotalEntitiesByType> data = new ArrayList();
|
||||
List<Double> entityCount = new ArrayList();
|
||||
List<TotalEntitiesByType> data = new ArrayList<>();
|
||||
List<Double> entityCount = new ArrayList<>();
|
||||
|
||||
for (Histogram.Bucket timestampBucket : timestampBuckets.getBuckets()) {
|
||||
String dateTimeString = timestampBucket.getKeyAsString();
|
||||
@ -46,13 +46,11 @@ public class TotalEntitiesAggregator extends DataInsightAggregatorInterface<Tota
|
||||
}
|
||||
}
|
||||
|
||||
double totalEntities = entityCount.stream().mapToDouble(v -> v.doubleValue()).sum();
|
||||
double totalEntities = entityCount.stream().mapToDouble(v -> v).sum();
|
||||
|
||||
data.stream()
|
||||
.forEach(
|
||||
(el) -> {
|
||||
el.withEntityCountFraction(el.getEntityCount() / totalEntities);
|
||||
});
|
||||
for (TotalEntitiesByType el : data) {
|
||||
el.withEntityCountFraction(el.getEntityCount() / totalEntities);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -26,8 +26,8 @@ public class TotalEntitiesByTierAggregator extends DataInsightAggregatorInterfac
|
||||
@Override
|
||||
List<TotalEntitiesByTier> aggregate() throws ParseException {
|
||||
Histogram timestampBuckets = this.aggregations.get(TIMESTAMP);
|
||||
List<TotalEntitiesByTier> data = new ArrayList();
|
||||
List<Double> entityCount = new ArrayList();
|
||||
List<TotalEntitiesByTier> data = new ArrayList<>();
|
||||
List<Double> entityCount = new ArrayList<>();
|
||||
|
||||
for (Histogram.Bucket timestampBucket : timestampBuckets.getBuckets()) {
|
||||
String dateTimeString = timestampBucket.getKeyAsString();
|
||||
@ -45,13 +45,11 @@ public class TotalEntitiesByTierAggregator extends DataInsightAggregatorInterfac
|
||||
}
|
||||
}
|
||||
|
||||
double totalEntities = entityCount.stream().mapToDouble(v -> v.doubleValue()).sum();
|
||||
double totalEntities = entityCount.stream().mapToDouble(v -> v).sum();
|
||||
|
||||
data.stream()
|
||||
.forEach(
|
||||
(el) -> {
|
||||
el.withEntityCountFraction(el.getEntityCount() / totalEntities);
|
||||
});
|
||||
for (TotalEntitiesByTier el : data) {
|
||||
el.withEntityCountFraction(el.getEntityCount() / totalEntities);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ import org.openmetadata.service.util.JsonUtils;
|
||||
public class ElasticSearchEventPublisher extends AbstractEventPublisher {
|
||||
private static final String SENDING_REQUEST_TO_ELASTIC_SEARCH = "Sending request to ElasticSearch {}";
|
||||
private final RestHighLevelClient client;
|
||||
private final ElasticSearchIndexDefinition esIndexDefinition;
|
||||
private final CollectionDAO dao;
|
||||
private static final String SERVICE_NAME = "service.name";
|
||||
private static final String DATABASE_NAME = "database.name";
|
||||
@ -104,7 +103,7 @@ public class ElasticSearchEventPublisher extends AbstractEventPublisher {
|
||||
// needs Db connection
|
||||
registerElasticSearchJobs();
|
||||
this.client = ElasticSearchClientUtils.createElasticSearchClient(esConfig);
|
||||
esIndexDefinition = new ElasticSearchIndexDefinition(client, dao);
|
||||
ElasticSearchIndexDefinition esIndexDefinition = new ElasticSearchIndexDefinition(client, dao);
|
||||
esIndexDefinition.createIndexes();
|
||||
}
|
||||
|
||||
|
||||
@ -100,14 +100,6 @@ public class ElasticSearchIndexDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkIndexExistsOrCreate(ElasticSearchIndexType indexType) {
|
||||
boolean exists = elasticSearchIndexes.get(indexType) == ElasticSearchIndexStatus.CREATED;
|
||||
if (!exists) {
|
||||
exists = createIndex(indexType);
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
public boolean createIndex(ElasticSearchIndexType elasticSearchIndexType) {
|
||||
try {
|
||||
GetIndexRequest gRequest = new GetIndexRequest(elasticSearchIndexType.indexName);
|
||||
|
||||
@ -27,7 +27,6 @@ import org.slf4j.MarkerFactory;
|
||||
@Slf4j
|
||||
public class AuditEventHandler implements EventHandler {
|
||||
private final Marker auditMarker = MarkerFactory.getMarker("AUDIT");
|
||||
private final String ANONYMOUS_USER = "anonymous";
|
||||
|
||||
public void init(OpenMetadataApplicationConfig config, Jdbi jdbi) {
|
||||
// Nothing to do
|
||||
@ -38,7 +37,7 @@ public class AuditEventHandler implements EventHandler {
|
||||
String method = requestContext.getMethod();
|
||||
if (responseContext.getEntity() != null) {
|
||||
String path = requestContext.getUriInfo().getPath();
|
||||
String username = ANONYMOUS_USER;
|
||||
String username = "anonymous";
|
||||
if (requestContext.getSecurityContext().getUserPrincipal() != null) {
|
||||
username = requestContext.getSecurityContext().getUserPrincipal().getName();
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class DataInsightChartRepository extends EntityRepository<DataInsightChar
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(DataInsightChart entity) throws IOException {
|
||||
public void prepare(DataInsightChart entity) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class DataInsightChartRepository extends EntityRepository<DataInsightChar
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeRelationships(DataInsightChart entity) throws IOException {
|
||||
public void storeRelationships(DataInsightChart entity) {
|
||||
storeOwner(entity, entity.getOwner());
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ public class WebAnalyticEventRepository extends EntityRepository<WebAnalyticEven
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public void deleteWebAnalyticEventData(WebAnalyticEventType name, Long timestamp) throws IOException {
|
||||
public void deleteWebAnalyticEventData(WebAnalyticEventType name, Long timestamp) {
|
||||
daoCollection
|
||||
.entityExtensionTimeSeriesDao()
|
||||
.deleteBeforeExclusive(name.value(), WEB_ANALYTICS_EVENT_DATA_EXTENSION, timestamp);
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openmetadata.service.monitoring;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.service.Entity;
|
||||
@ -31,7 +30,7 @@ public class EventMonitorPublisher extends AbstractEventPublisher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(EventResource.ChangeEventList events) throws EventPublisherException, JsonProcessingException {
|
||||
public void publish(EventResource.ChangeEventList events) throws EventPublisherException {
|
||||
for (ChangeEvent event : events.getData()) {
|
||||
String entityType = event.getEntityType();
|
||||
if (Entity.INGESTION_PIPELINE.equals(entityType)) {
|
||||
|
||||
@ -457,7 +457,7 @@ public class DataInsightChartResource extends EntityResource<DataInsightChart, D
|
||||
@NonNull
|
||||
@QueryParam("endTs")
|
||||
Long endTs)
|
||||
throws IOException, ParseException, ClassNotFoundException {
|
||||
throws IOException, ParseException {
|
||||
|
||||
SearchSourceBuilder searchSourceBuilder =
|
||||
dao.buildQueryFilter(startTs, endTs, tier, team, dataInsightChartName.value());
|
||||
|
||||
@ -312,7 +312,7 @@ public class BuildSearchIndexResource {
|
||||
UriInfo uriInfo, UUID startedBy, String entityType, CreateEventPublisherJob createRequest) {
|
||||
|
||||
ElasticSearchIndexDefinition.ElasticSearchIndexType indexType =
|
||||
elasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);
|
||||
ElasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);
|
||||
|
||||
if (Boolean.TRUE.equals(createRequest.getRecreateIndex())) {
|
||||
// Delete index
|
||||
@ -368,7 +368,7 @@ public class BuildSearchIndexResource {
|
||||
EventPublisherJob latestJob = JsonUtils.readValue(reindexJobString, EventPublisherJob.class);
|
||||
Long lastUpdateTime = latestJob.getTimestamp();
|
||||
ElasticSearchIndexDefinition.ElasticSearchIndexType indexType =
|
||||
elasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);
|
||||
ElasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);
|
||||
for (EntityInterface entity : entities) {
|
||||
if (entityType.equals(TABLE)) {
|
||||
((Table) entity).getColumns().forEach(table -> table.setProfile(null));
|
||||
|
||||
@ -69,7 +69,6 @@ import org.openmetadata.service.jdbi3.FeedRepository;
|
||||
import org.openmetadata.service.jdbi3.FeedRepository.FilterType;
|
||||
import org.openmetadata.service.jdbi3.FeedRepository.PaginationType;
|
||||
import org.openmetadata.service.resources.Collection;
|
||||
import org.openmetadata.service.resources.feeds.FeedResource.ThreadList;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser.EntityLink;
|
||||
import org.openmetadata.service.security.Authorizer;
|
||||
import org.openmetadata.service.security.policyevaluator.OperationContext;
|
||||
|
||||
@ -72,7 +72,7 @@ public class MetadataServiceResource
|
||||
public static final String COLLECTION_PATH = "v1/services/metadataServices/";
|
||||
public static final String FIELDS = "pipelines,owner,tags";
|
||||
|
||||
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
|
||||
public void initialize(OpenMetadataApplicationConfig config) {
|
||||
registerMetadataServices(config);
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.NonNull;
|
||||
import org.openmetadata.schema.api.configuration.LoginConfiguration;
|
||||
import org.openmetadata.service.OpenMetadataApplicationConfig;
|
||||
|
||||
@ -26,7 +27,7 @@ public class LoginAttemptCache {
|
||||
.expireAfterWrite(accessBlockTime, TimeUnit.SECONDS)
|
||||
.build(
|
||||
new CacheLoader<>() {
|
||||
public Integer load(String key) {
|
||||
public Integer load(@NonNull String key) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
@ -41,7 +42,7 @@ public class LoginAttemptCache {
|
||||
.expireAfterWrite(blockTimeInSec, TimeUnit.SECONDS)
|
||||
.build(
|
||||
new CacheLoader<>() {
|
||||
public Integer load(String key) {
|
||||
public Integer load(@NonNull String key) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
@ -605,10 +605,8 @@ public final class ChangeEventParser {
|
||||
String spanAddClose = getAddMarkerClose(publishTo);
|
||||
String spanRemove = getRemoveMarker(publishTo);
|
||||
String spanRemoveClose = getRemoveMarkerClose(publishTo);
|
||||
if (diff != null) {
|
||||
diff = replaceMarkers(diff, addMarker, spanAdd, spanAddClose);
|
||||
diff = replaceMarkers(diff, removeMarker, spanRemove, spanRemoveClose);
|
||||
}
|
||||
diff = replaceMarkers(diff, addMarker, spanAdd, spanAddClose);
|
||||
diff = replaceMarkers(diff, removeMarker, spanRemove, spanRemoveClose);
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
@ -23,8 +23,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.regex.Pattern;
|
||||
@ -33,8 +31,6 @@ import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.joda.time.Period;
|
||||
import org.joda.time.format.ISOPeriodFormat;
|
||||
import org.openmetadata.common.utils.CommonUtil;
|
||||
import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.api.data.TermReference;
|
||||
@ -44,20 +40,15 @@ import org.openmetadata.schema.entity.data.Topic;
|
||||
import org.openmetadata.schema.entity.policies.accessControl.Rule;
|
||||
import org.openmetadata.schema.entity.tags.Tag;
|
||||
import org.openmetadata.schema.entity.type.CustomProperty;
|
||||
import org.openmetadata.schema.filter.EventFilter;
|
||||
import org.openmetadata.schema.filter.Filters;
|
||||
import org.openmetadata.schema.type.ChangeDescription;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.schema.type.Column;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.schema.type.EventType;
|
||||
import org.openmetadata.schema.type.FailureDetails;
|
||||
import org.openmetadata.schema.type.Field;
|
||||
import org.openmetadata.schema.type.FieldChange;
|
||||
import org.openmetadata.schema.type.MetadataOperation;
|
||||
import org.openmetadata.schema.type.MlFeature;
|
||||
import org.openmetadata.schema.type.MlHyperParameter;
|
||||
import org.openmetadata.schema.type.Schedule;
|
||||
import org.openmetadata.schema.type.TableConstraint;
|
||||
import org.openmetadata.schema.type.TagLabel;
|
||||
import org.openmetadata.schema.type.TagLabel.TagSource;
|
||||
@ -92,8 +83,6 @@ public final class EntityUtil {
|
||||
public static final Comparator<ChangeEvent> compareChangeEvent = Comparator.comparing(ChangeEvent::getTimestamp);
|
||||
public static final Comparator<GlossaryTerm> compareGlossaryTerm = Comparator.comparing(GlossaryTerm::getName);
|
||||
public static final Comparator<CustomProperty> compareCustomProperty = Comparator.comparing(CustomProperty::getName);
|
||||
public static final Comparator<Filters> compareFilters = Comparator.comparing(Filters::getEventType);
|
||||
public static final Comparator<EventFilter> compareEventFilters = Comparator.comparing(EventFilter::getEntityType);
|
||||
|
||||
//
|
||||
// Matchers used for matching two items in a list
|
||||
@ -126,14 +115,6 @@ public final class EntityUtil {
|
||||
|
||||
public static final BiPredicate<MlFeature, MlFeature> mlFeatureMatch = MlFeature::equals;
|
||||
public static final BiPredicate<MlHyperParameter, MlHyperParameter> mlHyperParameterMatch = MlHyperParameter::equals;
|
||||
public static final BiPredicate<FailureDetails, FailureDetails> failureDetailsMatch =
|
||||
(failureDetails1, failureDetails2) ->
|
||||
Objects.equals(failureDetails2.getLastFailedAt(), failureDetails1.getLastFailedAt())
|
||||
&& Objects.equals(failureDetails2.getLastSuccessfulAt(), failureDetails1.getLastSuccessfulAt());
|
||||
|
||||
public static final BiPredicate<EventFilter, EventFilter> eventFilterMatch =
|
||||
(filter1, filter2) ->
|
||||
filter1.getEntityType().equals(filter2.getEntityType()) && filter1.getFilters().equals(filter2.getFilters());
|
||||
|
||||
public static final BiPredicate<GlossaryTerm, GlossaryTerm> glossaryTermMatch =
|
||||
(filter1, filter2) -> filter1.getFullyQualifiedName().equals(filter2.getFullyQualifiedName());
|
||||
@ -154,31 +135,6 @@ public final class EntityUtil {
|
||||
|
||||
private EntityUtil() {}
|
||||
|
||||
/** Validate Ingestion Schedule */
|
||||
public static void validateIngestionSchedule(Schedule ingestion) {
|
||||
if (ingestion == null) {
|
||||
return;
|
||||
}
|
||||
String duration = ingestion.getRepeatFrequency();
|
||||
|
||||
// ISO8601 duration format is P{y}Y{m}M{d}DT{h}H{m}M{s}S.
|
||||
String[] splits = duration.split("T");
|
||||
if (splits[0].contains("Y") || splits[0].contains("M") || (splits.length == 2 && splits[1].contains("S"))) {
|
||||
throw new IllegalArgumentException(
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, and Minutes - " + "example P{d}DT{h}H{m}M");
|
||||
}
|
||||
|
||||
Period period;
|
||||
try {
|
||||
period = ISOPeriodFormat.standard().parsePeriod(duration);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Invalid ingestion repeatFrequency " + duration, e);
|
||||
}
|
||||
if (period.toStandardMinutes().getMinutes() < 60) {
|
||||
throw new IllegalArgumentException("Ingestion repeatFrequency is too short and must be more than 60 minutes");
|
||||
}
|
||||
}
|
||||
|
||||
/** Validate that JSON payload can be turned into POJO object */
|
||||
public static <T> T validate(String identity, String json, Class<T> clz) throws WebApplicationException, IOException {
|
||||
T entity = null;
|
||||
@ -417,19 +373,6 @@ public final class EntityUtil {
|
||||
return Math.round((version + 1.0) * 10.0) / 10.0;
|
||||
}
|
||||
|
||||
public static void addSoftDeleteFilter(List<Filters> filters) {
|
||||
// Add filter for soft delete events if delete event type is requested
|
||||
Optional<Filters> deleteFilter =
|
||||
filters.stream().filter(eventFilter -> eventFilter.getEventType().equals(EventType.ENTITY_DELETED)).findAny();
|
||||
deleteFilter.ifPresent(
|
||||
eventFilter ->
|
||||
filters.add(
|
||||
new Filters()
|
||||
.withEventType(EventType.ENTITY_SOFT_DELETED)
|
||||
.withInclude(eventFilter.getInclude())
|
||||
.withExclude(eventFilter.getExclude())));
|
||||
}
|
||||
|
||||
public static EntityReference copy(EntityReference from, EntityReference to) {
|
||||
return to.withType(from.getType())
|
||||
.withId(from.getId())
|
||||
@ -506,4 +449,8 @@ public final class EntityUtil {
|
||||
public static EntityReference getEntityReference(EntityInterface entity) {
|
||||
return entity == null ? null : entity.getEntityReference();
|
||||
}
|
||||
|
||||
public static Column getColumn(Table table, String columnName) {
|
||||
return table.getColumns().stream().filter(c -> c.getName().equals(columnName)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package org.openmetadata.service.monitoring;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.openmetadata.service.resources.services.ingestionpipelines.IngestionPipelineResourceTest.DATABASE_METADATA_CONFIG;
|
||||
|
||||
import java.time.Instant;
|
||||
@ -44,7 +44,6 @@ public class CloudWatchEventMonitorTest {
|
||||
private static final String NAMESPACE = "INGESTION_PIPELINE";
|
||||
private static final String EXPECTED_NAMESPACE = "openmetadata/INGESTION_PIPELINE";
|
||||
private static final String FQN = "service.ingestion";
|
||||
private static EventMonitorConfiguration config;
|
||||
|
||||
private static CloudwatchEventMonitor eventMonitor;
|
||||
|
||||
@ -74,7 +73,7 @@ public class CloudWatchEventMonitorTest {
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
config = new EventMonitorConfiguration();
|
||||
EventMonitorConfiguration config = new EventMonitorConfiguration();
|
||||
config.setEventMonitor(EventMonitorProvider.CLOUDWATCH);
|
||||
config.setBatchSize(10);
|
||||
eventMonitor = new CloudwatchEventMonitor(EventMonitorProvider.CLOUDWATCH, config, CLUSTER_NAME);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openmetadata.service.monitoring;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
@ -62,14 +62,14 @@ class AirflowRESTClientIntegrationTest {
|
||||
void testLastIngestionLogsAreRetrievedWhenStatusCodesAre200() {
|
||||
Map<String, String> expectedMap = Map.of("key1", "value1", "key2", "value2");
|
||||
|
||||
registerMockedEndpoints(200, 200);
|
||||
registerMockedEndpoints(200);
|
||||
|
||||
assertEquals(expectedMap, airflowRESTClient.getLastIngestionLogs(INGESTION_PIPELINE, "after"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLastIngestionLogsExceptionWhenLoginFails() {
|
||||
registerMockedEndpoints(404, 200);
|
||||
registerMockedEndpoints(200);
|
||||
|
||||
Exception exception =
|
||||
assertThrows(
|
||||
@ -84,7 +84,7 @@ class AirflowRESTClientIntegrationTest {
|
||||
|
||||
@Test
|
||||
void testLastIngestionLogsExceptionWhenStatusCode404() {
|
||||
registerMockedEndpoints(200, 404);
|
||||
registerMockedEndpoints(404);
|
||||
|
||||
Exception exception =
|
||||
assertThrows(
|
||||
@ -107,7 +107,7 @@ class AirflowRESTClientIntegrationTest {
|
||||
return airflowConfiguration;
|
||||
}
|
||||
|
||||
private void registerMockedEndpoints(int loginStatusCode, int lastDagLogStatusCode) {
|
||||
private void registerMockedEndpoints(int lastDagLogStatusCode) {
|
||||
String jsonResponse = "{ \"key1\": \"value1\", \"key2\": \"value2\" }";
|
||||
|
||||
Map<String, MockResponse> pathResponses = new HashMap<>();
|
||||
|
||||
@ -50,8 +50,7 @@ import org.openmetadata.service.util.JsonUtils;
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ChangeEventParserResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
Table TABLE;
|
||||
private Table TABLE;
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
|
||||
@ -730,11 +730,20 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
if (!supportsSoftDelete) {
|
||||
return;
|
||||
}
|
||||
// Create an entity
|
||||
T entity = createEntity(createRequest(test), ADMIN_AUTH_HEADERS);
|
||||
getEntity(entity.getId(), allFields, ADMIN_AUTH_HEADERS);
|
||||
Double previousVersion = entity.getVersion();
|
||||
|
||||
// Soft-delete the entity
|
||||
deleteAndCheckEntity(entity, ADMIN_AUTH_HEADERS);
|
||||
EntityHistory history = getVersionList(entity.getId(), ADMIN_AUTH_HEADERS);
|
||||
T latestVersion = JsonUtils.readValue((String) history.getVersions().get(0), entityClass);
|
||||
|
||||
// Get all the entity version
|
||||
entity = JsonUtils.readValue((String) history.getVersions().get(0), entityClass);
|
||||
assertEquals(EntityUtil.nextVersion(previousVersion), entity.getVersion());
|
||||
|
||||
// Get the deleted entity version from versions API
|
||||
getVersion(entity.getId(), entity.getVersion(), ADMIN_AUTH_HEADERS);
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ public class WebAnalyticEventResourceTest extends EntityResourceTest<WebAnalytic
|
||||
|
||||
@Test
|
||||
void put_and_delete_web_analytic_event_data_200() throws IOException, ParseException {
|
||||
String dates[] = {"2022-10-11", "2022-10-10", "2022-10-09", "2022-10-08"};
|
||||
String[] dates = {"2022-10-11", "2022-10-10", "2022-10-09", "2022-10-08"};
|
||||
|
||||
for (String date : dates) {
|
||||
WebAnalyticEventData webAnalyticEventData =
|
||||
|
||||
@ -22,12 +22,10 @@ import static org.openmetadata.service.util.TestUtils.assertListNull;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.data.CreateChart;
|
||||
@ -46,11 +44,6 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
||||
super(Entity.CHART, Chart.class, ChartList.class, "charts", ChartResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_chartWithoutRequiredFields_4xx(TestInfo test) {
|
||||
// Service is required field
|
||||
|
||||
@ -7,7 +7,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.dataInsight.CreateDataInsightChart;
|
||||
@ -40,7 +39,7 @@ public class DataInsightResourceTest extends EntityResourceTest<DataInsightChart
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_data_insight_4x(TestInfo test) throws IOException {
|
||||
void post_data_insight_4x(TestInfo test) {
|
||||
assertResponseContains(
|
||||
() -> createEntity(createRequest(test).withName(null), ADMIN_AUTH_HEADERS),
|
||||
BAD_REQUEST,
|
||||
@ -57,28 +56,23 @@ public class DataInsightResourceTest extends EntityResourceTest<DataInsightChart
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(
|
||||
DataInsightChart createdEntity, CreateDataInsightChart request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
DataInsightChart createdEntity, CreateDataInsightChart request, Map<String, String> authHeaders) {
|
||||
assertEquals(request.getName(), createdEntity.getName());
|
||||
assertEquals(request.getDescription(), createdEntity.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(DataInsightChart expected, DataInsightChart updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(DataInsightChart expected, DataInsightChart updated, Map<String, String> authHeaders) {
|
||||
assertEquals(expected.getName(), updated.getName());
|
||||
assertEquals(expected.getFullyQualifiedName(), updated.getFullyQualifiedName());
|
||||
assertEquals(expected.getDescription(), updated.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataInsightChart validateGetWithDifferentFields(DataInsightChart entity, boolean byName)
|
||||
throws HttpResponseException {
|
||||
public DataInsightChart validateGetWithDifferentFields(DataInsightChart entity, boolean byName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) throws IOException {
|
||||
return;
|
||||
}
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {}
|
||||
}
|
||||
|
||||
@ -24,12 +24,10 @@ import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -52,11 +50,6 @@ public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDat
|
||||
super(Entity.DATABASE, Database.class, DatabaseList.class, "databases", DatabaseResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_databaseWithInvalidServiceType_4xx(TestInfo test) {
|
||||
// Create a database with entity reference to databaseServiceType having invalid serviceType
|
||||
|
||||
@ -22,11 +22,9 @@ import static org.openmetadata.service.util.TestUtils.assertListNull;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -52,11 +50,6 @@ class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchema, Crea
|
||||
DatabaseSchemaResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_schemaWithoutRequiredDatabase_400(TestInfo test) {
|
||||
CreateDatabaseSchema create = createRequest(test).withDatabase(null);
|
||||
|
||||
@ -64,7 +64,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
import static org.openmetadata.service.util.TestUtils.validateEntityReference;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -80,7 +79,6 @@ import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -148,11 +146,6 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
super(TABLE, Table.class, TableList.class, "tables", TableResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
public void setupDatabaseSchemas(TestInfo test) throws IOException {
|
||||
DatabaseResourceTest databaseResourceTest = new DatabaseResourceTest();
|
||||
CreateDatabase create = databaseResourceTest.createRequest(test).withService(SNOWFLAKE_REFERENCE);
|
||||
|
||||
@ -549,9 +549,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {
|
||||
if (expected == actual) {
|
||||
return;
|
||||
}
|
||||
if (expected == actual) {}
|
||||
// TODO fix this
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,10 +50,8 @@ import java.time.ZoneOffset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
@ -108,8 +106,8 @@ import org.openmetadata.service.resources.feeds.FeedResource.ThreadList;
|
||||
import org.openmetadata.service.resources.teams.TeamResourceTest;
|
||||
import org.openmetadata.service.resources.teams.UserResourceTest;
|
||||
import org.openmetadata.service.util.ChangeEventParser;
|
||||
import org.openmetadata.service.util.EntityUtil;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
import org.openmetadata.service.util.ResultList;
|
||||
import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@ -209,21 +207,18 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
@Test
|
||||
void post_feedWithoutMessage_4xx() {
|
||||
// Create thread without message field in the request
|
||||
CreateThread create = create().withFrom(USER.getName()).withMessage(null);
|
||||
assertResponseContains(() -> createThread(create, AUTH_HEADERS), BAD_REQUEST, "[message must not be null]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_feedWithoutFrom_4xx() {
|
||||
// Create thread without from field in the request
|
||||
CreateThread create = create().withFrom(null);
|
||||
assertResponseContains(() -> createThread(create, AUTH_HEADERS), BAD_REQUEST, "[from must not be null]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_feedWithNonExistentFrom_404() {
|
||||
// Create thread with non-existent from
|
||||
CreateThread create = create().withFrom(NON_EXISTENT_ENTITY.toString());
|
||||
assertResponse(
|
||||
() -> createThread(create, AUTH_HEADERS), NOT_FOUND, entityNotFound(Entity.USER, NON_EXISTENT_ENTITY));
|
||||
@ -231,7 +226,6 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
@Test
|
||||
void post_feedWithNonExistentAbout_404() {
|
||||
// Create thread with non-existent addressed To entity
|
||||
CreateThread create = create().withAbout("<#E::table::invalidTableName>");
|
||||
assertResponse(
|
||||
() -> createThread(create, AUTH_HEADERS), NOT_FOUND, entityNotFound(Entity.TABLE, "invalidTableName"));
|
||||
@ -594,15 +588,8 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
ResolveTask resolveTask = new ResolveTask().withNewValue("accepted description");
|
||||
resolveTask(taskId, resolveTask, userAuthHeaders);
|
||||
ResultList<Table> tables = TABLE_RESOURCE_TEST.listEntities(null, userAuthHeaders);
|
||||
Optional<Table> table =
|
||||
tables.getData().stream()
|
||||
.filter(t -> t.getFullyQualifiedName().equals(TABLE.getFullyQualifiedName()))
|
||||
.findFirst();
|
||||
assertTrue(table.isPresent());
|
||||
assertEquals(
|
||||
"accepted description",
|
||||
table.get().getColumns().stream().filter(c -> c.getName().equals("c1")).findFirst().get().getDescription());
|
||||
Table table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), null, userAuthHeaders);
|
||||
assertEquals("accepted description", EntityUtil.getColumn(table, ("c1")).getDescription());
|
||||
|
||||
Thread taskThread = getTask(taskId, userAuthHeaders);
|
||||
task = taskThread.getTask();
|
||||
@ -640,27 +627,14 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
assertNotNull(task.getId());
|
||||
int taskId = task.getId();
|
||||
|
||||
ResultList<Table> tables = TABLE_RESOURCE_TEST.listEntities(null, userAuthHeaders);
|
||||
Optional<Table> table =
|
||||
tables.getData().stream()
|
||||
.filter(t -> t.getFullyQualifiedName().equals(TABLE.getFullyQualifiedName()))
|
||||
.findFirst();
|
||||
assertTrue(table.isPresent());
|
||||
String oldDescription =
|
||||
table.get().getColumns().stream().filter(c -> c.getName().equals("c1")).findFirst().get().getDescription();
|
||||
Table table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), null, userAuthHeaders);
|
||||
String oldDescription = EntityUtil.getColumn(table, "c1").getDescription();
|
||||
|
||||
closeTask(taskId, "closing comment", userAuthHeaders);
|
||||
|
||||
// closing the task should not affect description of the table
|
||||
tables = TABLE_RESOURCE_TEST.listEntities(null, userAuthHeaders);
|
||||
table =
|
||||
tables.getData().stream()
|
||||
.filter(t -> t.getFullyQualifiedName().equals(TABLE.getFullyQualifiedName()))
|
||||
.findFirst();
|
||||
assertTrue(table.isPresent());
|
||||
assertEquals(
|
||||
oldDescription,
|
||||
table.get().getColumns().stream().filter(c -> c.getName().equals("c1")).findFirst().get().getDescription());
|
||||
table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), null, userAuthHeaders);
|
||||
assertEquals(oldDescription, EntityUtil.getColumn(table, "c1").getDescription());
|
||||
|
||||
Thread taskThread = getTask(taskId, userAuthHeaders);
|
||||
task = taskThread.getTask();
|
||||
@ -701,16 +675,8 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
ResolveTask resolveTask = new ResolveTask().withNewValue(newValue);
|
||||
resolveTask(taskId, resolveTask, userAuthHeaders);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("fields", "tags");
|
||||
ResultList<Table> tables = TABLE_RESOURCE_TEST.listEntities(params, userAuthHeaders);
|
||||
Optional<Table> table =
|
||||
tables.getData().stream()
|
||||
.filter(t -> t.getFullyQualifiedName().equals(TABLE.getFullyQualifiedName()))
|
||||
.findFirst();
|
||||
assertTrue(table.isPresent());
|
||||
List<TagLabel> tags =
|
||||
table.get().getColumns().stream().filter(c -> c.getName().equals("c1")).findFirst().get().getTags();
|
||||
Table table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), "tags", userAuthHeaders);
|
||||
List<TagLabel> tags = EntityUtil.getColumn(table, "c1").getTags();
|
||||
assertEquals(USER_ADDRESS_TAG_LABEL.getTagFQN(), tags.get(0).getTagFQN());
|
||||
|
||||
Thread taskThread = getTask(taskId, userAuthHeaders);
|
||||
@ -983,7 +949,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
.withMessage("Announcement Two")
|
||||
.withType(ThreadType.Announcement)
|
||||
.withAnnouncementDetails(announcementDetails);
|
||||
Thread thread2 = createAndCheck(create, userAuthHeaders);
|
||||
Thread thread2 = createAndCheck(create2, userAuthHeaders);
|
||||
|
||||
String originalJson = JsonUtils.pojoToJson(thread2);
|
||||
|
||||
|
||||
@ -33,14 +33,12 @@ import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.service.util.TestUtils.validateTagLabel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
@ -73,11 +71,6 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
|
||||
public GlossaryResourceTest() {
|
||||
// TODO add system glossary
|
||||
super(Entity.GLOSSARY, Glossary.class, GlossaryResource.GlossaryList.class, "glossaries", GlossaryResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
supportsEmptyDescription = false;
|
||||
}
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ public class KpiResourceTest extends EntityResourceTest<Kpi, CreateKpiRequest> {
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_testWithInvalidValues_4xx(TestInfo test) throws HttpResponseException {
|
||||
void post_testWithInvalidValues_4xx() {
|
||||
String uuid = "Test2" + UUID.randomUUID();
|
||||
CreateKpiRequest create1 = createRequest(uuid);
|
||||
create1.withDataInsightChart(USER1_REF);
|
||||
@ -109,7 +109,7 @@ public class KpiResourceTest extends EntityResourceTest<Kpi, CreateKpiRequest> {
|
||||
}
|
||||
|
||||
@Test
|
||||
void createUpdate_tests_200(TestInfo test) throws IOException {
|
||||
void createUpdate_tests_200() throws IOException {
|
||||
CreateKpiRequest create = createRequest("Test" + UUID.randomUUID());
|
||||
Kpi createdKpi = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||
createdKpi = getEntity(createdKpi.getId(), KpiResource.FIELDS, ADMIN_AUTH_HEADERS);
|
||||
@ -250,8 +250,7 @@ public class KpiResourceTest extends EntityResourceTest<Kpi, CreateKpiRequest> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(Kpi createdEntity, CreateKpiRequest request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(Kpi createdEntity, CreateKpiRequest request, Map<String, String> authHeaders) {
|
||||
validateCommonEntityFields(createdEntity, request, getPrincipalName(authHeaders));
|
||||
assertEquals(request.getStartDate(), createdEntity.getStartDate());
|
||||
assertEquals(request.getEndDate(), createdEntity.getEndDate());
|
||||
@ -325,7 +324,7 @@ public class KpiResourceTest extends EntityResourceTest<Kpi, CreateKpiRequest> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(Kpi expected, Kpi updated, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public void compareEntities(Kpi expected, Kpi updated, Map<String, String> authHeaders) {
|
||||
validateCommonEntityFields(expected, updated, getPrincipalName(authHeaders));
|
||||
assertEquals(expected.getStartDate(), updated.getStartDate());
|
||||
assertEquals(expected.getEndDate(), updated.getEndDate());
|
||||
@ -335,16 +334,14 @@ public class KpiResourceTest extends EntityResourceTest<Kpi, CreateKpiRequest> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kpi validateGetWithDifferentFields(Kpi entity, boolean byName) throws HttpResponseException {
|
||||
public Kpi validateGetWithDifferentFields(Kpi entity, boolean byName) {
|
||||
// TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {
|
||||
if (expected == actual) {
|
||||
return;
|
||||
}
|
||||
if (expected == actual) {}
|
||||
// TODO fix this
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import static org.openmetadata.service.util.TestUtils.assertListNull;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@ -34,7 +33,6 @@ import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.data.CreateLocation;
|
||||
@ -54,11 +52,6 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
|
||||
super(Entity.LOCATION, Location.class, LocationList.class, "locations", LocationResource.FIELDS);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateLocation createRequest(String name) {
|
||||
return new CreateLocation().withName(name).withPath(name).withService(getContainer());
|
||||
|
||||
@ -26,7 +26,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -35,10 +34,8 @@ import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.openmetadata.schema.api.CreateType;
|
||||
import org.openmetadata.schema.entity.Type;
|
||||
@ -66,11 +63,6 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
||||
supportsNameWithDot = false;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
}
|
||||
|
||||
public void setupTypes() throws HttpResponseException {
|
||||
INT_TYPE = getEntityByName("integer", "", ADMIN_AUTH_HEADERS);
|
||||
STRING_TYPE = getEntityByName("string", "", ADMIN_AUTH_HEADERS);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.openmetadata.service.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.List;
|
||||
@ -85,6 +86,6 @@ class FullyQualifiedNameTest {
|
||||
assertEquals("a.b.c", FullyQualifiedName.getParent("a.b.c.d"));
|
||||
assertEquals("a.b", FullyQualifiedName.getParent("a.b.c"));
|
||||
assertEquals("a", FullyQualifiedName.getParent("a.b"));
|
||||
assertEquals(null, FullyQualifiedName.getParent("a"));
|
||||
assertNull(FullyQualifiedName.getParent("a"));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user