Skip to content

Commit

Permalink
fix(assertion tab): fixing up regression in assertion resolver (datah…
Browse files Browse the repository at this point in the history
…ub-project#6296)

* fixing up regression in assertion resolver

* small nit
  • Loading branch information
gabe-lyons committed Oct 27, 2022
1 parent e799150 commit 5a20ac4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,19 @@ public static Filter buildFilter(@Nullable List<FacetFilterInput> andFilters, @N
return new Filter().setOr(new ConjunctiveCriterionArray(new ConjunctiveCriterion().setAnd(new CriterionArray(andCriterions))));
}

// Translates a FacetFilterInput (graphql input class) into Criterion (our internal model)
public static Criterion criterionFromFilter(final FacetFilterInput filter) {
return criterionFromFilter(filter, false);
}

// Translates a FacetFilterInput (graphql input class) into Criterion (our internal model)
public static Criterion criterionFromFilter(final FacetFilterInput filter, final Boolean skipKeywordSuffix) {
Criterion result = new Criterion();
result.setField(getFilterField(filter.getField()));

if (skipKeywordSuffix) {
result.setField(filter.getField());
} else {
result.setField(getFilterField(filter.getField()));
}

// `value` is deprecated in place of `values`- this is to support old query patterns. If values is provided,
// this statement will be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public CompletableFuture<AssertionRunEventsResult> get(DataFetchingEnvironment e
}

@Nullable
private Filter buildFilter(@Nullable FilterInput filtersInput, @Nullable final String status) {
public static Filter buildFilter(@Nullable FilterInput filtersInput, @Nullable final String status) {
if (filtersInput == null && status == null) {
return null;
}
Expand All @@ -109,7 +109,7 @@ private Filter buildFilter(@Nullable FilterInput filtersInput, @Nullable final S
facetFilters.addAll(filtersInput.getAnd());
}
return new Filter().setOr(new ConjunctiveCriterionArray(new ConjunctiveCriterion().setAnd(new CriterionArray(facetFilters.stream()
.map(filter -> criterionFromFilter(filter))
.map(filter -> criterionFromFilter(filter, true))
.collect(Collectors.toList())))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private Filter buildFilters(@Nullable FilterInput maybeFilters) {
return null;
}
return new Filter().setOr(new ConjunctiveCriterionArray(new ConjunctiveCriterion().setAnd(new CriterionArray(maybeFilters.getAnd().stream()
.map(filter -> criterionFromFilter(filter))
.map(filter -> criterionFromFilter(filter, true))
.collect(Collectors.toList())))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testGetSuccess() throws Exception {
Mockito.eq(10L),
Mockito.eq(5),
Mockito.eq(false),
Mockito.any(Filter.class),
Mockito.eq(AssertionRunEventResolver.buildFilter(null, AssertionRunStatus.COMPLETE.toString())),
Mockito.any(Authentication.class)
)).thenReturn(
ImmutableList.of(
Expand Down Expand Up @@ -108,4 +108,4 @@ public void testGetSuccess() throws Exception {
assertEquals((long) graphqlRunEvent.getResult().getUnexpectedCount(), 2L);
assertEquals(graphqlRunEvent.getResult().getType(), com.linkedin.datahub.graphql.generated.AssertionResultType.SUCCESS);
}
}
}

0 comments on commit 5a20ac4

Please sign in to comment.