Skip to content

Commit

Permalink
fix broken tests and do more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 committed Dec 11, 2024
1 parent cb42873 commit 5064172
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ private static EntityClient initMockEntityClient(
Mockito.eq(filter),
Mockito.eq(start),
Mockito.eq(limit),
Mockito.eq(Collections.emptyList())))
Mockito.eq(Collections.emptyList()),
Mockito.eq(null)))
.thenReturn(result);
return client;
}
Expand All @@ -496,7 +497,8 @@ private static void verifyMockEntityClient(
Mockito.eq(filter),
Mockito.eq(start),
Mockito.eq(limit),
Mockito.eq(Collections.emptyList()));
Mockito.eq(Collections.emptyList()),
Mockito.eq(null));
}

private static void verifyMockViewService(ViewService mockService, Urn viewUrn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import static com.linkedin.metadata.utils.SearchUtil.*;

import com.linkedin.common.urn.UrnUtils;
import com.linkedin.data.schema.PathSpec;
import com.linkedin.data.template.LongMap;
import com.linkedin.data.template.StringArray;
import com.linkedin.metadata.aspect.AspectRetriever;
import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.models.EntitySpec;
import com.linkedin.metadata.models.annotation.SearchableAnnotation;
import com.linkedin.metadata.query.filter.Condition;
import com.linkedin.metadata.query.filter.ConjunctiveCriterion;
import com.linkedin.metadata.query.filter.ConjunctiveCriterionArray;
import com.linkedin.metadata.query.filter.Criterion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,17 @@ public void testGetSpecificAggregationsHasFields() {
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(),
ImmutableList.of("test1", "test2", "hasTest1"));
Assert.assertEquals(aggs.size(), 5);
Assert.assertEquals(aggs.size(), 4);
Set<String> facets = aggs.stream().map(AggregationBuilder::getName).collect(Collectors.toSet());
Assert.assertEquals(
ImmutableSet.of("test1", "test2", "hasTest1", "_entityType", "_entityType␞typeNames"),
facets);
Assert.assertEquals(ImmutableSet.of("test1", "test2", "hasTest1", "_entityType"), facets);

// Case 2: Ask for fields that should NOT exist.
aggs =
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(),
ImmutableList.of("hasTest2"));
Assert.assertEquals(
aggs.size(), 2); // default has two fields already, hasTest2 will not be in there
aggs.size(), 1); // default has one field already, hasTest2 will not be in there
}

