@Test @DisplayName("match columns") void matchColumns() { Column column = booleanColumn(); boolean actualValue = false; ColumnName columnName = column.name(); Collection<Object> ids = Collections.emptyList(); Multimap<Column, Filter> filters = ImmutableMultimap.of(column, eq(columnName.value(), actualValue)); CompositeQueryParameter parameter = createParams(filters, ALL); QueryParameters params = QueryParameters.newBuilder() .add(parameter) .build(); EntityQuery<?> query = createQuery(ids, params); Any matchingId = AnyPacker.pack(Sample.messageOfType(TaskId.class)); Any nonMatchingId = AnyPacker.pack(Sample.messageOfType(TaskId.class)); EntityQueryMatcher<?> matcher = new EntityQueryMatcher<>(query); EntityRecord matching = EntityRecord.newBuilder() .setEntityId(matchingId) .build(); EntityRecord nonMatching = EntityRecord.newBuilder() .setEntityId(nonMatchingId) .build(); Map<ColumnName, Object> matchingColumns = ImmutableMap.of(columnName, actualValue); EntityRecordWithColumns nonMatchingRecord = EntityRecordWithColumns.of(nonMatching, Collections.emptyMap()); EntityRecordWithColumns matchingRecord = createRecord(matching, matchingColumns); assertTrue(matcher.test(matchingRecord)); assertFalse(matcher.test(nonMatchingRecord)); }
@Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); @Override boolean test(@Nullable EntityRecordWithColumns input); }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); @Override boolean test(@Nullable EntityRecordWithColumns input);  }