Skip to content

Commit

Permalink
Add @CanIgnoreReturnValue to some methods in MatchAssert
Browse files Browse the repository at this point in the history
This is an AssertJ annotation, but IDEA knows about it (and ErrorProne
probably too). It prevents a warning in the IDE that the return value is
ignored, which is a false positive in this case, because we don't have
to string more assertions. This makes the use optional without
suppressing any more warnings inside the method.
  • Loading branch information
ksobolew authored and kokosing committed Oct 15, 2021
1 parent 9d09ac7 commit 4d35eac
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.trino.sql.planner.rowpattern.ir.IrRowPattern;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.AssertProvider;
import org.assertj.core.util.CanIgnoreReturnValue;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -58,6 +59,7 @@ public static AssertProvider<MatchAssert> match(IrRowPattern pattern, String inp
return () -> new MatchAssert(matcher.run(identityEvaluator(mappedInput), new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "dummy")), labelMapping);
}

@CanIgnoreReturnValue
public MatchAssert hasLabels(char[] expectedLabels)
{
int[] mappedExpected = new int[expectedLabels.length];
Expand All @@ -70,6 +72,7 @@ public MatchAssert hasLabels(char[] expectedLabels)
.isEqualTo(mappedExpected));
}

@CanIgnoreReturnValue
public MatchAssert hasCaptures(int[] expectedCaptures)
{
return satisfies(actual -> assertThat(actual.isMatched()))
Expand All @@ -78,6 +81,7 @@ public MatchAssert hasCaptures(int[] expectedCaptures)
.isEqualTo(expectedCaptures));
}

@CanIgnoreReturnValue
public MatchAssert isNoMatch()
{
return satisfies(actual -> assertThat(!actual.isMatched()));
Expand Down

0 comments on commit 4d35eac

Please sign in to comment.