@Test
Expand All @@ -294,7 +292,7 @@ public void testAggregateOverStructuredProperty() {
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(aspectRetriever),
List.of("structuredProperties.ab.fgh.ten"));
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(aggs.size(), 2);
AggregationBuilder aggBuilder = aggs.get(0);
Assert.assertTrue(aggBuilder instanceof TermsAggregationBuilder);
TermsAggregationBuilder agg = (TermsAggregationBuilder) aggBuilder;
Expand All @@ -310,9 +308,7 @@ public void testAggregateOverStructuredProperty() {
TestOperationContexts.systemContextNoSearchAuthorization(aspectRetriever),
List.of("structuredProperties.ab.fgh.ten", "structuredProperties.hello"));
Assert.assertEquals(
aggs.size(),
4); // has two default filters (_entityType, _entityType␞typeNames) both get mapped to
// _index
aggs.size(), 3); // has one default filter (_entityType) both get mapped to _index
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand All @@ -336,7 +332,7 @@ public void testAggregateOverStructuredPropertyNamespaced() {
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(aspectRetriever),
List.of("structuredProperties.under.scores.and.dots_make_a_mess"));
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(aggs.size(), 2);
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand All @@ -349,7 +345,7 @@ public void testAggregateOverStructuredPropertyNamespaced() {
List.of(
"structuredProperties.under.scores.and.dots_make_a_mess",
"structuredProperties.hello"));
Assert.assertEquals(aggs.size(), 4);
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand All @@ -373,7 +369,7 @@ public void testAggregateOverStructuredPropertyV1() {
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(aspectRetrieverV1),
List.of("structuredProperties.ab.fgh.ten"));
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(aggs.size(), 2);
AggregationBuilder aggBuilder = aggs.get(0);
Assert.assertTrue(aggBuilder instanceof TermsAggregationBuilder);
TermsAggregationBuilder agg = (TermsAggregationBuilder) aggBuilder;
Expand All @@ -391,9 +387,7 @@ public void testAggregateOverStructuredPropertyV1() {
"structuredProperties.ab.fgh.ten",
"structuredProperties._versioned.hello.00000000000001.string"));
Assert.assertEquals(
aggs.size(),
4); // has two default filters (_entityType, _entityType␞typeNames) both get mapped to
// _index
aggs.size(), 3); // has two one filter (_entityType) both get mapped to _index
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand All @@ -417,7 +411,7 @@ public void testAggregateOverStructuredPropertyNamespacedV1() {
builder.getAggregations(
TestOperationContexts.systemContextNoSearchAuthorization(aspectRetrieverV1),
List.of("structuredProperties.under.scores.and.dots_make_a_mess"));
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(aggs.size(), 2);
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand All @@ -433,7 +427,7 @@ public void testAggregateOverStructuredPropertyNamespacedV1() {
List.of(
"structuredProperties.under.scores.and.dots_make_a_mess",
"structuredProperties._versioned.hello.00000000000001.string"));
Assert.assertEquals(aggs.size(), 4);
Assert.assertEquals(aggs.size(), 3);
Assert.assertEquals(
aggs.stream()
.map(aggr -> ((TermsAggregationBuilder) aggr).field())
Expand Down Expand Up @@ -498,7 +492,7 @@ public void testAggregateOverFieldsAndStructProp() {
"hasTest1",
"structuredProperties.ab.fgh.ten",
"structuredProperties.hello"));
Assert.assertEquals(aggs.size(), 7);
Assert.assertEquals(aggs.size(), 6);
Set<String> facets =
aggs.stream()
.map(aggB -> ((TermsAggregationBuilder) aggB).field())
Expand Down Expand Up @@ -569,9 +563,7 @@ public void testAggregateOverFieldsAndStructPropV1() {
"structuredProperties.ab.fgh.ten",
"structuredProperties.hello"));
Assert.assertEquals(
aggs.size(),
7); // has two default filters (_entityType, _entityType␞typeNames) both get mapped to
// _index
aggs.size(), 6); // has one default filter (_entityType) both get mapped to _index
Set<String> facets =
aggs.stream()
.map(aggB -> ((TermsAggregationBuilder) aggB).field())
Expand Down Expand Up @@ -680,7 +672,7 @@ public void testAddFiltersToMetadataWithStructuredPropsNoResults() {
AspectRetriever mockAspectRetriever = getMockAspectRetriever(propertyUrn);

final List<AggregationMetadata> aggregationMetadataList = new ArrayList<>();
builder.addFacetFiltersToAggregationMetadata(
builder.addCriterionFiltersToAggregationMetadata(
criterion, aggregationMetadataList, mockAspectRetriever);

// ensure we add the correct structured prop aggregation here
Expand Down Expand Up @@ -723,7 +715,7 @@ public void testAddFiltersToMetadataWithStructuredPropsWithAggregations() {

final List<AggregationMetadata> aggregationMetadataList = new ArrayList<>();
aggregationMetadataList.add(aggregationMetadata);
builder.addFacetFiltersToAggregationMetadata(
builder.addCriterionFiltersToAggregationMetadata(
criterion, aggregationMetadataList, mockAspectRetriever);

Assert.assertEquals(aggregationMetadataList.size(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ public void testAggregationsInSearch() {
String.format("_entityType%stextFieldOverride", AGGREGATION_SEPARATOR_CHAR);
SearchRequest searchRequest =
requestHandler.getSearchRequest(
operationContext.withSearchFlags(flags -> flags.setFulltext(true).setIncludeDefaultFacets(false)),
operationContext.withSearchFlags(
flags -> flags.setFulltext(true).setIncludeDefaultFacets(false)),
"*",
null,
null,
Expand Down

0 comments on commit 5064172

Please sign in to comment.