Skip to content

Commit

Permalink
Revert "add additional test"
Browse files Browse the repository at this point in the history
This reverts commit a1d1e78.
  • Loading branch information
david-leifker committed Sep 7, 2023
1 parent c94a776 commit dc9181b
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 312 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@
"type" : [ "string", "null" ],
"doc" : "The run id that produced the metadata. Populated in case of batch-ingestion.",
"default" : "no-run-id-provided"
}, {
"name" : "pipelineName",
"type" : [ "null", "string" ],
"doc" : "The ingestion pipeline id that produced the metadata. Populated in case of batch ingestion.",
"default" : null
}, {
"name" : "registryName",
"type" : [ "null", "string" ],
Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ Set<SearchFieldConfig> getStandardFields(@Nonnull Collection<EntitySpec> entityS
return fields;
}

@VisibleForTesting
Set<SearchFieldConfig> getFieldsFromEntitySpec(EntitySpec entitySpec) {
private Set<SearchFieldConfig> getFieldsFromEntitySpec(EntitySpec entitySpec) {
Set<SearchFieldConfig> fields = new HashSet<>();
List<SearchableFieldSpec> searchableFieldSpecs = entitySpec.getSearchableFieldSpecs();
for (SearchableFieldSpec fieldSpec : searchableFieldSpecs) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.linkedin.metadata.search.elasticsearch.query.request;

import com.datastax.dse.driver.api.core.graph.predicates.Search;
import com.linkedin.data.schema.DataSchema;
import com.linkedin.data.schema.PathSpec;
import com.linkedin.metadata.ESTestConfiguration;
import com.linkedin.metadata.config.search.CustomConfiguration;
import com.linkedin.metadata.config.search.ExactMatchConfiguration;
import com.linkedin.metadata.config.search.PartialConfiguration;
Expand All @@ -22,9 +22,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.util.Pair;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchAllQueryBuilder;
Expand All @@ -36,26 +34,16 @@
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;

import static com.linkedin.datahub.graphql.resolvers.search.SearchUtils.AUTO_COMPLETE_ENTITY_TYPES;
import static com.linkedin.datahub.graphql.resolvers.search.SearchUtils.SEARCHABLE_ENTITY_TYPES;
import static com.linkedin.metadata.search.elasticsearch.indexbuilder.SettingsBuilder.TEXT_SEARCH_ANALYZER;
import static com.linkedin.metadata.search.elasticsearch.indexbuilder.SettingsBuilder.URN_SEARCH_ANALYZER;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;

@Import(ESTestConfiguration.class)
public class SearchQueryBuilderTest extends AbstractTestNGSpringContextTests {

@Autowired
private EntityRegistry entityRegistry;

public class SearchQueryBuilderTest {
public static SearchConfiguration testQueryConfig;
static {
testQueryConfig = new SearchConfiguration();
Expand Down Expand Up @@ -285,36 +273,6 @@ public void testCustomDefault() {
}
}

/**
* Tests to make sure that the fields are correctly combined across search-able entities
*/
@Test
public void testGetStandardFieldsEntitySpec() {
List<EntitySpec> entitySpecs = Stream.concat(SEARCHABLE_ENTITY_TYPES.stream(), AUTO_COMPLETE_ENTITY_TYPES.stream())
.map(entityType -> entityType.toString().toLowerCase().replaceAll("_", ""))
.map(entityRegistry::getEntitySpec)
.collect(Collectors.toList());
assertTrue(entitySpecs.size() > 30, "Expected at least 30 searchable entities in the registry");

// Count of the distinct field names
Set<String> expectedFieldNames = Stream.concat(
// Standard urn fields plus entitySpec sourced fields
Stream.of("urn", "urn.delimited"),
entitySpecs.stream()
.flatMap(spec -> TEST_CUSTOM_BUILDER.getFieldsFromEntitySpec(spec).stream())
.map(SearchFieldConfig::fieldName))
.collect(Collectors.toSet());

Set<String> actualFieldNames = TEST_CUSTOM_BUILDER.getStandardFields(entitySpecs).stream()
.map(SearchFieldConfig::fieldName)
.collect(Collectors.toSet());

assertEquals(actualFieldNames, expectedFieldNames,
String.format("Missing: %s Extra: %s",
expectedFieldNames.stream().filter(f -> !actualFieldNames.contains(f)).collect(Collectors.toSet()),
actualFieldNames.stream().filter(f -> !expectedFieldNames.contains(f)).collect(Collectors.toSet())));
}

@Test
public void testGetStandardFields() {
Set<SearchFieldConfig> fieldConfigs = TEST_CUSTOM_BUILDER.getStandardFields(ImmutableList.of(TestEntitySpecBuilder.getSpec()));
Expand Down

0 comments on commit dc9181b

Please sign in to comment.